Rule#
module wntr.network.controls
- class Rule[source]#
Bases:
ControlBase
A very general and flexible class for defining both controls rules.
- __init__(condition, then_actions, else_actions=None, priority=ControlPriority.medium, name=None)[source]#
- Parameters:
condition (ControlCondition) – The condition that should be used to determine when the actions need to be activated. When the condition evaluates to True, the then_actions are activated. When the condition evaluates to False, the else_actions are activated.
then_actions (Iterable of ControlAction) – The actions that should be activated when the condition evaluates to True.
else_actions (Iterable of ControlAction) – The actions that should be activated when the condition evaluates to False.
priority (ControlPriority) – The priority of the control. Default is ControlPriority.medium
name (str) – The name of the control
- is_control_action_required()[source]#
This method is called to see if any action is required by this control object. This method returns a tuple that indicates if action is required (a bool) and a recommended time for the simulation to backup (in seconds as a positive int).
- Returns:
req – A tuple (bool, int) indicating if an action should be run and how far to back up the simulation.
- Return type:
- requires()[source]#
Returns a set of objects required for this control.
- Returns:
required_objects
- Return type:
OrderedSet of object
- run_control_action()[source]#
This method is called to run the control action after a call to IsControlActionRequired indicates that an action is required.
- update_condition(condition)[source]#
Update the controls condition in place
- Parameters:
condition (ControlCondition) – The new condition for this control to use
- Raises:
ValueError – If the provided condition isn’t a valid ControlCondition
- update_else_actions(else_actions)[source]#
Update the controls else_actions in place
- Parameters:
else_actions (Iterable[ControlAction]) – The new else_actions for this control to use
- update_priority(priority)[source]#
Update the controls priority in place
- Parameters:
priority (ControlPriority) – The new priority for this control to use
- update_then_actions(then_actions)[source]#
Update the controls then_actions in place
- Parameters:
then_actions (Iterable[ControlAction]) – The new then_actions for this control to use
- property condition#
- property epanet_control_type#
The control type. Note that presolve and postsolve controls are both simple controls in Epanet.
- Returns:
control_type
- Return type:
_ControlType
- property name#
A string representation of the Control.
- property priority#