dimod.higherorder.utils.make_quadratic¶

make_quadratic
(poly, strength, vartype=None, bqm=None)[source]¶ Create a binary quadratic model from a higher order polynomial.
Parameters:  poly (dict) – Polynomial as a dict of form {term: bias, …}, where term is a tuple of variables and bias the associated bias.
 strength (float) – The energy penalty for violating the prodcut constraint. Insufficient strength can result in the binary quadratic model not having the same minimizations as the polynomial.
 vartype (
Vartype
/str/set, optional) –Variable type for the binary quadratic model. Accepted input values:
Vartype.SPIN
,'SPIN'
,{1, 1}
Vartype.BINARY
,'BINARY'
,{0, 1}
If bqm is provided, vartype is not required.
 bqm (
BinaryQuadraticModel
, optional) – The terms of the reduced polynomial are added to this binary quadratic model. If not provided, a new binary quadratic model is created.
Returns: Examples
>>> poly = {(0,): 1, (1,): 1, (2,): 1.5, (0, 1): 1, (0, 1, 2): 2} >>> bqm = dimod.make_quadratic(poly, 5.0, dimod.SPIN)