STEP
Optimizer
Top Results
Qubit |
Probability |
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
- | - |
Python Code
from qiskit import transpile
from qiskit.circuit.library import QAOAAnsatz
from qiskit.quantum_info import SparsePauliOp
from qiskit_aer import AerSimulator
from qiskit_aer.primitives import EstimatorV2, SamplerV2
ham = "IIIZZ+IIZIZ+3*ZZZII"
hamiltonian = SparsePauliOp.from_list([])
ansatz = QAOAAnsatz(hamiltonian, reps=1)
x0 = 2 * np.pi * np.random.rand(ansatz.num_parameters)
ansatz_decomposed = ansatz.decompose()
ansatz_t = transpile(ansatz.decomposed, sim, optimization_level=0)
estimator = EstimatorV2()
res = minimize(cost_func, x0, args=(ansatz_t, hamiltonian, estimator), method="Powell")