Rule-Based Controls

<< Click to Display Table of Contents >>

Navigation:  Wadiso 6 User Guide > Time/Water quality simulation > Editing of Time/WQ Simulation Data > Link Controls >

Rule-Based Controls

The Rule-Based Editor is a text editor, which can be used to specify complex rules that modify links, based on a combination of conditions. The editor is accessed by selecting Simulation Data > Simulation Tables > Links Controlled by Rules.

 

The text editor is used to enter the rule statements, as follows:

 

Format:

 

Each rule is a series of 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 value

 

where:

 

ruleID = an ID label assigned to the rule

condition_n = a condition clause

action_n = an action clause

Priority = a priority value (e.g., a number from 1 to 5)

 

Condition Clause Format:

 

A condition clause in a Rule-Based Control takes the form of:

 

object No.ID attribute relation value

 

where:

 

object = a category of network object

No.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:

 

NODE 23 PRESSURE > 20

 

TANK 200 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

PIPE

RESERVOIR

TANK

PUMP

VALVE

 

When SYSTEM is used in a condition, no 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, expressed either as a decimal number or in hours:minutes format)

· CLOCKTIME (24-hour clock time with AM or PM appended)

 

Relation operators consist of the following:

 

· = IS

· <> NOT

· < BELOW

· > ABOVE

· <=

. >=

 

Action Clause Format:

 

An action clause in a Rule-Based Control takes the form of:

 

object No.ID STATUS/SETTING IS value

 

where:

 

object = LINK, PIPE, PUMP or VALVE keyword

No.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 100 SETTING IS 1.5

 

VALVE 123 SETTING IS 90

 

Remarks:

 

a. Only the RULE, IF and THEN portions of a rule are required; the other portions are optional.

 

b. 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

 

IF A THEN ...

 

IF B and C THEN ...

 

c. The PRIORITY value is used to determine which rule applies when two or more rules require that conflicting actions be taken on a link. 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.

 

Examples:

 

RULE 1

IF TANK 1 LEVEL ABOVE 19.1

THEN PUMP 335 STATUS IS CLOSED

AND PIPE 330 STATUS IS OPEN

RULE 2

IF SYSTEM CLOCKTIME = 8 AM

AND SYSTEM CLOCKTIME < 6 PM

AND TANK 1 LEVEL BELOW 12

THEN PUMP 335 STATUS IS OPEN

RULE 3

IF SYSTEM CLOCKTIME = 6 PM

OR SYSTEM CLOCKTIME < 8 AM

AND TANK 1 LEVEL BELOW 14

THEN PUMP 335 STATUS IS OPEN

 

(The rule-based controls are considered Time/WQ simulation-specific data, and are saved with the Time/WQ simulation *.WOP file).

 

The Rule Based Editor can also be used to specify Time-Based-, Clocktime-Based-, and Simple Control rules, in lieu of, or in addition to, using the three custom designed editors, which are available for this purpose.

 

The text editor is used to enter rule statements for these simpler controls, which modify links, based on a single condition, as follows:

 

Format:

 

One line for each control, which can be of the form:

 

LINK -- Link No -- Setting -- IF NODE -- Node No -- ABOVE/BELOW -- Value

LINK -- Link No -- Setting -- AT TIME -- Time

LINK -- Link No -- Setting -- AT CLOCKTIME -- Clocktime -- AM/PM

 

where:

 

Link No = a link ID number

Setting = OPEN or CLOSED, ON or OFF, a pump speed setting, or a control valve setting

Node No = a node ID number

Value = a pressure head for a node, or a water level for a tank

Time = a time since the start of the simulation in decimal hours or in hours:minutes format

Clocktime = a 24-hour clock time (hours:minutes) with AM/PM appended

 

Remarks:

 

a. Simple controls are used to change link status or settings, based on tank water level, node pressure head, time into the simulation, or time of day.

 

Examples:

 

To close Link 12 if the level in Tank 23 exceeds 20 ft, the statement is:

 

LINK 12 CLOSED IF NODE 23 ABOVE 20

 

To open Link 12 if the pressure head at Node 130 is under 30 m, the statement is:

 

LINK 12 OPEN IF NODE 130 BELOW 30

 

If PUMP 2's speed is to be set to 1.5 at 16 hours into the simulation, the statement is:

 

LINK 2 1.5 AT TIME 16 HOURS

 

If Link 12 is to be closed at 10 am and opened at 8 pm throughout the simulation, the statement is:

 

LINK 12 CLOSED AT CLOCKTIME 10 AM

 

LINK 12 OPEN AT CLOCKTIME 8 PM