pyepo.model.omo.omomodel ======================== .. py:module:: pyepo.model.omo.omomodel .. autoapi-nested-parse:: Abstract optimization model based on Pyomo Classes ------- .. autoapisummary:: pyepo.model.omo.omomodel.optOmoModel Module Contents --------------- .. py:class:: optOmoModel(solver: str = 'glpk') Bases: :py:obj:`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"``). :ivar _model: underlying Pyomo model :vartype _model: pyomo.ConcreteModel :ivar solver: name of the Pyomo solver backend :vartype solver: str .. py:attribute:: solver :value: 'glpk' .. py:method:: get_config() -> dict Return the constructor configuration for this model. .. py:method:: setObj(c: numpy.ndarray | torch.Tensor | list) -> None A method to set the objective function :param c: cost of objective function .. py:method:: solve() -> tuple[numpy.ndarray, float] A method to solve the model :returns: optimal solution (np.ndarray) and objective value (float) :rtype: tuple .. py:method:: copy() -> Self A method to copy the model :returns: new copied model :rtype: optModel .. py:method:: addConstr(coefs: numpy.ndarray | torch.Tensor | list, rhs: float) -> Self A method to add a new constraint :param coefs: coefficients of new constraint :param rhs: right-hand side of new constraint :returns: new model with the added constraint :rtype: optModel