Rule-Based Controls allow link status and settings to be based on a combination of conditions that might exist in the network over an extended period simulation. The use of rule-based controls is explained in the following tabs, click on each tab to explore.
Rule-based Controls are statements of the form:
RULE ruleID
IF condition_1
AND condition_2
OR condition_3
AND condition_4
etc.
THEN action_1
AND action_2
etc.
ELSE action_3
AND action_4
etc.
PRIORITY priority
where
| ruleID | = | an ID label assigned to the rule |
| conditon_n | = | a condition clause |
| action_n | = | an action clause |
| priority | = | a priority value (e.g., a number from 1 to 5) |
The following conventions apply to rule statements:
1. Only the RULE, IF and THEN portions of a rule are required; the other portions are optional.
2. Any number and combination of AND and OR clauses can be used in a rule.
3. When mixing AND and OR clauses, the OR operator has higher precedence than AND, i.e.,
IF A or B and C
is equivalent to
IF (A or B) and C.
If the interpretation was meant to be IF A or (B and C)then this can be expressed using two rules as in
Rule 1: IF A THEN ...
Rule 2: IF B and C THEN ...
4. The PRIORITY value is used to determine which rule applies when two or more rules require that conflicting actions be taken on a link. The higher the value the higher the priority. A rule without a priority value always has a lower priority than one with a value. For two rules with the same priority value, the rule that appears first is given the higher priority.
5. There is no limit on the number of rule statements that can be added to a project.
A condition clause in a Rule-Based Control takes the form of:
object id attribute relation value
where
Some example conditional clauses are:
JUNCTION 23 PRESSURE > 20
TANK T200 FILLTIME BELOW 3.5
LINK 44 STATUS IS OPEN
SYSTEM DEMAND >= 1500
SYSTEM CLOCKTIME = 7:30 AM
The Object keyword can be any of the following:
NODE LINK SYSTEM
JUNCTION PIPE
RESERVOIR PUMP
TANK VALVE
When SYSTEM is used in a condition no ID is supplied.
The following attributes can be used with Node-type objects:
DEMAND
HEAD
PRESSURE
The following attributes can be used with Tanks:
LEVEL
FILLTIME (hours needed to fill a tank)
DRAINTIME (hours needed to empty a tank)
These attributes can be used with Link-Type objects:
FLOW
STATUS (OPEN, CLOSED, or ACTIVE)
SETTING (Pump speed or Valve setting)
The SYSTEM object can use the following attributes:
DEMAND (total system demand)
TIME (hours from the start of the simulation)
CLOCKTIME (24-hour clock time with AM or PM appended)
Relation operators consist of the following:
= IS
<> NOT
< BELOW
> ABOVE
<= >=
| object | = | a category of network object |
| id | = | the object's ID label |
| attribute | = | an attribute or property of the object |
| relation | = | a relational operator |
| value | = | an attribute value |
Some example conditional clauses are:
JUNCTION 23 PRESSURE > 20
TANK T200 FILLTIME BELOW 3.5
LINK 44 STATUS IS OPEN
SYSTEM DEMAND >= 1500
SYSTEM CLOCKTIME = 7:30 AM
The Object keyword can be any of the following:
NODE LINK SYSTEM
JUNCTION PIPE
RESERVOIR PUMP
TANK VALVE
When SYSTEM is used in a condition no ID is supplied.
The following attributes can be used with Node-type objects:
DEMAND
HEAD
PRESSURE
The following attributes can be used with Tanks:
LEVEL
FILLTIME (hours needed to fill a tank)
DRAINTIME (hours needed to empty a tank)
These attributes can be used with Link-Type objects:
FLOW
STATUS (OPEN, CLOSED, or ACTIVE)
SETTING (Pump speed or Valve setting)
The SYSTEM object can use the following attributes:
DEMAND (total system demand)
TIME (hours from the start of the simulation)
CLOCKTIME (24-hour clock time with AM or PM appended)
Relation operators consist of the following:
= IS
<> NOT
< BELOW
> ABOVE
<= >=
An action clause in a Rule-Based Control takes the form of:
object id STATUS/SETTING IS value
where
| object | = | LINK, PIPE, PUMP, or VALVE keyword |
| id | = | the object's ID label |
| value | = | a status condition (OPEN or CLOSED), pump speed setting, or valve setting |
Some example action clauses are:
LINK 23 STATUS IS CLOSED
PUMP P100 SETTING IS 1.5
VALVE 123 SETTING IS 90
Here are several examples of Rule-Based Controls.
Example 1:This set of rules shuts down a pump and opens a by-pass pipe when the level in a tank exceeds a certain value and does the opposite when the level is below another value.
RULE 1
IF TANK 1 LEVEL ABOVE 19.1
THEN PUMP 335 STATUS IS CLOSED
AND PIPE 330 STATUS IS OPEN
RULE 2
IF TANK 1 LEVEL BELOW 17.1
THEN PUMP 335 STATUS IS OPEN
AND PIPE 330 STATUS IS CLOSED
Example 2:
These rules change the tank level at which a pump turns on depending on the time of day.
RULE 3
IF SYSTEM CLOCKTIME >= 8 AM
AND SYSTEM CLOCKTIME < 6 PM
AND TANK 1 LEVEL BELOW 12
THEN PUMP 335 STATUS IS OPEN
RULE 4
IF SYSTEM CLOCKTIME >= 6 PM
OR SYSTEM CLOCKTIME < 8 AM
AND TANK 1 LEVEL BELOW 14
THEN PUMP 335 STATUS IS OPEN
Rule-Based Controls are applied after an initial hydraulic state of the network is computed (i.e., after time zero). They are evaluated over the course of a hydraulic simulation as follows:
1. The rules are evaluated at a sub-hydraulic time step equal to 1/10 of the normal hydraulic time step (e.g., if hydraulics are updated every hour, then rules are evaluated every 6 minutes).
2. Over this sub-hydraulic time step, clock time is updated as are the water levels in storage tanks (based on the last set of pipe flows computed).
3. If a rule's conditions are satisfied, then its actions are added to a list. If an action conflicts with one for the same link already on the list then the action from the rule with the higher priority stays on the list and the other is removed. If the priorities are the same then the original action stays on the list.
4. If the list is not empty, then the new actions are taken. If this causes the status of one or more links to change then a new hydraulic solution is computed.
5. The action list is cleared and the next sub-hydraulic time step is checked.