ARL Master Index


Processing Options Statements


    RuleSet <nameOfRuleSet> (

      <Processing Options Statement>*      // Zero or more statements

      .
      .
      .
    )
      

Ruleset processing options statements:

Some of the statements give you control over the inference engine while it is evaluating rules, while other statements let you define your own data types or let you import functions that can be called from your rules.

Processing options statements...


InferenceMethod

For rulesets containing fuzzy variables and rules, specifies the manner in which a solution variable's fuzzy representation is updated.

For rulesets with no fuzzy variables and rules, specifies the type of inferencing to be performed.

If left unspecified, the default InferenceMethod is Script.

The specified InferenceMethod applies only to the Main rule block. All other rule blocks are processed with the Script engine.

Syntax

   InferenceMethod ( FuzzyAdd | MinMax  | ProductOr )1
   InferenceMethod ( Script | Forward | Forward2 | Forward3 | Mixed | Predicate | Backward )2
      

Parameters

       FuzzyAdd
Specifies that the fuzzy solution set is updated by adding the minimum truth value of the consequent fuzzy region, bounded by 1.0. This method is generally used with CorrelationMethod(Product).
       MinMax
Specifies that the fuzzy solution set is updated by using the maximum of the minumum truth value of the consequent fuzzy set. This method is generally used with CorrelationMethod(Minimise).
       ProductOr
Specifies that the fuzzy solution set is updated by using 1 minus the product of (1 minus the truth value of the consequent fuzzy set) and (1 minus the predicate truth). This method is generally used with CorrelationMethod(Product).
       Backward
Specifies that the boolean solution is obtained by doing backward chaining.
       Forward
Specifies that the boolean solution is obtained by doing simple forward chaining. This is the lightest weight of the forward chaining algorithms and is adequate for small to medium sized rulesets.
       Forward2
Specifies that the boolean solution is obtained by doing forward chaining that makes use of working memory.
       Forward3
Specifies that the boolean solution is obtained by doing forward chaining that makes use of working memory and Rete networks. This is the heaviest duty of the forward chaining algorithms and should be used for very large rulesets.
       Mixed
Specifies that the boolean solution is obtained by doing both forward and backward chaining.
       Predicate
Specifies that the boolean solution is obtained by doing predicate logic inferencing.
       Script
Specifies that the rules are processed sequentially with no special inferencing.

This chart shows the degree of support that each inferencing engine provides for specific Able Rule Language features. Any feature marked NS is Not Supported, meaning the inferencing engine tolerates the presence of the feature in a ruleset but will not process it. These features will produce warnings. The presence of any feature marked NO will prevent a ruleset from executing so an error will be issued when the ruleset parses.

ARL Feature All ruleblocks Main ruleblock1
Inferencing method Script Fuzzy2 Forward Forward2 Forward3 Backward3 Predicate3
Assertion rule yes yes yes yes yes yes yes
If/Then If/Then/Else If/Then{} rules4 yes yes Else clause not supported NS NS Else clause / multiple consequents not supported Else clause / multiple consequents not supported
While/Do or Until/Do loop rule yes yes NS NS NS NS NS
When/Do pattern match rule yes no NS yes yes NS NS
Predicate rule no no no no no no yes
Fuzzy variable no yes no no no no no
Processing
order5
assertions, then sequential assertions, then sequential assertions, then sequential assertions, priority, sequential assertions, priority, sequential assertions, then sequential assertions, priority, sequential

1 Some inferencing methods are used only in the main ruleblock. The Script inferencing method is used to process other ruleblocks for these inferencing engines.

2 ProductOr, MinMax and FuzzyAdd inferencing methods.

3 At runtime, Backward chaining and Predicate inferencing require a GoalVariable or GoalPredicate respectively. A warning is issued when the ruleset is parsed if no variable is provided. The variable may be set via API before the ruleset is processed.

4 If/Then conditional rules have three variants:

Simple if x == 0
then y = 1
Else if x == 0
then y = 1
else y = 2
Multiple consequents if x==0
then y=0
z=1
else y=1
z=1

5 Rule processing order is generally assertions first, then rule priority (if supported), and finally in the sequence provided by the ruleset. See the JavaDoc for the appropriate inferencing engine for more details.

Examples

    RuleSet <nameOfRuleSet> (

       InferenceMethod ( FuzzyAdd )  // For a ruleset with
                                     //   fuzzy (and other) variables.

       InferenceMethod ( Forward  )  // For a ruleset with
                                     //  NO fuzzy variables.

      .
      .
      .
    )
      

1 Rulesets with fuzzy variables and rules.
2 Rulesets with no fuzzy variables or rules.

Return to top


AlphaCut

For rulesets with fuzzy clauses, specifies the threshold at which truth values become insignificant. If the truth value of any antecedent clause falls below the alphacut when the clause is evaluated, the inference engine stops evaluating the rule in which the clause appears.

If left unspecified, the default AlphaCut value is 0.1.

Syntax

   AlphaCut ( <numericValue> )
      

Parameters

       <numericValue>
Is a number from 0.0 to 0.99. If set at 0.0, any clause that evaluates to anything greater than zero is essentially considered true to some degree. If set at 0.99, all clauses must evaluate to 1.0 (boolean true) to be considered true at all. Values between 0.05 and 0.2 may be considered typical, but of course it all depends on your fuzzy variables and their fuzzy set definitions.

Example

    RuleSet <nameOfRuleSet> (

       AlphaCut ( 0.20 )

      .
      .
      .
    )
      

Return to top


CorrelationMethod

For rulesets with fuzzy clauses, specifies the manner in which a rule's consequent fuzzy region is correlated with the rule's antecedent fuzzy truth value.

If left unspecified, the default CorrelationMethod is Product.

Syntax

   CorrelationMethod ( Product | Minimum )
      

Parameters

       Product
Specifies that the membership value of the consequent fuzzy region is the product of the fuzzy region and the truth of the premise. The effect is that the consequent fuzzy region is scaled, preserving its shape. This method is generally used with InferenceMethod(ProductOr) or InferenceMethod(FuzzyAdd).
       Minimum
Specifies that the membership value of the consequent fuzzy region is the minimum of the fuzzy region and the truth of the premise. The effect is that the consequent fuzzy region is truncated at the truth of the premise, creating a plateau. This method is generally used with InferenceMethod(MinMax).

Example

    RuleSet <nameOfRuleSet> (

       CorrelationMethod ( Minimum )

      .
      .
      .
    )
      

Return to top


DefuzzifyMethod

For rulesets with fuzzy clauses, specifies the manner in which a fuzzy set is turned into a crisp numeric value.

If left unspecified, the default DefuzzifyMethod is Centroid.

Syntax

   DefuzzifyMethod ( Centroid | MaxHeight )
      

Parameters

       Centroid
Specifies that a fuzzy set's crisp value is calculated as the weighted mean (center of gravity) of the fuzzy region. Also known as composite moments.
       MaxHeight
Specifies that a fuzzy set's crisp value is calculated from the point that has the highest truth value. Also known as composite maximum.

Example

    RuleSet <nameOfRuleSet> (

       DefuzzifyMethod ( Centroid )

      .
      .
      .
    )
      
Return to top

Predicates

When InferenceMethod is predicate, specifies the names of predicates used in rules. All predicates referenced in rules must be pre-declared in this section. Multiple statements may be used; they are cumulative.

This statement should not be used with other inference methods.

Syntax

   Predicates ( <predicateName>* )
      

Parameters

       predicateName
Is a list of zero or more names of predicates used in predicate rules.

Example

    RuleSet <nameOfRuleSet> (

       InferenceMethod(Predicate)

       Predicates ( father, mother, sister )
       Predicate  (brother)
       Predicates (aunt uncle)

      .
      .
      .
    )
      
Return to top

GoalPredicates

When InferenceMethod is predicate, specifies the goal(s) of the predicate inference engine.

This statement, if used, must immediately follow the last Predicates statement.

Syntax

   GoalPredicates ( <predicateClause>* )
      

Parameters

       predicateClause
Is a list, separated by either commas or ampersands, of zero or more predicate clauses. These clauses represent goals to be solved by the inference engine.

Example

    RuleSet <nameOfRuleSet> (

       InferenceMethod(Predicate)

       Predicates(male, female)
       Predicates(father mother parent)
       Predicates(son, daughter, brother)

       GoalPredicate ( brother(milcah,X) )  // Who is the brother of Milcah?

      .
      .
      .
    )
      
Return to top

Import

Allows you to import all the public methods in the specified classes (or libraries) as user-defined functions without having to declare each method explicitly. Imported methods then become available to be called from rules. Note that if two or more imported classes contain duplicate method names with an identical number of arguments, the last method imported is the method that is available to your rules. Also, when using imported methods in rules, you must use the number and types of arguments expected by the method. No checking is done, and improper use will result in runtime errors during ruleset processing. Remember that all numbers used in the rules package are implemented as doubles.

See also the UserDefinedFunctions statement.

See also the general section on interacting with functions. Among other things, the section describes some built-in method libraries that are available.

Note that built-in functions always take precedence over imported functions of the same name and arity.

Syntax

   Import ( "fully.Qualified.ClassName", ...)
      

Parameters

       "fully.Qualified.ClassName"
Specifies one or more class names, fully qualifed, with each name in double quotes, whose public methods are to be made available as user-defined functions. These methods can then be called from rule statements.

Examples

    RuleSet <nameOfRuleSet> (

       Import( "com.binford.Hammers", "com.binford.Saws" )
       Import( "com.tooltime.FirstAid" )

      .
      .
      .
    )
      

The first statement imports all the public methods in both Hammers and Saws. The second statement additionally imports all the public methods in FirstAid. If the Hammers library contains the public method driveNail(), for example, then a rule such as the following can be coded:


    rule: if nail_length == 6 then rc = driveNail()
 
      
Return to top

UserTypes

Allows you to define your own data types so that you can declare and manipulate variables of those types. Each type you declare must be equated to a public Java class.

You can declare multiple types in one UserTypes statement, or you can use multiple UserType statements that declare one type each. In either case, the net results are the same.

Syntax

   UserTypes ( type : "fully.Qualified.ClassName", ... )
      

Parameters

       type
Is an Identifier that names a new data type. Variables of this type can then be declared and used throughout your ruleset. You must not redefine the built-in data types. The identifier must be followed by a colon.
       "fully.Qualified.ClassName"
Is the fully qualified name, in double quotes, of the Java class that you want equated to the above data type. Instances of the named class must be fully serializable if you want to save your ruleset as a serialized AbleRuleSet object. The named class must also have a constructor method that matches the number of parameters that you will use when declaring variables of the specified type. If the named class has public members, or if it has public "get" and "set" methods for its members, those members can also be referenced in your rules. See the example below.

Example

    RuleSet <nameOfRuleSet> (

       UserTypes ( Puzzle : "hanoi.Puzzle", Ring:"hanoi.Ring" )
       UserType  ( DataLog: "hanoi.Logger")

      .
      .
      .
    )
      

The first statement equates the data type Puzzle to instances of objects of type "hanoi.Puzzle" and the data type Ring to instances of objects of type "hanoi.Ring." The second statement additionally equates the data type DataLog to instances of objects of type "hanoi.Logger".

These statements then allow the ruleset author to define variables such as shown below. Note that for each variable declaration an instance of the specified class is created and the constructor is passed the arguments in parentheses.

    RuleSet <nameOfRuleSet> (

      .
      .
      .

        Variables (
          easyPuzzle Puzzle("Puzzle1") // Name
          hardPuzzle Puzzle("Puzzle2") // Name

          smallRing   Ring("RingA", 2) // Name, diameter
          mediumRing  Ring("RingB", 4) // Name, diameter
          largeRing   Ring("RingC", 6) // Name, diameter
        )

      .
      .
      .
    )
      

In the example above, Puzzle (the hanoi.Puzzle class) must have a constructor that takes a string as a parameter. Ring (the hanoi.Ring class) must have a constructor that takes a string and a number as parameters. Variables as declared above will create an instance of the respective class.

Furthermore, depending on whether the Ring class has public members, or at least public getter and setter methods for internal members, rules such as the following might be allowed, where diameter is a publicly accessible member of class Ring.

    RuleSet <nameOfRuleSet> (

      .
      .
      .

        Rules (
          r1: if
                   smallRing.diameter >= mediumRing.diameter
              then
                   result = someAction();
        )

      .
      .
      .
    )
      
Return to top
Able Rule Language master index.
Able RuleSet Editor master index.
Rules package table of contents.

Last modified: Fri Sep 21 14:23:28 Central Daylight Time 2001