Anatomy of a Rules-Based System


Anatomy of a Rules-Based System

A rules-based system is made up of a number of distinct elements. A set of rules exists that operate over a collection of facts stored in a working memory. Logic is provided to identify which rule to fire (based upon the antecedents ) and then modify working memory (based upon the consequents). Figure 8.1 provides a graphical depiction of a simple rules-based system.

click to expand
Figure 8.1: Rules-based system illustration.

Rules operate over the body of facts stored within the working memory. Once a rule is matched, it is permitted to fire, which may (or may not) alter the working memory. This process continues until a goal state is reached.

Working Memory

The working memory is the structure where the currently known facts are stored. This is a persistent space that can be altered only through the consequent of a rule (and from which a rule may only be fired if its antecedents are true). Consider the following example of working memory:

 (sensor-failed sensor1) (mode normal) 

In this example, two facts are known. These are encoded in pairs of type and value. For example, the first fact is defined as a type sensor-failed and its value is sensor1 . The knowledge being demonstrated by this fact is that sensor1 is a failed sensor. The second fact defines that the particular mode is normal . All facts are coded in this representation (though in commercial rules-based systems, a richer representation is often provided).

Rules Memory

The rules memory contains a set of rules that operate over the working memory. Rules are constructed in two parts and include an "antecedent" and a "consequent." The antecedent defines the facts that must be true for the rule to be triggered. The consequent defines those actions that will be taken if the rule is triggered. Consider the following example:

 (defrule sensor-check        (sensor-failed sensor1) =>       (add (disable sensor1)) ) 

The defrule token specifies that we're defining a rule for the system, and is followed by a text name for the rule. This is followed by one or more antecedents (in this case (sensor-failed sensor1) ). The ' => ' symbol separates the antecedents from the consequents. One or more consequents are then provided. These actions are performed only if the rule is triggered. Finally, the rule is closed by the trailing parenthesis. The actions are defined as two elements. The first is the command that is to be issued and the second is a parameter on which the command operates. In this example, if the rule were triggered, the fact (disable sensor1) would be added to the working memory.

Logic

The system of reasoning behind the rules-based system is the logic that identifies the rules to trigger and permits them to fire. This process is commonly defined as a match-resolve-act cycle, and is discussed in the section "Phases of a Rules-Based System."




Visual Basic Developer
Visual Basic Developers Guide to ASP and IIS: Build Powerful Server-Side Web Applications with Visual Basic. (Visual Basic Developers Guides)
ISBN: 0782125573
EAN: 2147483647
Year: 1999
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net