Control#

module wntr.network.controls

class Control[source]#

Bases: Rule

A class for controls.


__init__(condition, then_action, 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_action (BaseControlAction) – The action that should be activated when the condition evaluates to True.

  • priority (ControlPriority) – The priority of the control. Default is ControlPriority.medium

  • name (str) – The name of the control

actions()#

Returns a list of all actions used by this control.

Returns:

act

Return type:

list of BaseControlAction

is_control_action_required()#

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:

tuple

requires()#

Returns a set of objects required for this control.

Returns:

required_objects

Return type:

OrderedSet of object

run_control_action()#

This method is called to run the control action after a call to IsControlActionRequired indicates that an action is required.

to_dict()#
update_condition(condition)#

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)#

Update the controls else_actions in place

Parameters:

else_actions (Iterable[ControlAction]) – The new else_actions for this control to use

update_priority(priority)#

Update the controls priority in place

Parameters:

priority (ControlPriority) – The new priority for this control to use

update_then_actions(then_actions)#

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#