lookup#

VarDictND.lookup(*key)[source]#

Get the variable for the specified key, or zero if it is not found.

Parameters:
*keykey
Returns:
xpress.var or 0

Examples

Create xpress problem:

>>> import xpress as xp
>>> import warnings
>>> warnings.filterwarnings('ignore', category=xp.LicenseWarning)
>>> prob = xp.problem()

Create index-set:

>>> arcs = IndexSetND([('A', 'B'), ('B', 'C'), ('C', 'B')], names=['ori', 'des'])

Add variables:

>>> from opti_extensions.xpress import addVariables
>>> arc_flow = addVariables(prob, arcs, name='arc-flow', ub=10, vartype=xp.continuous)

Lookup with keys:

>>> arc_flow.lookup('A', 'B')
arc-flow(('A', 'B'))
>>> arc_flow.lookup('X', 'Y')
0