SimTimeCondition#

module wntr.network.controls

class SimTimeCondition[source]#

Bases: ControlCondition

Condition based on time since start of the simulation. Generally, the relation should be None (converted to “at”) – then it is only evaluated “at” specific times. Using greater-than or less-than type relationships should be reserved for complex, multi-condition statements and should not be used for simple controls. If repeat is used, the relationship will automatically be changed to an “at time” evaluation, and a warning will be raised.

Parameters:
  • model (WaterNetworkModel) – The model that the time threshold is being compared against

  • relation (str or None) – String options are ‘at’, ‘after’ or ‘before’. The ‘at’ and None are equivalent, and only evaluate as True during the simulation step the time occurs. After evaluates as True from the time specified until the end of simulation, before evaluates as True from start of simulation until the specified time.

  • threshold (float or str) – The time (a float in decimal hours) used in the condition; if provided as a string in ‘[dd-]hh:mm[:ss]’ format, then the time will be parsed from the string;

  • repeat (bool or float, default=False) – If True, then repeat every 24-hours; if non-zero float, reset the condition every repeat seconds after the first_time.

  • first_time (float, default=0) – Start rule at first_time, using that time as 0 for the condition evaluation


__init__(model, relation, threshold, repeat=False, first_time=0)[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