Domain#

class gamspy.Domain(*sets: tuple[Set | Alias | ImplicitSet])[source]#

Bases: object

Domain class needed for where statements on multidimensional index list in operations

Parameters:
sets: tuple[Set | str]

Methods

gamsRepr()

Representation of this Domain in GAMS language.

latexRepr()

Representation of this Domain in Latex.

Examples

>>> from gamspy import Container, Set, Ord, Card, Variable, Equation, Sum, Domain
>>> m = Container()
>>> X = Set(m, name="X", records=[f"I{i}" for i in range(1, 22)])
>>> Y = Set(m, name="Y", records=[f"J{j}" for j in range(1, 22)])
>>> inside = Set(m, name="inside", domain=[X, Y])
>>> inside[X, Y].where[~((Ord(X) == 1) & (Ord(X) == Card(X)))] = True
>>> f = Variable(m, name="f", domain=[X, Y], type="positive")
>>> obj = Variable(m, name="obj")
>>> objfun = Equation(m, name="objfun", type="regular")
>>> objfun[...] = obj == Sum(Domain(X, Y).where[inside[X, Y]], f[X.lead(1), Y] - f[X, Y])
gamsRepr() str[source]#

Representation of this Domain in GAMS language.

Returns:
str

Examples

>>> from gamspy import Container, Set, Domain
>>> m = Container()
>>> X = Set(m, name="x", records=[f"I{i}" for i in range(1, 22)])
>>> Y = Set(m, name="y", records=[f"J{j}" for j in range(1, 22)])
>>> Domain(X, Y).gamsRepr()
'(x,y)'
latexRepr() str[source]#

Representation of this Domain in Latex.

Returns:
str