comando package

Subpackages

Submodules

Module contents

Configuration of the backends for COMANDO.

class comando.Domain(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Simple Enum for variable domains, specify other types via bounds.

BINARY = 3
INTEGER = 2
REAL = 1
class comando.Symbol(name, **assumptions)[source]

Bases: SlotSerializationMixin, Symbol

A placeholder for a value which can occur within expressions.

property is_indexed

Check if the Symbol is indexed.

property value

Get the Symbol’s value.

comando.evaluate(expr, idx=None)[source]

Evaluate the given expression at the symbols’ current values.

Note

To allow for indexed espressions to be evaluated, evaluate uses numpy and thus double arithmetic instead of the arbitrary precision arithmetic usually used by sympy or symengine backends. This can result in different results in comparison to those obtained by other tools such as solvers or AMLs interfaced to COMANDO.

Arguments:
  • expr (comando.Expr) – The expression to be evaluated

  • idx (double, str, list, tuple) – The index at which to evaluate

  • returns

  • result (float or pandas.Series) – The numerical result of the evaluation

comando.prod(*args)[source]

Return the product of the elements in args.

class comando.Parameter(name, value=nan, parent=None)[source]

Bases: Symbol

A Symbol representing a parameter whose value is known.

property elements
expand(data)[source]

Expand the Parameter with indexed data.

expansion
property indices
property is_indexed

Check whether the Parameter is indexed or not.

property items
property parent

Return the parent of this parameter.

property value

Return the value or values of the Parameter.

class comando.Variable(name, domain=Domain.REAL, bounds=(None, None), discretization: DiscretizationParameters = None, init_val=None, indexed=False, parent=None)[source]

Bases: Symbol

A Symbol representing a variable whose value is unknown.

property bounds
property discretization
property domain
fix(value=None)[source]

Fix the variable by setting both bounds to value.

property init_val
property is_binary
property is_integer
property is_negative

Check if all possible values of the variable are negative.

We can assert negativity if the upper bound is negative, otherwise we can assert nonnegativity if the lower bound is nonnegative. If we cannot assert either of these facts, the variable may contain both positive and negative values. To reflect this we return None.

property is_nonnegative

Check if all possible values of the variable are negative.

This is the fuzzy not of self.is_negative

property is_nonpositive

Check if all possible values of the variable are negative.

This is the fuzzy not of self.is_negative

property is_positive

Check if all possible values of the variable are positive.

We can assert positivity if the lower bound is positive, otherwise we can assert nonpositivity if the upper bound is nonpositive. If we cannot assert either of these facts, the variable may contain both positive and negative values. To reflect this we return None.

property lb
property parent

Return the parent of this variable.

property ub
unfix()[source]

Recover the original bounds.

property value

Get the Symbol’s value.

class comando.VariableVector(name, domain=Domain.REAL, bounds=(None, None), discretization: DiscretizationParameters = None, init_val=None)[source]

Bases: Symbol

A Symbol representing a vector of Variables.

property bounds
property discretization
property domain
property elements
expansion
fix(value=None)[source]

Fix self.elements by setting both bounds to value.

property indices
property init_val
instantiate(index)[source]

Create Variable instances for every element in index.

property is_binary
property is_expanded
property is_indexed

Check if the Symbol is indexed.

property is_integer
property is_negative

Check if all possible values of the variable are negative.

We can assert negativity if the upper bound is negative, otherwise we can assert nonnegativity if the lower bound is nonnegative. If we cannot assert either of these facts, the variable may contain both positive and negative values. To reflect this we return None.

property is_nonnegative

Check if all possible values of the variable are negative.

This is the fuzzy not of self.is_negative

property is_nonpositive

Check if all possible values of the variable are negative.

This is the fuzzy not of self.is_negative

property is_positive

Check if all possible values of the variable are positive.

We can assert positivity if the lower bound is positive, otherwise we can assert nonpositivity if the upper bound is nonpositive. If we cannot assert either of these facts, the variable may contain both positive and negative values. To reflect this we return None.

property items
property lb
property ub
unfix()[source]

Recover the original bounds.

property value

Get the Symbol’s value.