Modular Investors


Tutorial Index     Rules & Decision Tables     Column Queries     Arrays     Tables & Pattern Matching     Lists     VBA     Multiple Rule Sets     Array Queries


loans_08_modules.xls

This example produces the same results as the sample introducing lists, but instead of having all the rules in one rule set, the rules for each of the investors are placed in their own rule sets. The main rule set, ResaleRules, now contains rules that use the appropriate investor rule sets to get results.

The advantage of this approach is it makes it very easy to manage change and complexity in investor rules. New investors can be easily added, and special conditions for different investors are easily supported. Typically the rules for each investor would be on their own worksheets, but in this example they are all on one worksheet to illustrate the architecture.


loans_08_modules.xls

There are a number of tasks in building this modular rule set application.

Common data in ResaleRules is provided with the RArray("loans", C5:G19) function used in earlier examples. It is placed in ResaleRules and can be used by any of the investor rule sets.

Dispatch queries are implemented using a rule in ResaleRules that has an investor name as an index to the property. That investor name, which is also a rule set name, is used in the goal syntax for querying a property in a different rule set ( RuleSet : Fact ):

Resell[ ?investor, ?id] = ?investor : Resell[?id]

So, the RQuery() goal of "Resell['Acme', 303]" will cause the sub goal Acme: Resell[303] to be pursued.

Excel dependencies are established by placing =RXLDependency( RuleSet ) function calls inside the main rule set, ResaleRules. RXLDependency() does nothing more than trigger Excel's dependency mechanism, so that changes in an investor rule set will cause Excel to mark ResaleRules as modified. This will cause RQuery()s which refer to ResaleRules to be re-executed.

Inheritance relationships are established with the statement Inherit from RuleSet. When one rule set inherits from another, it can directly refer to the properties of that rule set. For example, the Ace rule set can refer to loans[103, 'FICO'] as if it were defined in Ace.

If a rule set does not inherit from another, it can still refer to properties in other rule sets by using the RuleSet : Fact syntax. So if Ace did NOT inherit from ResaleRules, it could still refer to ResaleRules: loans[103, 'FICO'].

Warning - Avoid circular definitions using either RXLDependency() or Inherit from RuleSet. Typically, RXLDependency()s go from top to bottom, and Inherit from RuleSet relationships go from bottom to top.

These relationships are summarized in the following diagram.


Modular Rule Set Architecture

 


Copyright ©2005-7 Amzi! inc. All Rights Reserved.
ARulesXL and Amzi! are trademarks or registered trademarks of Amzi!
Microsoft and Excel are trademarks or registered trademarks of Microsoft Corporation.