Sum#

class gamspy.Sum(domain: Set | Alias | tuple[Set | Alias] | Domain | Expression, expression: Expression | int | bool)[source]#

Bases: Operation

Represents a sum operation over a domain.

Parameters:
domainSet | Alias | Tuple[Set | Alias], Domain, Expression
expressionExpression | int | bool

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> i = gp.Set(m, "i", records=['i1','i2', 'i3'])
>>> v = gp.Variable(m, "v")
>>> e = gp.Equation(m, "e", type="eq")
>>> e[...] = gp.Sum(i, 3) <= v

Methods

gamsRepr()

Representation of the Sum operation in GAMS language.

gamsRepr()[source]#

Representation of the Sum operation in GAMS language.

Returns:
str

Examples

>>> from gamspy import Container, Set, Parameter, Variable, Sum
>>> m = Container()
>>> i = Set(m, "i", records=['i1','i2', 'i3'])
>>> c = Parameter(m, "c", domain=i)
>>> v = Variable(m, "v", domain=i)
>>> Sum(i, c[i]*v[i]).gamsRepr()
'sum(i,(c(i) * v(i)))'