ABLE, Version 1.1b

com.ibm.able.beans.rules
Class AbleRuleSet

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--com.ibm.able.AbleObject
                          |
                          +--com.ibm.able.beans.rules.AbleRuleSet

public class AbleRuleSet
extends AbleObject
implements AbleSensorManager, AbleEffectorManager, java.io.Serializable

RuleSet class The RuleSet provides an inferencing context using: (1) a set of working memory items (Facts, Variables, others) (2) a set of Rules (3) an inference engine

Version:
$Revision: 1.2 $, $Date: 2000/07/25 14:51:12 $
See Also:
Serialized Form

Field Summary
protected  java.util.Vector assertions
           
static int BACKWARD_CHAIN
           
protected  java.util.Hashtable effectors
           
protected  AbleInferenceEngine engine
           
static int FORWARD_CHAIN
           
protected  java.util.Stack goalClauseStack
           
protected  java.lang.String goalVariableName
           
static int MIXED_CHAIN
           
protected  int mode
           
protected  java.util.Vector rules
           
protected  java.util.Hashtable sensors
           
protected  java.util.Hashtable workingMemory
           
 
Fields inherited from class com.ibm.able.AbleObject
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
AbleRuleSet()
           
AbleRuleSet(java.lang.String name)
           
 
Method Summary
 void addAssertion(AbleRule theRule)
           
 void addEffector(AbleEffector anEffector)
          Add an effector to the list of managed effectors.
 void addMemoryItem(java.lang.String name, java.lang.Object item)
          Add an item to working memory
 void addRule(AbleRule rule)
           
 void addSensor(AbleSensor aSensor)
          Add a sensor to the list of managed sensors.
 void addVariableToInputSequence(java.lang.String theVariableName)
          Specify that a variable is to be added to the input sequence.
 void addVariableToOutputSequence(java.lang.String theVariableName)
          Specify that a variable is to be added to the output sequence.
 void backwardChain(java.lang.String goal)
           
 void clear()
          remove all rules and memory items from the rule set
 boolean definedSensorEffector(java.lang.String theName, boolean theSensorFlag)
          Determine whether a sensor or an effector with the specified name already exists within the ruleset.
 void defineEffector(java.lang.String theEffectorName)
          Define an effector that must be available at runtime.
 void defineSensor(java.lang.String theSensorName)
          Define a sensor that must be available at runtime.
 void displayVariables()
          Display the values of all variables in the rule set
 boolean effectorNameAlreadyExists(java.lang.String theEffectorName)
          Determine whether an effector with the specified name exists within the ruleset.
 boolean effectorNameIsUnused(java.lang.String theEffectorName)
          Determine whether an effector with the specified name does not exist within the ruleset.
 AbleParTrace getBaseTraceObject()
          Retrieve the base tracer object.
 java.util.Hashtable getDefinedEffectors()
          Get defined effectors.
 java.util.Hashtable getDefinedSensors()
          Get defined sensors.
 java.util.Hashtable getEffectors()
          Get all effectors registered with this effector manager.
 java.lang.String getGoalVariableName()
           
 AbleParTrace getInfrTraceObject()
          Retrieve the inferencing tracer object.
 java.lang.Object getMemoryItem(java.lang.String name)
          retrieve a working memory item
 int getMode()
           
 int getNumOutputVars()
          Retrieve the number of output variables.
 java.util.Vector getOutputVars()
          Retrieve the output variables.
 AbleRule getRule(java.lang.String name)
           
 java.util.Vector getRules()
          retrieve the list of rules
 java.util.Hashtable getSensors()
          Get all sensors registered with this sensor manager.
 java.io.File getSrcFile()
          Retrieve the name of the source file for this ruleset.
 java.lang.String getSrcFileName()
          Retrieve the name of the source file for this ruleset.
 java.util.Hashtable getWorkingMemory()
          get a copy of the current working memory
 void init()
          Initialize the rule set, start asynchronous event processing
 void instantiateFrom(java.io.DataInputStream theStream, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag)
          Instantiate the ruleset object by reading a rule source file contained in the specified input stream.
 void instantiateFrom(java.lang.String theFileName, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag)
          Instantiate the ruleset object by reading a rule source file contained in the specified input file.
 void instantiateFromXml(java.io.File theFile, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag)
          Instantiate the ruleset object by reading a boolean XML document contained in the specified input file.
 void instantiateFromXml(java.io.InputStream theInputStream, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag)
          Instantiate the ruleset object by reading a boolean rule XML document contained in the specified input stream.
 java.lang.Object invokeEffector(java.lang.String anEffectorName, java.lang.Object[] args)
          Call the method that the specified effector represents, passing to it the specified array of argument objects.
 java.lang.Object invokeSensor(java.lang.String aSensorName, java.lang.Object[] args)
          Call the method that the specified sensor represents, passing to it the specified array of argument objects.
 boolean ioBuffersOK()
          Determine whether the input and output buffers are the expected object type (String[]) and that they have enough slots to hold the required input and output variables.
 boolean isBaseTraceActive()
          Determine whether ruleset tracing is on.
 boolean isExecutable()
          Determine whether the ruleset is executable.
 void makeAssertionRule(java.lang.String theRuleLabel, AbleConsequentClause theCnsClause, double theRulePriority)
          Create an unconditional rule (that is, an assertion) from the specified bits, and add the rule to the ruleset.
 void makeBooleanVariable(java.lang.String theVariableName, boolean theBooleanValue)
          Create a boolean variable, give it an initial value, and add it to the ruleset.
 void makeCategoricalVariable(java.lang.String theVariableName, java.util.Hashtable theSymbolList)
          Create a symbolic variable and add it to the ruleset.
 void makeConditionalRule(java.lang.String theRuleLabel, java.util.Vector theAntClauses, AbleConsequentClause theCnsClause, double theRulePriority)
           
 void makeContinuousVariable(java.lang.String theVariableName, double theLoValue, double theHiValue)
          Create a continuous variable over a range of values and add it to the ruleset.
 void makeDiscreteVariable(java.lang.String theVariableName, double theNumericValue)
          Create a numeric variable, give it an initial value, and add it to the ruleset.
 void process()
          Perform the standard processing function performed by this object.
 void removeAllMemoryItems()
          remove all items from working memory
 void removeAllRules()
          remove all rules from the rule set
 void removeEffector(java.lang.String anEffectorName)
          Remove an effector from the list of managed effectors.
 void removeMemoryItem(java.lang.String name)
          remove an item from working memory
 void removeRule(java.lang.String name)
          Remove all rules with the specified name
 void removeSensor(java.lang.String aSensorName)
          Remove a sensor from the list of managed sensors.
 void reset()
          Reset the ruleset so that rules can be fired again.
 java.lang.Object[] resolveArgs(java.lang.Object[] theArgs)
          Scan the list of arguments, turning any reference to a named variable into the variable's current value.
 java.lang.String rlString()
          Return a formal able rule language string.
 boolean sensorNameAlreadyExists(java.lang.String theSensorName)
          Determine whether a sensor with the specified name exists within the ruleset.
 boolean sensorNameIsUnused(java.lang.String theSensorName)
          Determine whether a sensor with the specified name does not exist within the ruleset.
 void setEffectors(java.util.Hashtable theEffectors)
          Set all effectors for this manager.
 void setGoalVariableName(java.lang.String theVariableName)
           
 void setMemoryItem(java.lang.String name, java.lang.Object item)
          set or replace a working memory item
 void setMode(int infMode)
           
 void setRule(AbleRule rule)
           
 void setRules(java.util.Vector newRules)
          Set all of the rules in the ruleSet Note: all existing rules are removed
 void setSensors(java.util.Hashtable theSensors)
          Set all sensors for this manager.
 void setSerFileName(java.lang.String theSerFileName)
          Specify the name of the serialized file for this ruleset.
 void setSrcFile(java.io.File theSrcFile)
          Specify the source file object for this ruleset.
 void setSrcFileName(java.lang.String theSrcFileName)
          Specify the name of the source file for this ruleset.
 void setWorkingMemory(java.util.Vector newItems)
          load the entire working memory with AbleAtoms
 void setWorkingMemory(java.util.Vector names, java.util.Vector newItems)
          load the entire working memory with Objects
 void setXmlFileName(java.lang.String theXmlFileName)
          Specify the name of the XML document file for this ruleset.
 boolean variableNameAlreadyExists(java.lang.String theVariableName)
          Determine whether a variable with the specified name exists within the ruleset.
 boolean variableNameIsUnused(java.lang.String theVariableName)
          Determine whether a variable with the specified name does not exist within the ruleset.
 java.lang.String xmlString()
          Retrieve the XML representation of this rule set.
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, Copyright, dataChanged, firePropertyChange, flushAbleEventQueue, getAbleEventListeners, getAbleEventProcessingEnabled, getAbleEventQueueSize, getBuffer, getBufferContents, getComment, getDestBufferConnections, getFileName, getInputBuffer, getInputBuffer, getInputBufferAsStringArray, getInputBufferContents, getLogger, getName, getOutputBuffer, getOutputBuffer, getOutputBufferAsStringArray, getOutputBufferContents, getParent, getPropertyConnectionManager, getSleepTime, getSourceBufferConnections, getState, handleAbleEvent, hasInputBuffer, hasOutputBuffer, init, isAbleEventPostingEnabled, isAbleEventProcessingEnabled, isChanged, isConnectable, isDataFlowEnabled, isTimerEventProcessingEnabled, notifyAbleEventListeners, processAbleEvent, processBufferConnections, processNoEventProcessingEnabledSituation, processTimerEvent, propertyChange, quitAll, quitEnabledEventProcessing, removeAbleEventListener, removeAllAbleEventListeners, removeAllBufferConnections, removeAllPropertyConnections, removeDestBufferConnection, removePropertyChangeListener, removePropertyConnection, removeSourceBufferConnection, removeStateChangeListener, restartEnabledEventProcessing, restoreFromFile, restoreFromFile, restoreFromSerializedFile, restoreFromStream, resumeAll, resumeEnabledEventProcessing, saveToFile, saveToFile, setAbleEventProcessingEnabled, setChanged, setComment, setDataFlowEnabled, setFileName, setInputBuffer, setInputBuffer, setLogger, setName, setOutputBuffer, setOutputBuffer, setParent, setSleepTime, setState, setTimerEventProcessingEnabled, sourceConnectionsOK, startEnabledEventProcessing, suspendAll, suspendEnabledEventProcessing, toString
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

workingMemory

protected java.util.Hashtable workingMemory

rules

protected java.util.Vector rules

engine

protected AbleInferenceEngine engine

mode

protected int mode

FORWARD_CHAIN

public static final int FORWARD_CHAIN

BACKWARD_CHAIN

public static final int BACKWARD_CHAIN

MIXED_CHAIN

public static final int MIXED_CHAIN

goalVariableName

protected java.lang.String goalVariableName

goalClauseStack

protected java.util.Stack goalClauseStack

effectors

protected java.util.Hashtable effectors

sensors

protected java.util.Hashtable sensors

assertions

protected java.util.Vector assertions
Constructor Detail

AbleRuleSet

public AbleRuleSet()
            throws java.rmi.RemoteException

AbleRuleSet

public AbleRuleSet(java.lang.String name)
            throws java.rmi.RemoteException
Method Detail

process

public void process()
             throws java.rmi.RemoteException
Perform the standard processing function performed by this object. This typically takes data from the inputBuffer, processes it, and places the results in the output buffer. Specifically:

Fire the rules in the ruleset.

The order of processing is as follows:

  1. Determine whether the ruleset is executable. If it is, processing continues.
  2. Determine whether the IO buffers are of the proper type and size. If they are, processing continues.
  3. The ruleset is reset. (See below.)
  4. All assertions are fired.
  5. Variables identified in the input sequence are assigned values from the input buffer. The input buffer object must be a String[].
  6. Conditional rules are fired until they quiesce.
  7. Values of variables identified in the output sequence are written to the output buffer. The output buffer object must be a String[].
Throws:
AbleParException - When any error occurs.

Overrides:
process in class AbleObject
See Also:
isExecutable(), reset()

reset

public void reset()
           throws java.rmi.RemoteException
Reset the ruleset so that rules can be fired again. Each variable is reset to its original initial value (if it had one) and all rules are set to their original state. Also, each element in the output buffer (if there is one) is cleared to the empty string "".
Overrides:
reset in class AbleObject

addSensor

public void addSensor(AbleSensor aSensor)
Add a sensor to the list of managed sensors.
Specified by:
addSensor in interface AbleSensorManager
Parameters:
aSensor - The actual sensor to be added to the list of sensors.

See Also:
removeSensor(java.lang.String)

removeSensor

public void removeSensor(java.lang.String aSensorName)
Remove a sensor from the list of managed sensors.
Specified by:
removeSensor in interface AbleSensorManager
Parameters:
aSensorName - The name of the sensor to be removed.

See Also:
addSensor(com.ibm.able.beans.AbleSensor)

getSensors

public java.util.Hashtable getSensors()
Get all sensors registered with this sensor manager.
Specified by:
getSensors in interface AbleSensorManager
Returns:
A list of all registered AbleSensor objects.
See Also:
addSensor(com.ibm.able.beans.AbleSensor), setSensors(java.util.Hashtable)

setSensors

public void setSensors(java.util.Hashtable theSensors)
Set all sensors for this manager.
Specified by:
setSensors in interface AbleSensorManager
Parameters:
theSensors - A list of AbleSensor objects that are to be managed by this sensor manager. The input list is cloned.

See Also:
addSensor(com.ibm.able.beans.AbleSensor), getSensors()

invokeSensor

public java.lang.Object invokeSensor(java.lang.String aSensorName,
                                     java.lang.Object[] args)
                              throws java.lang.NoSuchMethodException,
                                     java.lang.reflect.InvocationTargetException,
                                     java.lang.IllegalAccessException,
                                     java.lang.SecurityException
Call the method that the specified sensor represents, passing to it the specified array of argument objects.
Specified by:
invokeSensor in interface AbleSensorManager
Parameters:
aSensorName - The name of the sensor containing an encapsulated method.

args - An array of arguments that the method expects.

Returns:
The invoked method's return value.
Throws:
java.lang.reflect.InvocationTargetException - if an exception was thrown by the invoked method
java.lang.SecurityException - if the method is not public or accessible
java.lang.IllegalAccessException - if the method is not public or accessible
java.lang.NoSuchMethodException - the method or method signature if not defined in the source object

addEffector

public void addEffector(AbleEffector anEffector)
Add an effector to the list of managed effectors.
Specified by:
addEffector in interface AbleEffectorManager
Parameters:
anEffector - The actual effector to be added to the list of effectors.

See Also:
removeEffector(java.lang.String)

removeEffector

public void removeEffector(java.lang.String anEffectorName)
Remove an effector from the list of managed effectors.
Specified by:
removeEffector in interface AbleEffectorManager
Parameters:
anEffectorName - The name of the effector to be removed.

See Also:
addEffector(com.ibm.able.beans.AbleEffector)

invokeEffector

public java.lang.Object invokeEffector(java.lang.String anEffectorName,
                                       java.lang.Object[] args)
                                throws java.lang.NoSuchMethodException,
                                       java.lang.reflect.InvocationTargetException,
                                       java.lang.IllegalAccessException,
                                       java.lang.SecurityException
Call the method that the specified effector represents, passing to it the specified array of argument objects.
Specified by:
invokeEffector in interface AbleEffectorManager
Parameters:
anEffectorName - The name of the effector containing an encapsulated method.

args - An array of arguments that the method expects.

Returns:
The invoked method's return value
Throws:
java.lang.reflect.InvocationTargetException - if an exception was thrown by the invoked method
java.lang.SecurityException - if the method is not public or accessible
java.lang.IllegalAccessException - if the method is not public or accessible
java.lang.NoSuchMethodException - the method or method signature if not defined in the source object

getEffectors

public java.util.Hashtable getEffectors()
Get all effectors registered with this effector manager.
Specified by:
getEffectors in interface AbleEffectorManager
Returns:
A list of all registered AbleEffector objects.
See Also:
addEffector(com.ibm.able.beans.AbleEffector), setEffectors(java.util.Hashtable)

setEffectors

public void setEffectors(java.util.Hashtable theEffectors)
Set all effectors for this manager.
Specified by:
setEffectors in interface AbleEffectorManager
Parameters:
theEffectors - A list of AbleEffector objects that are to be managed by this effector manager. The input list is cloned.

See Also:
addEffector(com.ibm.able.beans.AbleEffector), getEffectors()

setMode

public void setMode(int infMode)

getMode

public int getMode()

setGoalVariableName

public void setGoalVariableName(java.lang.String theVariableName)
                         throws AbleParException

getGoalVariableName

public java.lang.String getGoalVariableName()

init

public void init()
          throws java.rmi.RemoteException
Initialize the rule set, start asynchronous event processing
Overrides:
init in class AbleObject

clear

public void clear()
remove all rules and memory items from the rule set

displayVariables

public void displayVariables()
Display the values of all variables in the rule set

backwardChain

public void backwardChain(java.lang.String goal)

addMemoryItem

public void addMemoryItem(java.lang.String name,
                          java.lang.Object item)
Add an item to working memory

removeMemoryItem

public void removeMemoryItem(java.lang.String name)
remove an item from working memory

removeAllMemoryItems

public void removeAllMemoryItems()
remove all items from working memory

setMemoryItem

public void setMemoryItem(java.lang.String name,
                          java.lang.Object item)
set or replace a working memory item

getMemoryItem

public java.lang.Object getMemoryItem(java.lang.String name)
retrieve a working memory item

setWorkingMemory

public void setWorkingMemory(java.util.Vector names,
                             java.util.Vector newItems)
load the entire working memory with Objects

setWorkingMemory

public void setWorkingMemory(java.util.Vector newItems)
load the entire working memory with AbleAtoms

getWorkingMemory

public java.util.Hashtable getWorkingMemory()
get a copy of the current working memory

addRule

public void addRule(AbleRule rule)

addAssertion

public void addAssertion(AbleRule theRule)

removeRule

public void removeRule(java.lang.String name)
Remove all rules with the specified name

removeAllRules

public void removeAllRules()
remove all rules from the rule set

setRule

public void setRule(AbleRule rule)

getRule

public AbleRule getRule(java.lang.String name)

setRules

public void setRules(java.util.Vector newRules)
Set all of the rules in the ruleSet Note: all existing rules are removed

getRules

public java.util.Vector getRules()
retrieve the list of rules

isExecutable

public boolean isExecutable()
Determine whether the ruleset is executable.

The ruleset is executable if:

  1. The parsser, if used, completed successfully.
  2. Variables have been successfully defined.
  3. Sensors and effectors referenced in the source rule file are actually available.
  4. Rules with valid clauses have been successfully defined.
Returns:
true if the ruleset seems executable, false otherwise.


ioBuffersOK

public boolean ioBuffersOK()
                    throws java.rmi.RemoteException
Determine whether the input and output buffers are the expected object type (String[]) and that they have enough slots to hold the required input and output variables.
Returns:
true if the buffers are big enough, false otherwise.


addVariableToInputSequence

public void addVariableToInputSequence(java.lang.String theVariableName)
                                throws AbleParException
Specify that a variable is to be added to the input sequence.

Variables that are in the input sequence have their values taken from an input buffer before inferencing begins. Explicitly, all assertions are fired, variables appearing in the input sequence are assigned values from the user's supplied input buffer, and then all conditional rules are fired. In this way, data supplied at runtime always takes precedence over data "hardcoded" in a ruleset.

Note that a variable may appear in the input sequence more than once, but because the input buffer (where the values come from) is a Hashtable, this has no significance. It simply means that a variable's value is loaded more than once.

Parameters:
theVariableName - The name of a variable whose value is to be taken from the input buffer before inferencing begins.

Throws:
AbleParException - If a variable with the specified name doesn't exist.

See Also:
process()

addVariableToOutputSequence

public void addVariableToOutputSequence(java.lang.String theVariableName)
                                 throws AbleParException
Specify that a variable is to be added to the output sequence.

Variables that are in the output sequence have their values written to an output buffer after inferencing ends.

Note that a variable may appear in the output sequence more than once, but because the output buffer (to where the values are written) is a Hashtable, this has no significance. It simply means that a variable's value is written more than once to the same key.

Parameters:
theVariableName - The name of a variable whose value is to be written to the output buffer after inferencing ends.

Throws:
AbleParException - If a variable with the specified name doesn't exist.

See Also:
process()

getNumOutputVars

public int getNumOutputVars()
Retrieve the number of output variables.
Returns:
The number of variables to be written to the output buffer.


getOutputVars

public java.util.Vector getOutputVars()
Retrieve the output variables.
Returns:
A list of variables.


variableNameAlreadyExists

public boolean variableNameAlreadyExists(java.lang.String theVariableName)
Determine whether a variable with the specified name exists within the ruleset.
Parameters:
theVariableName - The name of a variable that might exist.

Returns:
true if a variable with the specified name exists in the ruleset; false otherwise.


variableNameIsUnused

public boolean variableNameIsUnused(java.lang.String theVariableName)
Determine whether a variable with the specified name does not exist within the ruleset.
Parameters:
theVariableName - The name of a variable that might exist.

Returns:
true if a variable with the specified name does not exist in the ruleset; false otherwise.


defineEffector

public void defineEffector(java.lang.String theEffectorName)
                    throws AbleParException
Define an effector that must be available at runtime.
Parameters:
theEffectorName - The name of an effector that will be available at runtime.


getDefinedEffectors

public java.util.Hashtable getDefinedEffectors()
                                        throws java.rmi.RemoteException
Get defined effectors.
Returns:
A list of all parser-defined effectors.

effectorNameAlreadyExists

public boolean effectorNameAlreadyExists(java.lang.String theEffectorName)
Determine whether an effector with the specified name exists within the ruleset.
Parameters:
theEffectorName - The name of an effector that might exist.

Returns:
true if an effector with the specified name exists in the ruleset; false otherwise.


effectorNameIsUnused

public boolean effectorNameIsUnused(java.lang.String theEffectorName)
Determine whether an effector with the specified name does not exist within the ruleset.
Parameters:
theEffectorName - The name of an effector that might exist.

Returns:
true if an effector with the specified name does not exist in the ruleset; false otherwise.


defineSensor

public void defineSensor(java.lang.String theSensorName)
                  throws AbleParException
Define a sensor that must be available at runtime.
Parameters:
theSensorName - The name of a sensor that will be available at runtime.


getDefinedSensors

public java.util.Hashtable getDefinedSensors()
                                      throws java.rmi.RemoteException
Get defined sensors.
Returns:
A list of all parser-defined sensors.

sensorNameAlreadyExists

public boolean sensorNameAlreadyExists(java.lang.String theSensorName)
Determine whether a sensor with the specified name exists within the ruleset.
Parameters:
theSensorName - The name of a sensor that might exist.

Returns:
true if a sensor with the specified name exists in the ruleset; false otherwise.


sensorNameIsUnused

public boolean sensorNameIsUnused(java.lang.String theSensorName)
Determine whether a sensor with the specified name does not exist within the ruleset.
Parameters:
theSensorName - The name of a sensor that might exist.

Returns:
true if a sensor with the specified name does not exist in the ruleset; false otherwise.


definedSensorEffector

public boolean definedSensorEffector(java.lang.String theName,
                                     boolean theSensorFlag)
Determine whether a sensor or an effector with the specified name already exists within the ruleset.
Parameters:
theName - The name of a sensor or an effector that might exist.

theSensorFlag - If true, the name is checked against the list of known sensors; otherwise the name is checked against the list of known effectors. This method checks one list or the other, not both!

Returns:
true if a sensor or an effector with the specified name does exist in the ruleset; false otherwise.


makeBooleanVariable

public void makeBooleanVariable(java.lang.String theVariableName,
                                boolean theBooleanValue)
                         throws AbleParException
Create a boolean variable, give it an initial value, and add it to the ruleset.

Boolean variables may only take on the value True or False.

Parameters:
theVariableName - The name of the new variable.

theBooleanValue - The initial value of the variable. This is also the value of the variable after a ruleset reset().

Throws:
AbleParException - If a variable with the specified name already exists.

See Also:
reset()

makeCategoricalVariable

public void makeCategoricalVariable(java.lang.String theVariableName,
                                    java.util.Hashtable theSymbolList)
                             throws AbleParException
Create a symbolic variable and add it to the ruleset.

Symbolic variables may take on only a value that occurs in the specified symbol list.

Parameters:
theVariableName - The name of the new variable.

theSymbolList - The list of Symbols, any one of which can be the current value of the symbolic variable.

The symbol list is a hashtable where the keys and objects are identical String objects. For example, String foo = "bar"; theSymbolList.put(foo,foo);

Throws:
AbleParException - If a variable with the specified name already exists.


makeContinuousVariable

public void makeContinuousVariable(java.lang.String theVariableName,
                                   double theLoValue,
                                   double theHiValue)
                            throws AbleParException
Create a continuous variable over a range of values and add it to the ruleset.

Continuous variables may take on any value within a universe of discourse, or range of values, delimited by theLoValue and theHiValue.

Parameters:
theVariableName - The name of the new variable.

theLoValue - Defines the low end of the universe of discourse.

theHiValue - Defines the high end of the universe of discourse.

Throws:
AbleParException - If a variable with the specified name already exists.


makeDiscreteVariable

public void makeDiscreteVariable(java.lang.String theVariableName,
                                 double theNumericValue)
                          throws AbleParException
Create a numeric variable, give it an initial value, and add it to the ruleset.

Numeric variables may take on any arbitrary numeric value.

Parameters:
theVariableName - The name of the new variable.

theNumericValue - The initial value of the variable. This is also the value of the variable after a ruleset reset().

Throws:
AbleParException - If a variable with the specified name already exists.

See Also:
reset()

makeAssertionRule

public void makeAssertionRule(java.lang.String theRuleLabel,
                              AbleConsequentClause theCnsClause,
                              double theRulePriority)
                       throws AbleParException
Create an unconditional rule (that is, an assertion) from the specified bits, and add the rule to the ruleset.

makeConditionalRule

public void makeConditionalRule(java.lang.String theRuleLabel,
                                java.util.Vector theAntClauses,
                                AbleConsequentClause theCnsClause,
                                double theRulePriority)
                         throws AbleParException

instantiateFrom

public void instantiateFrom(java.io.DataInputStream theStream,
                            AbleParTrace theTracer,
                            boolean theStopOnAbleExceptionFlag)
                     throws AbleParException,
                            antlr.ParserException,
                            java.io.IOException
Instantiate the ruleset object by reading a rule source file contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theStream - The source from which a rule file is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

Throws:
AbleParException - On any error.

antlr.ParserException - If the rule file cannot be parsed successfully.

java.io.IOException - If an error occurs while reading the source rule file.


instantiateFrom

public void instantiateFrom(java.lang.String theFileName,
                            AbleParTrace theTracer,
                            boolean theStopOnAbleExceptionFlag)
                     throws AbleParException,
                            antlr.ParserException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Instantiate the ruleset object by reading a rule source file contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theFileName - The source from which a rule file is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

Throws:
AbleParException - On any error.

antlr.ParserException - If the rule file cannot be parsed successfully.

java.io.FileNotFoundException - If the specified input file cannot be found.

java.io.IOException - If an error occurs while reading the source rule file.


instantiateFromXml

public void instantiateFromXml(java.io.InputStream theInputStream,
                               AbleParTrace theTracer,
                               boolean theStopOnAbleExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               org.xml.sax.SAXException,
                               java.io.IOException
Instantiate the ruleset object by reading a boolean rule XML document contained in the specified input stream. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theStream - The source from which an XML document is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

Throws:
AbleParException - On any parser error.

org.xml.sax.SAXException - If the XML document cannot be parsed successfully.

java.io.IOException - If an error occurs while reading the XML document.


instantiateFromXml

public void instantiateFromXml(java.io.File theFile,
                               AbleParTrace theTracer,
                               boolean theStopOnAbleExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               AbleParException,
                               org.xml.sax.SAXException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Instantiate the ruleset object by reading a boolean XML document contained in the specified input file. If no exceptions are thrown during this process, the ruleset is ready for processing when this method returns.

Note that if the ruleset contains any variables and rules from a previous instantiation, these are removed from the ruleset before the source file is read. That is, the ruleset is cleared, and made to look like a newly created ruleset.

Parameters:
theFile - The source from which an XML document is read.

theTracer - A trace object, used by the parser to record information during the parsing process.

Throws:
AbleParException - On any parser error.

org.xml.sax.SAXException - If the XML document cannot be parsed successfully.

java.io.FileNotFoundException - If the specified input file cannot be found.

java.io.IOException - If an error occurs while reading the XML document file.


setSrcFile

public void setSrcFile(java.io.File theSrcFile)
Specify the source file object for this ruleset.

This, and the following few methods, are used by the Able RuleSet Editor program. When the editor is told to save the source rules, this method is called so that the source file object may be temporarily saved across editor sessions. Then, when the user selects "customize" from the Able Editor, the rule editor will be able to retrieve the file object and reload the source rule file.

If there is no source rule file, the editor will try to reconstitute the source rules from the existing instantiated ruleset variables.

Note that the variable containing the source file is transient. This is because serialized objects will likely be transferred from system to system with possibly different file systems and file naming conventions. When this happens, it is not likely that the source file will accompany the serialized file, and if it should, it is not likely that the source file would appear within the same directory structure as it did on the originating system!

Parameters:
theSrcFile - The file object containing source rules.


getSrcFile

public java.io.File getSrcFile()
Retrieve the name of the source file for this ruleset.
Returns:
The name of the file containing source rules.


setSrcFileName

public void setSrcFileName(java.lang.String theSrcFileName)
Specify the name of the source file for this ruleset.
Parameters:
theSrcFileName - The name of the file containing source rules.


getSrcFileName

public java.lang.String getSrcFileName()
Retrieve the name of the source file for this ruleset.
Returns:
The name of the file containing source rules.


setSerFileName

public void setSerFileName(java.lang.String theSerFileName)
                    throws java.rmi.RemoteException
Specify the name of the serialized file for this ruleset.
Parameters:
theSerFileName - The name of the file containing a serialized able ruleset.


setXmlFileName

public void setXmlFileName(java.lang.String theXmlFileName)
                    throws java.rmi.RemoteException
Specify the name of the XML document file for this ruleset.
Parameters:
theXmlFileName - The name of the file containing a fuzzy XML document.


resolveArgs

public java.lang.Object[] resolveArgs(java.lang.Object[] theArgs)
                               throws AbleParException
Scan the list of arguments, turning any reference to a named variable into the variable's current value.
Parameters:
theArgs - Arguments to a sensor or an effector.

Throws:
AbleParException - on any error.

rlString

public java.lang.String rlString()
Return a formal able rule language string.
Returns:
A String describing the object in able rule language.


xmlString

public java.lang.String xmlString()
Retrieve the XML representation of this rule set.
Returns:
A String containing an XML representation of this ruleset.


isBaseTraceActive

public boolean isBaseTraceActive()
Determine whether ruleset tracing is on.
Returns:
true if ruleset tracing is on; false otherwise.

See Also:
AbleParTrace.isActive()

getBaseTraceObject

public AbleParTrace getBaseTraceObject()
Retrieve the base tracer object.
Returns:
the base trace object.


getInfrTraceObject

public AbleParTrace getInfrTraceObject()
Retrieve the inferencing tracer object.
Returns:
the inferencing trace object.


ABLE, Version 1.1b

ABLE: Produced by Joe, Don, and Jeff who say, 'Thanks for your support.'