wntr.sim.aml module

class wntr.sim.aml.aml.Model[source]

Bases: object

A class for creating algebraic models.

set_structure()[source]

This method essentially just orders all of the variables and constraints so that the constraint residuals and the jacobian can be evaluated efficiently. This method must be called before get_x, load_var_values_from_x, evaluate_residuals, or evaluate_jacobian can be called. If any changes are made to the model (e.g., variables/constraints are added/removed), then this method needs called again. Avoid calling this method too often if you are concerned about efficiency.

class wntr.sim.aml.aml.ConstraintDict(mapping=None)[source]

Bases: wntr.sim.aml.aml._NodeDict

Dictionary of constraints; primarily handles registering the constraints with the model and naming

class wntr.sim.aml.expr.OperationEnum(value)[source]

Bases: enum.IntEnum

An enumeration.

class wntr.sim.aml.expr.ExpressionBase[source]

Bases: wntr.sim.aml.expr.Node

A base class for expressions (including variables and params).

abstract evaluate()[source]

Evaluate the expression numerically.

Returns

val (float) – The floating point value of the expression.

class wntr.sim.aml.expr.Leaf[source]

Bases: wntr.sim.aml.expr.ExpressionBase

evaluate()[source]

Evaluate the expression numerically.

Returns

val (float) – The floating point value of the expression.

class wntr.sim.aml.expr.Float(val)[source]

Bases: wntr.sim.aml.expr.Leaf

class wntr.sim.aml.expr.Var(val=0)[source]

Bases: wntr.sim.aml.expr.Leaf

Variables

Parameters

val (float) – value of the variable

class wntr.sim.aml.expr.Param(val=0)[source]

Bases: wntr.sim.aml.expr.Leaf

class wntr.sim.aml.expr.expression(expr=None)[source]

Bases: wntr.sim.aml.expr.ExpressionBase

Parameters

expr (expression) –

last_node()[source]
Returns

last_node (Operator)

evaluate()[source]

Evaluate the expression numerically.

Returns

val (float) – The floating point value of the expression.

wntr.sim.aml.expr.exp(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.log(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.sin(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.cos(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.tan(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.asin(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.acos(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.atan(val)[source]
Parameters

val (ExpressionBase) –

Returns

expr (expression)

wntr.sim.aml.expr.if_else(if_statement, then_statement, else_statement)[source]
Parameters
Returns

expr (ExpressionBase)

wntr.sim.aml.expr.inequality(body, lb=None, ub=None)[source]
Parameters
Returns

expr (ExpressionBase)

wntr.sim.aml.expr.is_variable_type(obj)[source]

Returns True if the object is a variable.

Parameters

obj (ExpressionBase) – Also accepts floats and ints

Returns

bool