lookup#

VarDict1D.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:

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

Add variables:

>>> from opti_extensions.xpress import addVariables
>>> node_select = addVariables(prob, nodes, name='node-select', vartype=xp.binary)

Lookup for keys:

>>> node_select.lookup('A')
node-select(A)
>>> node_select.lookup('Z')
0