dimod.lp.loads#

loads(obj: str | bytes | bytearray) ConstrainedQuadraticModel[source]#

Construct a constrained quadratic model from a string formatted as a LP file.

LP files are a common format for encoding optimization models. See documentation from Gurobi and CPLEX.

Note that if the objective function is specified as a maximization function then it will be converted to a minimization function by flipping the sign of all of the biases.

Parameters:

obj – A str or bytes formatted like an LP file.

Returns:

An example of reading a string formatted as an LP file.

lp = '''
Minimize
    x0 - 2 x1
Subject To
    x0 + x1 = 1
Binary
    x0 x1
End
'''

cqm = dimod.lp.loads(lp)

See also

load()

Added in version 0.11.0.