You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ansatzfromqiskit_mod.qiskit_natimportNeoHartreeFockinit_state=NeoHartreeFock(2*num_spin_orbitals, mixnum_particles, converter)
# setup the ansatz for VQEfromqiskit.circuit.libraryimportTwoLocalansatz=TwoLocal(2*num_spin_orbitals, ['ry', 'rz'], 'cz',reps=2)
# add the initial stateansatz.compose(init_state, front=True)
ansatz.draw() # <-- this will not include the initial state
What 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 stateansatz=ansatz.compose(init_state, front=True)
or
# add the initial stateansatz.compose(init_state, front=True, inplace=True)
Thanks in advance, I wish you a happy and productive day
The text was updated successfully, but these errors were encountered:
Environment
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 argumentinplace
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:
What 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 toansatz
or theinplace=True
argument should be used to ensure the initial state is included in the ansatz passed to the VQE. Here is the suggested version:or
Thanks in advance, I wish you a happy and productive day
The text was updated successfully, but these errors were encountered: