|
ABLE, Version 1.1b | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
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
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 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 |
protected java.util.Hashtable workingMemory
protected java.util.Vector rules
protected AbleInferenceEngine engine
protected int mode
public static final int FORWARD_CHAIN
public static final int BACKWARD_CHAIN
public static final int MIXED_CHAIN
protected java.lang.String goalVariableName
protected java.util.Stack goalClauseStack
protected java.util.Hashtable effectors
protected java.util.Hashtable sensors
protected java.util.Vector assertions
Constructor Detail |
public AbleRuleSet() throws java.rmi.RemoteException
public AbleRuleSet(java.lang.String name) throws java.rmi.RemoteException
Method Detail |
public void process() throws java.rmi.RemoteException
Fire the rules in the ruleset.
The order of processing is as follows:
isExecutable()
,
reset()
public void reset() throws java.rmi.RemoteException
public void addSensor(AbleSensor aSensor)
aSensor
- The actual sensor to be added to the list of sensors.
removeSensor(java.lang.String)
public void removeSensor(java.lang.String aSensorName)
aSensorName
- The name of the sensor to be removed.
addSensor(com.ibm.able.beans.AbleSensor)
public java.util.Hashtable getSensors()
addSensor(com.ibm.able.beans.AbleSensor)
,
setSensors(java.util.Hashtable)
public void setSensors(java.util.Hashtable theSensors)
theSensors
- A list of AbleSensor objects that are to be managed by
this sensor manager. The input list is cloned.
addSensor(com.ibm.able.beans.AbleSensor)
,
getSensors()
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
aSensorName
- The name of the sensor containing an encapsulated method.
args
- An array of arguments that the method expects.
public void addEffector(AbleEffector anEffector)
anEffector
- The actual effector to be added to the list of effectors.
removeEffector(java.lang.String)
public void removeEffector(java.lang.String anEffectorName)
anEffectorName
- The name of the effector to be removed.
addEffector(com.ibm.able.beans.AbleEffector)
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
anEffectorName
- The name of the effector containing an encapsulated method.
args
- An array of arguments that the method expects.
public java.util.Hashtable getEffectors()
addEffector(com.ibm.able.beans.AbleEffector)
,
setEffectors(java.util.Hashtable)
public void setEffectors(java.util.Hashtable theEffectors)
theEffectors
- A list of AbleEffector objects that are to be managed by
this effector manager. The input list is cloned.
addEffector(com.ibm.able.beans.AbleEffector)
,
getEffectors()
public void setMode(int infMode)
public int getMode()
public void setGoalVariableName(java.lang.String theVariableName) throws AbleParException
public java.lang.String getGoalVariableName()
public void init() throws java.rmi.RemoteException
public void clear()
public void displayVariables()
public void backwardChain(java.lang.String goal)
public void addMemoryItem(java.lang.String name, java.lang.Object item)
public void removeMemoryItem(java.lang.String name)
public void removeAllMemoryItems()
public void setMemoryItem(java.lang.String name, java.lang.Object item)
public java.lang.Object getMemoryItem(java.lang.String name)
public void setWorkingMemory(java.util.Vector names, java.util.Vector newItems)
public void setWorkingMemory(java.util.Vector newItems)
public java.util.Hashtable getWorkingMemory()
public void addRule(AbleRule rule)
public void addAssertion(AbleRule theRule)
public void removeRule(java.lang.String name)
public void removeAllRules()
public void setRule(AbleRule rule)
public AbleRule getRule(java.lang.String name)
public void setRules(java.util.Vector newRules)
public java.util.Vector getRules()
public boolean isExecutable()
The ruleset is executable if:
public boolean ioBuffersOK() throws java.rmi.RemoteException
public void addVariableToInputSequence(java.lang.String theVariableName) throws AbleParException
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.
theVariableName
- The name of a variable whose value is to be taken from the
input buffer before inferencing begins.
process()
public void addVariableToOutputSequence(java.lang.String theVariableName) throws AbleParException
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.
theVariableName
- The name of a variable whose value is to be written to the
output buffer after inferencing ends.
process()
public int getNumOutputVars()
public java.util.Vector getOutputVars()
public boolean variableNameAlreadyExists(java.lang.String theVariableName)
theVariableName
- The name of a variable that might exist.
public boolean variableNameIsUnused(java.lang.String theVariableName)
theVariableName
- The name of a variable that might exist.
public void defineEffector(java.lang.String theEffectorName) throws AbleParException
theEffectorName
- The name of an effector that will be available at runtime.
public java.util.Hashtable getDefinedEffectors() throws java.rmi.RemoteException
public boolean effectorNameAlreadyExists(java.lang.String theEffectorName)
theEffectorName
- The name of an effector that might exist.
public boolean effectorNameIsUnused(java.lang.String theEffectorName)
theEffectorName
- The name of an effector that might exist.
public void defineSensor(java.lang.String theSensorName) throws AbleParException
theSensorName
- The name of a sensor that will be available at runtime.
public java.util.Hashtable getDefinedSensors() throws java.rmi.RemoteException
public boolean sensorNameAlreadyExists(java.lang.String theSensorName)
theSensorName
- The name of a sensor that might exist.
public boolean sensorNameIsUnused(java.lang.String theSensorName)
theSensorName
- The name of a sensor that might exist.
public boolean definedSensorEffector(java.lang.String theName, boolean theSensorFlag)
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!
public void makeBooleanVariable(java.lang.String theVariableName, boolean theBooleanValue) throws AbleParException
Boolean variables may only take on the value True or False.
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().
reset()
public void makeCategoricalVariable(java.lang.String theVariableName, java.util.Hashtable theSymbolList) throws AbleParException
Symbolic variables may take on only a value that occurs in the specified symbol list.
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);
public void makeContinuousVariable(java.lang.String theVariableName, double theLoValue, double theHiValue) throws AbleParException
Continuous variables may take on any value within a universe of discourse, or range of values, delimited by theLoValue and theHiValue.
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.
public void makeDiscreteVariable(java.lang.String theVariableName, double theNumericValue) throws AbleParException
Numeric variables may take on any arbitrary numeric value.
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().
reset()
public void makeAssertionRule(java.lang.String theRuleLabel, AbleConsequentClause theCnsClause, double theRulePriority) throws AbleParException
public void makeConditionalRule(java.lang.String theRuleLabel, java.util.Vector theAntClauses, AbleConsequentClause theCnsClause, double theRulePriority) throws AbleParException
public void instantiateFrom(java.io.DataInputStream theStream, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag) throws AbleParException, antlr.ParserException, java.io.IOException
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.
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.
public void instantiateFrom(java.lang.String theFileName, AbleParTrace theTracer, boolean theStopOnAbleExceptionFlag) throws AbleParException, antlr.ParserException, java.io.FileNotFoundException, java.io.IOException
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.
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.
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
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.
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.
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
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.
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.
public void setSrcFile(java.io.File theSrcFile)
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!
theSrcFile
- The file object containing source rules.
public java.io.File getSrcFile()
public void setSrcFileName(java.lang.String theSrcFileName)
theSrcFileName
- The name of the file containing source rules.
public java.lang.String getSrcFileName()
public void setSerFileName(java.lang.String theSerFileName) throws java.rmi.RemoteException
theSerFileName
- The name of the file containing a serialized able ruleset.
public void setXmlFileName(java.lang.String theXmlFileName) throws java.rmi.RemoteException
theXmlFileName
- The name of the file containing a fuzzy XML document.
public java.lang.Object[] resolveArgs(java.lang.Object[] theArgs) throws AbleParException
theArgs
- Arguments to a sensor or an effector.
public java.lang.String rlString()
public java.lang.String xmlString()
public boolean isBaseTraceActive()
AbleParTrace.isActive()
public AbleParTrace getBaseTraceObject()
public AbleParTrace getInfrTraceObject()
|
ABLE, Version 1.1b | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |