pyepo.model.grb.grbmodel¶
Abstract optimization model based on GurobiPy
Classes¶
Abstract base class for GurobiPy-backed optimization models. |
Module Contents¶
- class pyepo.model.grb.grbmodel.optGrbModel¶
Bases:
pyepo.model.opt.optModelAbstract base class for GurobiPy-backed optimization models.
Subclasses implement
_getModelto build agurobipy.Modeland return(model, variables). The objective sense is auto-detected from the underlying Gurobi model –modelSensedoes not need to be set manually. Solver output is silenced by default; cost-vector updates use the C-levelsetAttr("Obj", ...)batch path for efficiency.- Variables:
_model (gurobipy.Model) – underlying Gurobi 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: