ValueCondition#

module wntr.network.controls

class ValueCondition[source]#

Bases: ControlCondition

Compare a network element attribute to a set value.

Parameters:
  • source_obj (object) – The object (such as a Junction, Tank, Pipe, etc.) to use in the comparison

  • source_attr (str) – The attribute of the object (such as level, pressure, setting, etc.) to compare against the threshold

  • operation (function or str) – A two-parameter comparison function (e.g., numpy.greater, numpy.less_equal), or a string describing the comparison (e.g., ‘=’, ‘below’, ‘is’, ‘>=’, etc.) Words, such as ‘below’, are only accepted from the EPANET rules conditions list (see …)

  • threshold (float) – A value to compare the source object attribute against


__init__(source_obj, source_attr, relation, threshold)[source]#
static __new__(cls, source_obj, source_attr, relation, threshold)[source]#
evaluate()[source]#

Check if the condition is satisfied.

Returns:

check

Return type:

bool

requires()[source]#

Returns a set of objects required to evaluate this condition

Returns:

required_objects

Return type:

OrderedSet of object

property backtrack#

The amount of time by which the simulation should be backed up. Should be updated by the evaluate method if appropriate.

Returns:

backtrack

Return type:

int

property name#

Returns the string representation of the condition.

Returns:

name

Return type:

str