pyepo.model.grb.grbmodel

Abstract optimization model based on GurobiPy

Classes

optGrbModel

Abstract base class for GurobiPy-backed optimization models.

Module Contents

class pyepo.model.grb.grbmodel.optGrbModel

Bases: pyepo.model.opt.optModel

Abstract base class for GurobiPy-backed optimization models.

Subclasses implement _getModel to build a gurobipy.Model and return (model, variables). The objective sense is auto-detected from the underlying Gurobi model – modelSense does not need to be set manually. Solver output is silenced by default; cost-vector updates use the C-level setAttr("Obj", ...) batch path for efficiency.

Variables:

_model (gurobipy.Model) – underlying Gurobi model

property num_cost: int

number of costs to be predicted

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:

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