pyepo.model.ort.ortcpmodel ========================== .. py:module:: pyepo.model.ort.ortcpmodel .. autoapi-nested-parse:: Abstract optimization model based on Google OR-Tools CP-SAT Classes ------- .. autoapisummary:: pyepo.model.ort.ortcpmodel.optOrtCpModel Module Contents --------------- .. py:class:: optOrtCpModel Bases: :py:obj:`pyepo.model.opt.optModel` Abstract base class for OR-Tools CP-SAT (constraint programming) models. Subclasses implement ``_getModel`` to build a ``cp_model.CpModel`` and return ``(model, variables)``. CP-SAT is an **integer-only** solver, so float cost vectors are scaled internally (multiplied by ``_OBJ_SCALE`` and cast to int) before being passed to the solver; the objective value returned by ``solve`` is rescaled back to the original units. As with the other non-Gurobi/non-COPT backends, ``modelSense`` is not auto-detected -- set ``self.modelSense = EPO.MAXIMIZE`` in ``_getModel`` for maximization (default is minimization). CP-SAT does not support LP relaxation, so ``relax()`` raises ``RuntimeError``. :ivar _model: underlying OR-Tools CP-SAT model :vartype _model: cp_model.CpModel .. 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 (list) 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 .. py:method:: relax() -> optOrtCpModel CP-SAT does not support LP relaxation.