pyepo.model.omo.omomodel¶
Abstract optimization model based on Pyomo
Classes¶
Abstract base class for Pyomo-backed optimization models. |
Module Contents¶
- class pyepo.model.omo.omomodel.optOmoModel(solver: str = 'glpk')¶
Bases:
pyepo.model.opt.optModelAbstract base class for Pyomo-backed optimization models.
Subclasses implement
_getModelto build a PyomoConcreteModeland return(model, variables). UnlikeoptGrbModel, the objective sense is not detected automatically – setself.modelSense = EPO.MAXIMIZEin_getModelfor maximization problems (default is minimization). The cost vector is wired into the model as a mutableParamso thatsetObjonly updates parameter values rather than rebuilding the objective expression.Any solver supported by Pyomo can be plugged in via the
solverargument (e.g.,"glpk","gurobi","cbc").- Variables:
_model (pyomo.ConcreteModel) – underlying Pyomo model
solver (str) – name of the Pyomo solver backend
- solver = 'glpk'¶
- 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 (np.ndarray) 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: