Sum#
- class gamspy.Sum(domain: Set | Alias | tuple[Set | Alias] | Domain | Expression, expression: Expression | int | bool)[source]#
Bases:
OperationRepresents a sum operation over a domain.
- Parameters:
- domainSet | Alias | tuple[Set | Alias], Domain, Expression
- expression(
Expression | ImplicitVariable | ImplicitParameter | int | bool | Variable | Parameter | Operation
)
Methods
gamsRepr()Representation of the Sum operation in GAMS language.
latexRepr()Representation of this operation in Latex.
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") >>> d = gp.Parameter(m, "d", domain=[i], records=[("i1", 1), ("i2", 2), ("i3", 4)]) >>> e[...] = gp.Sum(i, d[i]) <= v
- 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)))'