ams.opt.exprcalc.ExpressionCalc#

class ams.opt.exprcalc.ExpressionCalc(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)[source]#

Class for calculating expressions.

This class is useful for performing post-solve calculations, but it does not participate in the optimization model itself.

Note: ExpressionCalc is not a CVXPY expression and should NOT be referenced in e_str by any other components, including other instances of ExpressionCalc.

Accepts e_fn (callable taking RoutineNS) alongside the legacy e_str form. The codegen emits _exprcalc_<name> callables; the descriptor mutex from OptzBase keeps the two forms exclusive.

__init__(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)[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.