-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Environment
- qiskit.version: 0.25.1
- Python version: 3.8.0
- Operating system: Ubuntu 20.04
What is happening?
In the Python file neoh2evo.py, the ansatz.compose(init_state, front=True) call is effectively ignored because the returned value is not reassigned and the argument inplace is not used. As a result, there is no initial state in the ansatz passed to the VQE.
How can we reproduce the issue?
Run the following code in the Python file:
...
# setup the initial state for the ansatz
from qiskit_mod.qiskit_nat import NeoHartreeFock
init_state = NeoHartreeFock(2*num_spin_orbitals, mixnum_particles, converter)
# setup the ansatz for VQE
from qiskit.circuit.library import TwoLocal
ansatz = TwoLocal(2*num_spin_orbitals, ['ry', 'rz'], 'cz',reps=2)
# add the initial state
ansatz.compose(init_state, front=True)
ansatz.draw() # <-- this will not include the initial stateWhat should happen?
I would have expected the initial state to be included in the ansatz passed to the VQE.
Any Suggestions?
The ansatz.compose(init_state, front=True) call should be reassigned to ansatz or the inplace=True argument should be used to ensure the initial state is included in the ansatz passed to the VQE. Here is the suggested version:
# add the initial state
ansatz = ansatz.compose(init_state, front=True)or
# add the initial state
ansatz.compose(init_state, front=True, inplace=True)Thanks in advance, I wish you a happy and productive day
Metadata
Metadata
Assignees
Labels
No labels