Rules examples

Rulesets in the examples/rules directory show how to use User-defined Functions as sensors and effectors, the function libraries, and the various inferencing methods.

Ruleset
Name
Inferencing
Method
Libraries used Comment
AbleArrayDemo Script    
AbleBeanLibDemo Forward AbleBeanLib Creates, connects, and configures AbleBeans illustrating dataflow and event handling
AbleBitOpsDemo Script    
AbleCalendarLibDemo Script AbleCalendarLib  
AbleDataTypeDemo Script    
AbleMathDemo Script    
AbleStringLibDemo Script AbleStringLib Shows use of tokenizer helpers.
AbleTimePeriodDemo Script    
Animal Script   Shows a ruleset receiving data from a file import; serialized example.
BondRating FuzzyAdd    
BooleanRuleExamples Forward    
Bugs FuzzyAdd    
EightQueens Predicate    
Factorial Predicate AblePredicateLib  
FamilyRelationships1 Predicate    
FuzzyRuleExamples FuzzyAdd    
GroceryBagger PatternMatch/Rete   Shows construction of an object for each record in a file import and asserting to working memory; imports Java classes Grocery and GroceryBag.
HedgeDemo FuzzyAdd   Displays fuzzy set hedge results; use with Swing-based ruleset editor.
HighLevelPolicy Script   The controller ruleset shows how an import bean can be connected to a ruleset to provide data.
Medical MinMax    
MidLevel1 Forward    
MonkeysAndBananas PatternMatch/Rete    
MortgageB Forward    
MortgageF FuzzyAdd    
MurderMystery Predicate    
PolicyExample FuzzyAdd   PolicyTest1.ser is a serialized agent that shows the interactions of multiple rule sets.
PredicateNotDemo Predicate    
RuleBlocksDemo FuzzyAdd    
SampleSensorEffector FuzzyAdd    
SimulationTimerGenerator Script    
SortPredicateLists Predicate    
TowersOfHanoi PatternMatch/Rete   Imports Java classes Puzzle and Ring
Trout FuzzyAdd    
VehicleBackward Backward AbleGUILib  
VehicleForward Forward    
  MutEx    

Other rulesets may also be included; generally their names indicate their intended use.

Sample Java Programs

AnimalRuleSetApp.java is a Java program that creates a ruleset object, defines a String input buffer array, populates that buffer and passes it to the ruleset, and retrieves the result.

Another example, SampleSensorEffector.java, is a simple Java program that uses a ruleset by the same name and demonstrates:

This program can be run in two ways:

  1. The program is available from within the Able Agent Editor -- it appears on the Samples tab. Click on the SampleSensorEffector icon to create a bean on the editor's canvas, and then select Process from the bean's popup menu. Not much happens visually, but if you watch the command window from which you started the Able Agent Editor you will see a lot of messages fly by. Review the program's source code in conjunction with the ruleset file to determine what happens during processing.
  2. The program can be changed, recompiled, and, as it has a main() method, run from your operating system's command line. When doing this, make sure your classpath is set properly -- the classpath must contain all of the jar files referenced in ABLE's runnit command found in the bin directory.

If you want to experiment with the program in this way, it is recommended that you copy the Java source file and the ruleset file to your own working directory. In the Java program, change (1) the package name and (2) the path which points to your copied ruleset file, and then compile and run the program. You can use use ABLE's runnit command as an example to make your own runnit for your new Java program.

Note that this new program will not show up on the Able Agent Editor's tabs. You can make it do so, however, but this is documented elsewhere. Without going into explicit details here, suffice it to say that (1) you will need a manifest file that states the program is a JavaBean, (2) you must package your new Java program in a jar file, and (3) you must add the jar file's name to an entry in the able.preferences file. Furthermore, your new program, like any JavaBean, will need BeanInfo and Customizer files; these are also provided as examples. You can make your customizer as simple or as complex as you wish -- the ruleset editor itself is actually just a JavaBean Customizer used by the Able Agent Editor, but a rather complex one!