TimeOfDayCondition#

module wntr.network.controls

class TimeOfDayCondition[source]#

Bases: ControlCondition

Time-of-day or “clocktime” based condition statement. Resets automatically at 12 AM in clock time (shifted time) every day simulated. Evaluated from 12 AM the first day of the simulation, even if this is prior to simulation start. Unlike the SimTimeCondition, greater-than and less-than relationships make sense, and reset at midnight.

Parameters:
  • model (WaterNetworkModel) – The model that the time 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 midnight, before evaluates as True from midnight until the specified time.

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

  • repeat (bool, optional) – True by default; if False, allows for a single, timed trigger, and probably needs an entry for first_day; in this case a relation of after becomes True from the time until the end of the simulation, and before is True from the beginning of the simulation until the time specified.

  • first_day (float, default=0) – Start rule on day first_day, with the first day of simulation as day 0

  • TODO (WE ARE NOT TESTING THIS!!!!)


__init__(model, relation, threshold, repeat=True, first_day=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