qiskit.algorithms.VQD.get_energy_evaluation¶
- VQD.get_energy_evaluation(step, operator, return_expectation=False, prev_states=None)[source]¶
Returns a function handle to evaluates the energy at given parameters for the ansatz.
This return value is the objective function to be passed to the optimizer for evaluation.
- Parameters
step (
int
) – level of energy being calculated. 0 for ground, 1 for first excited state…operator (
OperatorBase
) – The operator whose energy to evaluate.return_expectation (
bool
) – If True, return theExpectationBase
expectation converter used in the construction of the expectation value. Useful e.g. to evaluate other operators with the same expectation value converter.prev_states (
Optional
[List
[ndarray
]]) – List of parameters from previous rounds of optimization.
- Return type
Callable
[[ndarray
],Union
[float
,List
[float
]]]- Returns
A callable that computes and returns the energy of the hamiltonian of each parameter, and, optionally, the expectation
- Raises
RuntimeError – If the circuit is not parameterized (i.e. has 0 free parameters).
AlgorithmError – If operator was not provided.