from_ising¶

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., ith variable is mapped to ith qubit. See https://github.com/Qiskit/qiskitterra/issues/1148 for details.
 Parameters
qubit_op (
Union
[OperatorBase
,PauliSumOp
]) – The qubit operator of the problem.offset (
float
) – The constant term 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\}\). Otherwise, \(x^2\) is treat as a quadratic term. The default value is False.
 Return type
QuadraticProgram
 Returns
The quadratic program corresponding to the qubit operator.
 Raises
QiskitOptimizationError – if there are Pauli Xs or Ys in any Pauli term
QiskitOptimizationError – if there are more than 2 Pauli Zs in any Pauli term
QiskitOptimizationError – if any Pauli term has an imaginary coefficient
NotImplementedError – If the input operator is a ListOp