RelativeCondition#

module wntr.network.controls

class RelativeCondition[source]#

Bases: ControlCondition

Compare attributes of two different objects (e.g., levels from tanks 1 and 2) This type of condition does not work with the EpanetSimulator, only the WNTRSimulator.

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

  • relation (function) – A numpy or other comparison method that takes two values and returns a bool (e.g., numpy.greater, numpy.less_equal)

  • threshold_obj (object) – The object (such as a Junction, Tank, Pipe, etc.) to use in the comparison of attributes

  • threshold_attr (str) – The attribute to used in the comparison evaluation


__init__(source_obj, source_attr, relation, threshold_obj, threshold_attr)[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