Working with Code Libraries - Creating rules for the Inference Engine
(Page 4 of 5 )
NxBRE supports several rule formats for its Inference Engine:
- RuleML files, an XML-based representation of rules
- Microsoft Visio 2003 VDX files
- HRF files, a human-readable format that resembles Prolog
RuleML is the format of choice of the Inference Engine. Not all the features are available in the other formats.
RuleML files can be directly authored with any schema-aware XML editor. The example Rule #1 shown previously can be expressed this way:
<Implies>
<And>
<Atom>
<Rel>premium</Rel>
<Var>customer</Var>
</Atom>
<Atom>
<Rel>regular</Rel>
<Var>product</Var>
</Atom>
</And>
<Atom>
<Rel>discount</Rel>
<Var>customer</Var>
<Var>product</Var>
<Ind>5.0 percent</Ind>
</Atom>
</Implies>
RuleML goes much further than simpleif/thenstatements. In fact, NxBRE’s forward-chaining Inference Engine performs pattern-matching operations and can produce combinations of matching data. See http://ruleml.org and NxBRE’s user guide for more information.
Editing rules in Visio offers several advantages, including the possibility of organizing rules in pages (Figure 4-3) or mixing rule elements with other schema elements (Figure 4-4).

Figure 4-3. Designing Inference Engine rules with Visio
HRF can be authored with any text editor. Our example Rule #1 would be written like this in HRF:
( premium{?customer}
& regular{?product} )
-> discount{?customer, ?product, 5.0 percent};
Whatever rule format is chosen, NxBRE provides a testing console as a companion package. As shown in Figure 4-5, this console allows you to easily load, run, and trace the processing of rule bases designed for the Inference Engine.
Next: Implementing the engine >>
More BrainDump Articles
More By O'Reilly Media
|
This article is excerpted from chapter four of Windows Developer Power Tools, written by James Avery and Jim Holmes (O'Reilly, 2006; ISBN: 0596527543). Check it out today at your favorite bookstore. Buy this book now.
|
|