Expression#

class gamspy._algebra.expression.Expression(left: OperandType, data: str | MathOp | ExtrinsicFunction, right: OperandType)[source]#

Bases: Operable

Expression of two operands and an operation.

Parameters:
left: str | int | float | Parameter | Variable | None

Left operand

data: str

Operation

right: str | int | float | Parameter | Variable | None

Right operand

Methods

gamsRepr()

Representation of this Expression in GAMS language.

getDeclaration()

Declaration of the Expression in GAMS

latexRepr()

Representation of this Expression in Latex.

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> a = gp.Parameter(m, name="a")
>>> b = gp.Parameter(m, name="b")
>>> expression = a * b
>>> expression.gamsRepr()
'(a * b)'
latexRepr() str[source]#

Representation of this Expression in Latex.

Returns:
str
gamsRepr() str[source]#

Representation of this Expression in GAMS language.

Returns:
str

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> a = gp.Parameter(m, name="a")
>>> b = gp.Parameter(m, name="b")
>>> expression = a * b
>>> expression.gamsRepr()
'(a * b)'
getDeclaration() str[source]#

Declaration of the Expression in GAMS

Returns:
str

Examples

>>> import gamspy as gp
>>> m = gp.Container()
>>> a = gp.Parameter(m, name="a")
>>> b = gp.Parameter(m, name="b")
>>> expression = a * b
>>> expression.getDeclaration()
'(a * b)'