pyepo.model.ort.ortmodel¶
Abstract optimization model based on Google OR-Tools (pywraplp)
Attributes¶
Classes¶
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.optModelAbstract base class for OR-Tools pywraplp (LP/MIP) models.
Subclasses implement
_getModelto build apywraplp.Solverand return(model, variables). UnlikeoptGrbModel, the objective sense is not detected automatically – setself.modelSense = EPO.MAXIMIZEin_getModelfor maximization problems (default is minimization). Solver output is silenced by default. The backend solver is selected at construction time via thesolverargument (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:
- 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:
- pyepo.model.ort.ortmodel.num_vars = 10¶