ams.opt.expression.Expression#

class ams.opt.expression.Expression(name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None, e_str: str | None = None, e_fn: Callable | None = None, model: str | None = None, src: str | None = None, vtype: str | None = <class 'float'>, horizon: str | None = None)[source]#

Base class for expressions used in a routine.

Routines are authored with e_str strings; the codegen at ams.prep.generate_for_routine() compiles each e_str into a callable e_fn(r) taking a RoutineNS proxy and returning a CVXPY expression. The mutex descriptor on e_str / e_fn keeps the two forms exclusive.

Parameters:
namestr, optional

Expression name. One should typically assigning the name directly because it will be automatically assigned by the model. The value of name will be the symbol name to be used in expressions.

tex_namestr, optional

LaTeX-formatted variable symbol. Defaults to the value of name.

infostr, optional

Descriptive information

unitstr, optional

Unit

e_strstr, optional

Expression string (legacy form).

e_fncallable, optional

Callable e_fn(r) -> cp.Expression taking a RoutineNS.

modelstr, optional

Name of the owner model or group.

srcstr, optional

Source expression name

vtypetype, optional

Value type

horizonams.routines.RParam, optional

Horizon

__init__(name: str | None = None, tex_name: str | None = None, info: str | None = None, unit: str | None = None, e_str: str | None = None, e_fn: Callable | None = None, model: str | None = None, src: str | None = None, vtype: str | None = <class 'float'>, horizon: str | None = None)[source]#

Methods

evaluate(*args, **kwargs)

get_all_idxes()

Return all the indexes of this item.

get_idx()

parse(*args, **kwargs)

Attributes

class_name

Return the class name

e

Return the calculated numerical value of the underlying expression.

e_fn

Mutex descriptor for e_str / e_fn on opt elements.

e_str

Mutex descriptor for e_str / e_fn on opt elements.

formulation_source

Where the live CVXPY object for this item came from.

n

Return the number of elements.

shape

Return the shape.

size

Return the size.

v

Return the CVXPY expression value.