I am trying to implement a simple AdaptVQE in Qiskit. Following the documentation provided by Qiskit, this should be very simple:

from qiskit.algorithms.minimum_eigensolvers import AdaptVQE, VQE
from qiskit.algorithms.optimizers import SLSQP
from qiskit.primitives import Estimator
from qiskit.circuit.library import EvolvedOperatorAnsatz

# get your Hamiltonian
hamiltonian = ...

# construct your ansatz
ansatz = EvolvedOperatorAnsatz(...)

vqe = VQE(Estimator(), ansatz, SLSQP())

adapt_vqe = AdaptVQE(vqe)

eigenvalue, _ = adapt_vqe.compute_minimum_eigenvalue(hamiltonian)

I tried putting

hamiltonian = SparsePauliOp("ZZ").to_operator()

along with providing operators to the EvolvedOperatorAnsatz, but none of this worked.

Any help is appreciated.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.