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)

Bases: SlotSerializationMixin, Symbol

A placeholder for a value which can occur within expressions.

property indexed

Check if the Symbol is indexed.

property is_Parameter
property is_Variable
property value

Get the Symbol’s value.

comando.prod(*args)[source]

Return the product of the elements in args.

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

Bases: Symbol

A Symbol representing a parameter whose value is known.

property elements
expand(data)

Expand the Parameter with indexed data.

expansion
property indexed

Check whether the Parameter is indexed or not.

property indices
property is_Parameter
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), init_val=None, indexed=False, parent=None)

Bases: Symbol

A Symbol representing a variable whose value is unknown.

property bounds
property domain
fix(value=None)

Fix the variable by setting both bounds to value.

property init_val
property is_Variable
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()

Recover the original bounds.

property value

Get the Symbol’s value.

class comando.VariableVector(name, domain=Domain.REAL, bounds=(None, None), init_val=None)

Bases: Symbol

A Symbol representing a vector of Variables.

property bounds
property domain
property elements
expansion
fix(value=None)

Fix self.elements by setting both bounds to value.

property indexed

Check if the Symbol is indexed.

property indices
property init_val
instantiate(index)

Create a Variable instance for every element in index.

property is_Variable
property is_binary
property is_expanded
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()

Recover the original bounds.

property value

Get the Symbol’s value.