ham_bp_to_ham_operator#
- iqm.qaoa.transforming_functions.ham_bp_to_ham_operator(ham_bp)[source]#
A function to transform a Hamiltonian represented as a BP into a
SparsePauliOp.A Hamiltonian as
SparsePauliOpmay be used byqiskitfunctions that e.g., calculate expectation values. The inputdimod.higherorder.BinaryPolynomialneeds to have sortable variables. This is already the case if theham_bpcomes from aHUBOInstance.- Parameters:
ham_bp (BinaryPolynomial) – A
BinaryPolynomialwithvartype=SPIN, where each term corresponds to a product of spin variables and its coefficient represents the prefactor of the associated multi-qubit Z…Z Pauli operator in the problem Hamiltonian.- Returns:
The Hamiltonian as
SparsePauliOpto be used byqiskit.- Raises:
TypeError – If the variables of the input
ham_bpare not sortable.- Return type: