Skip to content

Commit

Permalink
Avoid deep-copying the ansatz
Browse files Browse the repository at this point in the history
  • Loading branch information
mrossinek committed Sep 28, 2022
1 parent 8e47ab9 commit 40ba702
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions qiskit/algorithms/minimum_eigensolvers/adapt_vqe.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def compute_minimum_eigenvalue(
raise TypeError("The AdaptVQE ansatz must be of the EvolvedOperatorAnsatz type.")

# Overwrite the solver's ansatz with the initial state
solver_ansatz = copy.deepcopy(self.solver.ansatz)
self._tmp_ansatz = self.solver.ansatz
self._excitation_pool = self._tmp_ansatz.operators
self.solver.ansatz = self._tmp_ansatz.initial_state
Expand Down Expand Up @@ -269,7 +268,7 @@ def compute_minimum_eigenvalue(
result.aux_operators_evaluated = aux_values

logger.info("The final energy is: %s", str(result.eigenvalue))
self.solver.ansatz = solver_ansatz
self.solver.ansatz.operators = self._excitation_pool
return result


Expand Down

0 comments on commit 40ba702

Please sign in to comment.