[=10th Qiskit VQE算法时的属性错误

Atribute error when running the Qiskit VQE Alogrithum

我正在尝试 运行 使用 Aer 后端模拟器的 VQE 算法。但是,每当我 运行 算法时,我都会收到此错误:“AttributeError: 'TwoLocal' object has no attribute 'set_max_evals_grouped'”

任何人都可以解释这个错误的含义以及我该如何解决它吗?

这是我使用的代码:

driver = PySCFDriver(atom='Li .0 .0 .0; H .0 .0 1.5049', unit=UnitsType.ANGSTROM, charge=0, spin=0, basis='sto3g')



#create  second quantiesed operator 
es_problem= ElectronicStructureProblem(driver)
seconded_quanitsied_oprator= es_problem.second_q_ops() 
print(seconded_quanitsied_oprator)



#convert to qubit operator 


qubit_transformation = QubitConverter(JordanWignerMapper())
qubit_operator = qubit_transformation.convert(seconded_quanitsied_oprator[0])
print(qubit_operator) 


#set up simulator 
backend = BasicAer.get_backend('statevector_simulator')
quantum_instance=QuantumInstance(backend=backend)

# VEQ algothiums 
groundstate_energies = []
classical_optimizer = SLSQP(maxiter = 1000)


ansatz = TwoLocal(rotation_blocks='ry', entanglement_blocks='cz')


Vqe = VQE(qubit_operator,ansatz,SLSQP,quantum_instance )

您正在以旧方式使用 VQE(当它在 Aqua 中时),所以它不再起作用了。你应该做的是:

vqe = VQE(ansatz = ansatz,
          optimizer = SLSQP, 
          quantum_instance=quantum_instance)
vqe_result = vqe.compute_minimum_eigenvalue(qubit_operator)

以防万一,您需要了解的有关如何从 Aqua 移动的所有信息都可以在此处找到:https://qiskit.org/documentation/aqua_migration.html