# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ![qiskit_header.png](../../images/qiskit_header.png)

# # _*Qiskit Aqua: Tutorial to build a pluggable algorithm/component*_ 
#
# The latest version of this notebook is available on https://github.com/Qiskit/qiskit-tutorial.
#
# ***
# ### Contributors
# <NAME><sup>[1]</sup>, <NAME><sup>[1]</sup>, <NAME><sup>[1]</sup>, <NAME><sup>[1]</sup>, <NAME><sup>[1]</sup>, <NAME><sup>[1]</sup>
# ### Affiliation
# - <sup>[1]</sup>IBMQ

# ### Introduction
#
# This notebook is part of the simple example of an algorithm for `Qiskit Aqua`. This sample, called `Evolution Fidelity`, illustrates how to implement an algorithm and what steps to take to configure and run it. The implementation of the algorithm itself is located in the `evolutionfidelity` directory.

# ### Use the algorithm directly
# You can use the designed algorithm/components as is.

# +
from qiskit import BasicAer
import numpy as np
from qiskit.aqua.operators import MatrixOperator, op_converter
from evolutionfidelity.evolutionfidelity import EvolutionFidelity
from qiskit.aqua.components.initial_states import Zero
from qiskit.aqua import QuantumInstance
num_qubits = 2
temp = np.random.random((2 ** num_qubits, 2 ** num_qubits))
qubit_op = op_converter.to_weighted_pauli_operator(MatrixOperator(matrix=temp + temp.T))

initial_state = Zero(qubit_op.num_qubits)

algo = EvolutionFidelity(qubit_op, initial_state, expansion_order=1)

backend = BasicAer.get_backend('statevector_simulator')
quantum_instance = QuantumInstance(backend=backend)

result = algo.run(quantum_instance)
print(result['score'])
# -

import qiskit.tools.jupyter
# %qiskit_version_table
# %qiskit_copyright



StarcoderdataJupyterScriptsDedupFiltered