lookup#

VarDictND.lookup(*key)[source]#

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

Parameters:
*keykey
Returns:
highspy.highs_var or 0

Examples

Create highspy model:

>>> from highspy import Highs, HighsVarType
>>> mdl = Highs()

Create index-set:

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

Add variables:

>>> from opti_extensions.highspy import addVariables
>>> arc_flow = addVariables(
...     mdl, arcs, ub=10, type=HighsVarType.kContinuous, name_prefix='arc-flow_'
... )

Lookup with keys:

>>> arc_flow.lookup('A', 'B')
highs_var(0)
>>> arc_flow.lookup('X', 'Y')
0