class VariableGroup(**kwargs)[source]


Creates a group of Variable objects

argvlist, dict, int, pandas.Index

Loop index for variable group

namestring, optional

Name (prefix) of the variables

vartypestring, optional

Type of variables, BIN, INT, or CONT

lblist, dict, pandas.Series, optional

Lower bounds of variables

ublist, dict, pandas.Series, optional

Upper bounds of variables

initfloat, optional

Initial values of variables


  • When working with a single model, use the sasoptpy.Model.add_variables() method.

  • If a variable group object is created, it can be added to a model using the sasoptpy.Model.include() method.

  • An individual variable inside the group can be accessed using indices.

    >>> z = so.VariableGroup(2, ['a', 'b', 'c'], name='z', lb=0, ub=10)
    >>> print(repr(z[0, 'a']))
    sasoptpy.Variable(name='z_0_a', lb=0, ub=10, vartype='CONT')


>>> PERIODS = ['Period1', 'Period2', 'Period3']
>>> production = so.VariableGroup(PERIODS, vartype=so.INT,
                                  name='production', lb=10)
>>> print(production)
Variable Group (production) [
  [Period1: production['Period1']]
  [Period2: production['Period2']]
  [Period3: production['Period3']]
>>> x = so.VariableGroup(4, vartype=so.BIN, name='x')
>>> print(x)
Variable Group (x) [
  [0: x[0]]
  [1: x[1]]
  [2: x[2]]
  [3: x[3]]
>>> z = so.VariableGroup(2, ['a', 'b', 'c'], name='z')
>>> print(z)
Variable Group (z) [
  [(0, 'a'): z[0, 'a']]
  [(0, 'b'): z[0, 'b']]
  [(0, 'c'): z[0, 'c']]
  [(1, 'a'): z[1, 'a']]
  [(1, 'b'): z[1, 'b']]
  [(1, 'c'): z[1, 'c']]
>>> print(repr(z))
sasoptpy.VariableGroup([0, 1], ['a', 'b', 'c'], name='z')