sasoptpy.abstract.ImplicitVar

class ImplicitVar(**kwargs)[source]

Bases: object

Creates an implicit variable

Parameters
argvGenerator, optional

Generator object for the implicit variable

namestring, optional

Name of the implicit variable

Notes

  • If the loop inside generator is over an abstract object, a definition for the object will be created inside Model.to_optmodel() method.

Examples

Regular Implicit Variable

>>> I = range(5)
>>> x = so.Variable(name='x')
>>> y = so.VariableGroup(I, name='y')
>>> z = so.ImplicitVar((x + i * y[i] for i in I), name='z')
>>> for i in z:
>>>     print(i, z[i])
(0,) x
(1,) x + y[1]
(2,) x + 2 * y[2]
(3,) x + 3 * y[3]
(4,) x + 4 * y[4]

Abstract Implicit Variable

>>> I = so.Set(name='I')
>>> x = so.Variable(name='x')
>>> y = so.VariableGroup(I, name='y')
>>> z = so.ImplicitVar((x + i * y[i] for i in I), name='z')
>>> print(z._defn())
impvar z {i_1 in I} = x + i_1 * y[i_1];
>>> for i in z:
>>>     print(i, z[i])
(sasoptpy.abstract.SetIterator(name=i_1, ...),) x + i_1 * y[i_1]