dimod.lp.load#

load(file_like: str | bytes | IOBase) 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.

Parameters:

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

Returns:

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

loads()

Added in version 0.11.0.