ham_bqm_to_ham_operator

ham_bqm_to_ham_operator#

iqm.qaoa.transforming_functions.ham_bqm_to_ham_operator(ham_bqm)[source]#

A function to transform Hamiltonian represented as a BQM into a SparsePauliOp.

A Hamiltonian as SparsePauliOp may be used by qiskit functions that e.g., calculate expectation values.

Parameters:

ham_bqm (BinaryQuadraticModel) – A BinaryQuadraticModel with vartype=SPIN, i.e., the linear and quadratic terms correspond to the coefficients before the corresponding Z and ZZ operators in the problem Hamiltonian.

Returns:

The Hamiltonian as SparsePauliOp to be used by qiskit.

Return type:

SparsePauliOp