Reference |
Top Installation Introduction Samples Tutorial Reference Release Notes
Rules can be expressed as decision tables. This tablular format is easier to use for rules that fit a regular format. For example this table returns the pricing rate of a phone call:
Table rate
weekend daytime rate "yes" * 0.05 "no" "no" 0.09 "no" "yes" 0.12
The table is equivalent to these rules:
rate = 0.05 WHEN weekend = "yes" rate = 0.09 WHEN weekend = "no" AND daytime = "no" rate = 0.12 WHEN weekend = "no" AND daytime = "yes"
Note, the * as a value in a table means that property can have any value, hence that fact is omitted from the rule.
Decision tables are included in rule sets. They:
ARulesXL will draw a border around the table. This lets your verify that it has been defined properly.
Here are some examples of valid expressions in an input column. See the Decision Table.xls sample for more examples.
value > 800 AND < 1800 <= 800 OR >= 1800 MEMBER( myarray )
Any condition that can be used on the right side of a WHEN clause in a rule can be used in a decision table input column, however, the name of the column fact is implied. The above conditions would be written in rules as:
WHEN value > 800 AND value < 1800
WHEN value <= 800 OR value >= 1800
WHEN value = MEMBER( myarray)
A very powerful feature of ARulesXL is that you can mix rules and decision tables. This lets you specify the orderly values in a decision table and handle the special cases in rules. For example:
Table weekend
day weekend Saturday "yes" Sunday "yes" MEMBER( weekdays ) "no"
The above table returns weekend = "yes" for every day but Saturday and Sunday. However, suppose you want Friday evenings after 6pm to be the weekend rate. You could add another column with the time, or you could add these rules to handle the special case:
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday"] weekend = "yes" WHEN day = "Friday" and time >= 1800 weekend = "no" WHEN day = "Friday" and time < 1800
When you issue this query:
=RQuery(RateTable, "FIND rate WHEN day = "Friday" and time = 1902")
First, the reasoning engine will look in the weekend table. When it is unable to match Friday with any row in day, then it looks at the rules. There it finds the two rules for Friday based on time.
You can have any number of decision tables and rules in a single rule set.
If you want to create your decision tables by copying and pasting data from other sources, you need to do this in one of two ways:
Copyright ©2005-7 Amzi! inc. All Rights Reserved.
|