load(file_like: Union[str, bytes, io.IOBase]) dimod.constrained.constrained.ConstrainedQuadraticModel[source]

Construct a constrained quadratic model from 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.


file_like – Either a str or bytes object representing a path, or a file-like object.


An example of reading from a LP file.

with open('example.lp', 'rb') as f:
    cqm = dimod.lp.load(f)

An example of loading from a path

cqm = dimod.lp.load('example.lp')

See also


New in version 0.11.0.