pyepo.model.ort.ortcpmodel¶
Abstract optimization model based on Google OR-Tools CP-SAT
Classes¶
Abstract base class for OR-Tools CP-SAT (constraint programming) models. |
Module Contents¶
- class pyepo.model.ort.ortcpmodel.optOrtCpModel¶
Bases:
pyepo.model.opt.optModelAbstract base class for OR-Tools CP-SAT (constraint programming) models.
Subclasses implement
_getModelto build acp_model.CpModeland return(model, variables). CP-SAT is an integer-only solver, so float cost vectors are scaled internally (multiplied by_OBJ_SCALEand cast to int) before being passed to the solver; the objective value returned bysolveis rescaled back to the original units.As with the other non-Gurobi/non-COPT backends,
modelSenseis not auto-detected – setself.modelSense = EPO.MAXIMIZEin_getModelfor maximization (default is minimization). CP-SAT does not support LP relaxation, sorelax()raisesRuntimeError.- Variables:
_model (cp_model.CpModel) – underlying OR-Tools CP-SAT model
- 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:
- relax() optOrtCpModel¶
CP-SAT does not support LP relaxation.