lookup#
- VarDict1D.lookup(key)[source]#
Get the variable for the specified key, or zero if it is not found.
- Parameters:
- keykey
- Returns:
- gurobipy.Var or
0
- gurobipy.Var or
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()
Lookup for keys:
>>> node_select.lookup('A') <gurobi.Var node-select[A]>
>>> node_select.lookup('Z') 0