ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.rules
Class AblePredicateLib

java.lang.Object
  |
  +--com.ibm.able.rules.AblePredicateLib
All Implemented Interfaces:
java.io.Serializable

public class AblePredicateLib
extends java.lang.Object
implements java.io.Serializable

This class implements an alternate math library that takes/returns AbleDoubleLiterals as arguments and defines: plus, minus, times, divideBy for use by Predicate engine.

This class provides a library of mathematical user-defined functions that can be imported into an Able ruleset with an Import() statement. Each public method in this class can then be used as a user-defined function.

See Also:
Serialized Form

Field Summary
protected  AbleWorkingMemory myWm
           
 
Constructor Summary
AblePredicateLib()
          Create a new math library of user-defined function routines.
 
Method Summary
 boolean assertFact(java.lang.Object fact)
           
static java.lang.String Copyright()
          Determine the copyright of this class.
 AbleDoubleLiteral divideBy(java.lang.Object theNumberA, java.lang.Object theNumberB)
          Divide A by B and return the result.
 boolean getAnswer(AbleRuleSet theRuleSet)
          Return the answer.
 java.util.Vector getGroundSolution(AbleRuleSet theRuleSet, java.lang.String theRuleBlockName, int theIndex)
          Return the solution at the specified index in the solutionList.
 java.util.Vector getSolution(AbleRuleSet theRuleSet, java.lang.String theRuleBlockName, int theIndex)
          Return the solution at the specified index in the solutionList.
 java.util.Vector getSolutionList(AbleRuleSet theRuleSet, java.lang.String theRuleBlockName)
          Return the solutionList.
 AbleDoubleLiteral minus(java.lang.Object theNumberA, java.lang.Object theNumberB)
          Subtract B from A and return the result.
 AbleDoubleLiteral plus(java.lang.Object theNumberA, java.lang.Object theNumberB)
          Add two numbers and return the result.
 boolean retractFact(java.lang.Object fact)
           
 void setPredicateWorkingMemory(AbleWorkingMemory wm)
           
 AbleDoubleLiteral times(java.lang.Object theNumberA, java.lang.Object theNumberB)
          Multiply B by A and return the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myWm

protected AbleWorkingMemory myWm
Constructor Detail

AblePredicateLib

public AblePredicateLib()
Create a new math library of user-defined function routines.
Method Detail

plus

public AbleDoubleLiteral plus(java.lang.Object theNumberA,
                              java.lang.Object theNumberB)
                       throws AbleDataException
Add two numbers and return the result.
Parameters:
theNumberA - A number.

theNumberB - A number.

Returns:
the sum of the two numbers.

minus

public AbleDoubleLiteral minus(java.lang.Object theNumberA,
                               java.lang.Object theNumberB)
                        throws AbleDataException
Subtract B from A and return the result.
Parameters:
theNumberA - A number.

theNumberB - A number.

Returns:
the result of the subtraction.

times

public AbleDoubleLiteral times(java.lang.Object theNumberA,
                               java.lang.Object theNumberB)
                        throws AbleDataException
Multiply B by A and return the result.
Parameters:
theNumberA - A number.

theNumberB - A number.

Returns:
the product of the two numbers.

divideBy

public AbleDoubleLiteral divideBy(java.lang.Object theNumberA,
                                  java.lang.Object theNumberB)
                           throws AbleDataException
Divide A by B and return the result.
Parameters:
theNumberA - The dividend number.

theNumberB - The divisor number.

Returns:
the result of the division. If theNumberB is zero, return NaN.

getSolutionList

public java.util.Vector getSolutionList(AbleRuleSet theRuleSet,
                                        java.lang.String theRuleBlockName)
                                 throws AbleException
Return the solutionList.
Parameters:
theRuleSet -

Returns:
A Vector containing the solution(s). If no solution, zero elements will be returned.

getSolution

public java.util.Vector getSolution(AbleRuleSet theRuleSet,
                                    java.lang.String theRuleBlockName,
                                    int theIndex)
                             throws AbleException
Return the solution at the specified index in the solutionList. This is a Vector of predicates with variables bound with the results.
Parameters:
theRuleSet -

theRuleBlockName - The name of the ruleblock
theIndex - The index of the element in the solutionList to return
Returns:
A Vector containing the solution. If no solution, an empty Vector will be returned.

getGroundSolution

public java.util.Vector getGroundSolution(AbleRuleSet theRuleSet,
                                          java.lang.String theRuleBlockName,
                                          int theIndex)
                                   throws AbleException
Return the solution at the specified index in the solutionList. This is a Vector of predicates with all variables removed (i.e. ground Predicates)
Parameters:
theRuleSet -

theRuleBlockName - The name of the ruleblock
theIndex - The index of the element in the solutionList to return
Returns:
A Vector containing the solution. If no solution, an empty Vector will be returned.

getAnswer

public boolean getAnswer(AbleRuleSet theRuleSet)
                  throws AbleException
Return the answer.
Returns:
True if the solution Vector contains at least one solution.

setPredicateWorkingMemory

public void setPredicateWorkingMemory(AbleWorkingMemory wm)

assertFact

public boolean assertFact(java.lang.Object fact)

retractFact

public boolean retractFact(java.lang.Object fact)

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.


ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003