dimod.lp.loads

loads(obj: Union[str, ByteString]) dimod.constrained.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.

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()

New in version 0.11.0.