pyepo.model.ort.ortmodel

Abstract optimization model based on Google OR-Tools (pywraplp)

Attributes

Classes

optOrtModel

Abstract base class for OR-Tools pywraplp (LP/MIP) models.

Module Contents

class pyepo.model.ort.ortmodel.optOrtModel(solver: str = 'scip')

Bases: pyepo.model.opt.optModel

Abstract base class for OR-Tools pywraplp (LP/MIP) models.

Subclasses implement _getModel to build a pywraplp.Solver and return (model, variables). Unlike optGrbModel, the objective sense is not detected automatically – set self.modelSense = EPO.MAXIMIZE in _getModel for maximization problems (default is minimization). Solver output is silenced by default. The backend solver is selected at construction time via the solver argument (e.g., "scip", "glop", "cbc").

Variables:
  • _model (pywraplp.Solver) – underlying OR-Tools linear solver

  • solver (str) – pywraplp backend name

solver = 'scip'
setObj(c: numpy.ndarray | torch.Tensor | list) None

A method to set the objective function

Parameters:

c – cost of objective function

solve() tuple[numpy.ndarray, float]

A method to solve the model

Returns:

optimal solution (list) and objective value (float)

Return type:

tuple

copy() Self

A method to copy the model

Returns:

new copied model

Return type:

optModel

addConstr(coefs: numpy.ndarray | torch.Tensor | list, rhs: float) Self

A method to add a new constraint

Parameters:
  • coefs – coefficients of new constraint

  • rhs – right-hand side of new constraint

Returns:

new model with the added constraint

Return type:

optModel

pyepo.model.ort.ortmodel.num_vars = 10