QuadraticProgram.from_ising¶
- QuadraticProgram.from_ising(qubit_op, offset=0.0, linear=False)[source]¶
Create a quadratic program from a qubit operator and a shift value.
Variables are mapped to qubits in the same order, i.e., i-th variable is mapped to i-th qubit. See https://github.com/Qiskit/qiskit-terra/issues/1148 for details.
- Parameters:
qubit_op (
OperatorBase
) – The qubit operator of the problem.offset (
float
) – The constant value in the Ising Hamiltonian.linear (
bool
) – If linear is True, \(x^2\) is treated as a linear term since \(x^2 = x\) for \(x \in \{0,1\}\). Else, \(x^2\) is treated as a quadratic term. The default value is False.
- Raises:
QiskitOptimizationError – If there are Pauli Xs in any Pauli term
QiskitOptimizationError – If there are more than 2 Pauli Zs in any Pauli term
NotImplementedError – If the input operator is a ListOp
- Return type: