pyepo.model.omo.omomodel

Abstract optimization model based on Pyomo

Classes

optOmoModel

Abstract base class for Pyomo-backed optimization models.

Module Contents

class pyepo.model.omo.omomodel.optOmoModel(solver: str = 'glpk')

Bases: pyepo.model.opt.optModel

Abstract base class for Pyomo-backed optimization models.

Subclasses implement _getModel to build a Pyomo ConcreteModel 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). The cost vector is wired into the model as a mutable Param so that setObj only updates parameter values rather than rebuilding the objective expression.

Any solver supported by Pyomo can be plugged in via the solver argument (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:

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