sum#

VarDict1D.sum()[source]#

Sum all variables in an expression.

Returns:
gurobipy.LinExpr

Examples

Create gurobipy model:

>>> from gurobipy import GRB, Model
>>> mdl = Model()

Create index-set:

>>> nodes = IndexSet1D(['A', 'B', 'C'], name='node')

Add variables:

>>> from opti_extensions.gurobipy import addVars
>>> node_select = addVars(mdl, nodes, vtype=GRB.BINARY, name='node-select')
>>> mdl.update()

Sum all variables:

>>> node_select.sum()
<gurobi.LinExpr: node-select[A] + node-select[B] + node-select[C]>