EstimatorSingleLayer#
Module: iqm.qaoa.backends
- class iqm.qaoa.backends.EstimatorSingleLayer[source]#
Bases:
EstimatorBackendThe estimator class for calculating the expectation value analytically (for \(p=1\) QAOA).
Methods
Calculates the expectation value of the Hamiltonian for \(p=1\) QAOA.
The method for estimating the exp.
- estimate(qaoa_object)[source]#
Calculates the expectation value of the Hamiltonian for \(p=1\) QAOA.
The function calculates the energy (exp. val. of the Hamiltonian) by adding the expectation values of its individual terms expressed through equation (12) in [2]. The calculation includes a constant term (coming from the translation of a QUBO problem to a Hamiltonian).
- Parameters:
qaoa_object (QUBOQAOA) – The instance of
QUBOQAOAwhose expectation value is to be calculated.- Returns:
The expectation value of the energy of the QAOA state using
angles.- Raises:
ValueError – If the provided
QUBOQAOAobject has more than 1 layer.TypeError – If the variables in the
qaoa_object.hamiltonian_bqmare not labelled by integers. UsingQUBOQAOAcorrectly should automatically lead to its attributehamiltonian_bqmhaving its variables labelled by integers.
- Return type:
- estimate_correlations_z(qaoa_object, target_qubits)[source]#
The method for estimating the exp. value of products of Z operators on
target_qubits.This works only if the set(s) in
target_qubitsare of size at most 2. In case of a set of two qubits, it adds an interaction of strength 0 between them, so that they are neighboring in the BQM.- Parameters:
- Returns:
The estimated expected value of product of Z operators on given
target_qubits. Or a list of those, iftarget_qubitswas given as a list.- Raises:
ValueError – If the number of layers of the QAOA is not 1.
ValueError – If the weight of the operator whose exp. value we are interested in (i.e., the number of qubits it affects) is more than 2.
- Return type:
Inheritance
