ABLE, Version 1.1b

com.ibm.able.beans.fuzzy
Class FsRuleSet

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

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

This class defines the Fuzzy System "RuleSet" class.

The FsRuleSet object is the primary interface into the Fuzzy System. Through an FsRuleSet object you can create variables, fuzzy sets, and rules, and then perform inferencing with the rules to solve problems. Input data and solution data are read from and written to program buffers so that an FsRuleSet can be embedded in other objects.

There are two ways to instantiate a fuzzy system ruleset. The first is to write a fuzzy program using the defined fuzzy rule language, and then ask an FsRuleSet object to instantiate itself from that source file. The second way is to use the methods of FsRuleSet to create an instantiated object programatically.

Once a ruleset is successfully instantiated, you can call the process() method to perform inferencing and obtain a solution.

Version:
$Revision: 1.8 $, $Date: 2000/09/12 16:31:02 $
See Also:
Serialized Form

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
FsRuleSet()
          Create a new fuzzy system ruleset.
FsRuleSet(FsTrace theBaseTracer, FsTrace theInferenceTracer)
          Create a new fuzzy system ruleset.
 
Method Summary
 void addAntecedentToRule(java.lang.Integer theRuleId, java.lang.String theRuleLabel, java.lang.String theClauseVarLhs, int theClauseOperator, java.lang.String theClauseHedges, java.lang.String theClauseValue, int theClauseValueType, double theClauseWeight, java.util.Vector theCallParms)
          Create an antecedent (if) clause from the specified bits, and add the clause to the specified rule.
 void addBetaSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtCenter, double theSetFlexFactor, double theSetWeight)
          Create a new beta fuzzy set and add it to the specified continuous variable.
 void addComplementSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, java.lang.String theSetNameComplement)
          Create the complement of a previously created fuzzy set and add it to the specified continuous variable.
 void addConsequentToRule(java.lang.Integer theRuleId, java.lang.String theRuleLabel, java.lang.String theClauseVarLhs, int theClauseOperator, java.lang.String theClauseHedges, java.lang.String theClauseValue, int theClauseValueType, java.util.Vector theCallParms)
          Create a consequent (then) clause from the specified bits, and add the clause to the specified rule.
 void addEffector(AbleEffector theAbleEffector)
          Add an effector to the list of managed effectors.
 void addFuzzyChangeListener(java.beans.PropertyChangeListener theListener)
          Add a property change listener to the ruleset.
 void addGaussianSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtCenter, double theSetWidthFactor)
          Create a new gaussian fuzzy set and add it to the specified continuous variable.
 void addLinearSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtBegin, double theSetPtEnd, int theSetDirection)
          Create a new linear fuzzy set and add it to the specified continuous variable.
 void addPiSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtCenter, double theSetWidth)
          Create a new pi fuzzy set and add it to the specified continuous variable.
 void addSegmentsSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, int theNumberOfSegments, double[] theScalarVector, double[] theTruthVector)
          Create a new segments fuzzy set and add it to the specified continuous variable.
 void addSensor(AbleSensor theAbleSensor)
          Add a sensor to the list of managed sensors.
 void addShoulderSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtBegin, double theSetPtEnd, int theSetDirection)
          Create a new shoulder fuzzy set and add it to the specified continuous variable.
 void addSigmoidSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtBegin, double theSetPtEnd, double theSetPtFlex, int theSetDirection)
          Create a new sigmoid fuzzy set and add it to the specified continuous variable.
 void addTrapezoidSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtLeft, double theSetPtLeftCore, double theSetPtRightCore, double theSetPtRight)
          Create a new trapezoid fuzzy set and add it to the specified continuous variable.
 void addTriangleSetToContinuousVariable(java.lang.String theVariableName, java.lang.String theSetName, double theAlphaCut, double theSetPtLeft, double theSetPtCenter, double theSetPtRight)
          Create a new triangle fuzzy set and add it to the specified continuous variable.
 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 clear()
          Clear the ruleset of all variables and rules, clear out the trace logs, set the ruleset name to the empty string (""), and set all ruleset options (alphacut, correlation method, and so on) to default values.
 boolean conditionalRuleIdExists(java.lang.Integer theRuleId)
          Determine whether any rule in the ruleset contains the specified key.
static java.lang.String Copyright()
          Determine the copyright of this class.
 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.
 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.
 double getAlphaCut()
          Retrieve the current alphacut threshold.
 FsTrace getBaseTraceObject()
          Retrieve the base tracer object.
 int getCorrelationMethod()
          Retrieve the current correlation method.
 java.util.Hashtable getDefinedEffectors()
          Get defined effectors.
 java.util.Hashtable getDefinedSensors()
          Get defined sensors.
 int getDefuzzifyMethod()
          Retrieve the current defuzzification method.
 java.util.Hashtable getEffectors()
          Get all effectors registered with this effector manager.
 int getInferenceMethod()
          Retrieve the current inference method.
 FsTrace getInfrTraceObject()
          Retrieve the inferencing tracer object.
 java.util.BitSet getInitialFactBase()
          Retrieve the initial fact base.
 int getNumOutputVars()
          Retrieve the number of output variables.
 java.util.Vector getOutputVars()
          Retrieve the output variables.
 java.util.Hashtable getRules()
          Retrieve the list of rules.
 java.lang.String getRuleSetName()
          Retrieve the name of the ruleset.
 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 getVariables()
          Retrieve the list of variables.
 void instantiateFrom(java.io.DataInputStream theStream, FsTrace theTracer, boolean theStopOnFsExceptionFlag)
          Instantiate the ruleset object by reading a fuzzy system rule source file contained in the specified input stream.
 void instantiateFrom(java.lang.String theFileName, FsTrace theTracer, boolean theStopOnFsExceptionFlag)
          Instantiate the ruleset object by reading a fuzzy system rule source file contained in the specified input file.
 void instantiateFromXml(java.io.File theFile, FsTrace theTracer, boolean theStopOnFsExceptionFlag)
          Instantiate the ruleset object by reading a fuzzy system XML document contained in the specified input file.
 void instantiateFromXml(java.io.InputStream theInputStream, FsTrace theTracer, boolean theStopOnFsExceptionFlag)
          Instantiate the ruleset object by reading a fuzzy system XML document contained in the specified input stream.
 java.lang.Object invokeEffector(java.lang.String theEffectorName, java.lang.Object[] theArgs)
          Call the method that the effector name represents, passing in the array of argument objects.
 java.lang.Object invokeSensor(java.lang.String theSensorName, java.lang.Object[] theArgs)
          Call the method that the sensor name represents, passing in the 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.
 boolean isInferencingTraceActive()
          Determine whether inference tracing is on.
 void makeBooleanVariable(java.lang.String theVariableName, boolean theBooleanValue)
          Create a boolean variable, give it an initial value, and add it to the ruleset.
 java.lang.Integer makeConditionalRule(java.lang.String theRuleLabel)
          Create a conditional rule (that is, an if-then rule) with the specified label, and add the rule to the ruleset.
 void makeContinuousVariable(java.lang.String theVariableName, double theLoValue, double theHiValue)
          Create a continuous (or fuzzy) variable over a range of values and add it to the ruleset.
 void makeNumericVariable(java.lang.String theVariableName, double theNumericValue)
          Create a numeric variable, give it an initial value, and add it to the ruleset.
 void makeSymbolicVariable(java.lang.String theVariableName, java.util.Hashtable theSymbolList)
          Create a symbolic variable and add it to the ruleset.
 void makeUnconditionalRule(java.lang.String theRuleLabel, java.lang.String theRuleVarLhs, int theRuleOperator, java.lang.String theRuleHedges, java.lang.String theRuleValue, int theRuleValueType, java.util.Vector theCallParms)
          Create an unconditional rule (that is, an assertion) from the specified bits, and add the rule to the ruleset.
 void process()
          Perform the standard processing function performed by this object.
 void process(java.util.Hashtable theInputBuffer, java.util.Hashtable theOutputBuffer)
          Fire the rules in the ruleset.
 void removeEffector(java.lang.String theEffectorName)
          Remove an effector from the list of managed effectors.
 void removeFuzzyChangeListener(java.beans.PropertyChangeListener theListener)
          Remove a property change listener from the ruleset.
 void removeSensor(java.lang.String theSensorName)
          Remove a sensor from the list of managed sensors.
 void reset()
          Reset the ruleset so that rules can be fired again.
 java.util.Vector resolveArgs(java.util.Vector theVariableNames)
          Given a list of variable names, return a list of those names resolved to actual variable references.
 java.lang.String rlString()
          Return a formal fuzzy rule language string.
 boolean ruleLabelAlreadyExists(java.lang.String theRuleLabel)
          Determine whether any rule in the ruleset contains the specified label.
 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 setAlphaCut(double theAlphaCut)
          Set the alphacut threshold to the specified value.
 void setBaseTraceActive(boolean theTraceValue)
          Turn ruleset tracing on or off.
 void setCorrelationMethod(int theCorrelationMethod)
          Set the correlation method to the specified type.
 void setDefuzzifyMethod(int theDefuzzifyMethod)
          Set the defuzzification method to the specified type.
 void setEffectors(java.util.Hashtable theAbleEffectors)
          Set all effectors for this manager.
 void setInferenceMethod(int theInferenceMethod)
          Set the inference method to the specified type.
 void setInferencingTraceActive(boolean theTraceValue)
          Turn inference tracing on or off.
 void setRuleSetName(java.lang.String theRuleSetName)
          Specify the name of the ruleset.
 void setSensors(java.util.Hashtable theAbleSensors)
          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 setXmlFileName(java.lang.String theXmlFileName)
          Specify the name of the XML document file for this ruleset.
 java.lang.String toString()
          Retrieve a string describing (the contents of) the object.
 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.
 boolean variableNamesAlreadyExist(java.util.Vector theVariableNames)
          Determine whether variables with the specified names exist within the ruleset.
 java.lang.String xmlString()
          Return a formal XML fuzzy document string.
 
Methods inherited from class com.ibm.able.AbleObject
addAbleEventListener, addDestBufferConnection, addPropertyChangeListener, addPropertyConnection, addSourceBufferConnection, addStateChangeListener, 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, 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
 
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
 

Constructor Detail

FsRuleSet

public FsRuleSet()
          throws java.rmi.RemoteException
Create a new fuzzy system ruleset.

FsRuleSet

public FsRuleSet(FsTrace theBaseTracer,
                 FsTrace theInferenceTracer)
          throws java.rmi.RemoteException
Create a new fuzzy system ruleset.
Parameters:
theBaseTracer - A trace object, used by the ruleset to record interactions with other objects.

theInferenceTracer - A trace object, used by the ruleset to record information during the inferencing process.

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:
FsException - When any Fs error occurs.

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

reset

public void reset()
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

addEffector

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

See Also:
removeEffector(java.lang.String)

removeEffector

public void removeEffector(java.lang.String theEffectorName)
                    throws java.rmi.RemoteException
Remove an effector from the list of managed effectors.
Specified by:
removeEffector in interface AbleEffectorManager
Parameters:
theEffectorName - 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 theEffectorName,
                                       java.lang.Object[] theArgs)
                                throws java.rmi.RemoteException,
                                       java.lang.NoSuchMethodException,
                                       java.lang.reflect.InvocationTargetException,
                                       java.lang.IllegalAccessException,
                                       java.lang.SecurityException
Call the method that the effector name represents, passing in the array of argument objects.
Specified by:
invokeEffector in interface AbleEffectorManager
Parameters:
theEffectorName - The name of the effector containing an encapsulated method.

theArgs - An array of arguments that the method expects.

Returns:
The invoked method's return value.
See Also:
addEffector(com.ibm.able.beans.AbleEffector), setEffectors(java.util.Hashtable)

getEffectors

public java.util.Hashtable getEffectors()
                                 throws java.rmi.RemoteException
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 theAbleEffectors)
                  throws java.rmi.RemoteException
Set all effectors for this manager.
Specified by:
setEffectors in interface AbleEffectorManager
Parameters:
theAbleEffectors - 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()

addSensor

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

See Also:
removeSensor(java.lang.String)

removeSensor

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

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

invokeSensor

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

theArgs - An array of arguments that the method expects.

Returns:
The invoked method's return value.
See Also:
addSensor(com.ibm.able.beans.AbleSensor), setSensors(java.util.Hashtable)

getSensors

public java.util.Hashtable getSensors()
                               throws java.rmi.RemoteException
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 theAbleSensors)
                throws java.rmi.RemoteException
Set all sensors for this manager.
Specified by:
setSensors in interface AbleSensorManager
Parameters:
theAbleSensors - 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()

instantiateFrom

public void instantiateFrom(java.io.DataInputStream theStream,
                            FsTrace theTracer,
                            boolean theStopOnFsExceptionFlag)
                     throws FsException,
                            antlr.ParserException,
                            java.io.IOException
Instantiate the ruleset object by reading a fuzzy system 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, fuzzy sets, 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:
FsException - On any fuzzy system 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,
                            FsTrace theTracer,
                            boolean theStopOnFsExceptionFlag)
                     throws FsException,
                            antlr.ParserException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Instantiate the ruleset object by reading a fuzzy system 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, fuzzy sets, 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:
FsException - On any fuzzy system 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,
                               FsTrace theTracer,
                               boolean theStopOnFsExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               FsException,
                               org.xml.sax.SAXException,
                               java.io.IOException
Instantiate the ruleset object by reading a fuzzy system 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, fuzzy sets, 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:
FsException - On any fuzzy system 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,
                               FsTrace theTracer,
                               boolean theStopOnFsExceptionFlag)
                        throws java.lang.IllegalAccessException,
                               java.lang.InstantiationException,
                               java.lang.ClassNotFoundException,
                               FsException,
                               org.xml.sax.SAXException,
                               java.io.FileNotFoundException,
                               java.io.IOException
Instantiate the ruleset object by reading a fuzzy system 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, fuzzy sets, 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 an XML document is read.

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

Throws:
FsException - On any fuzzy system 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.


setRuleSetName

public void setRuleSetName(java.lang.String theRuleSetName)
                    throws FsException
Specify the name of the ruleset.
Parameters:
theRuleSetName - The new name of the ruleset.

Throws:
FsException - If the name is null or an empty string.

See Also:
getRuleSetName()

getRuleSetName

public java.lang.String getRuleSetName()
Retrieve the name of the ruleset.
Returns:
The current name of the ruleset.

See Also:
setRuleSetName(java.lang.String)

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 Fuzzy RuleSet Customizer program. When the customizer is told to save the source rules, this method is called so that the source file object may be temporarily saved across customizer sessions. Then, when the user selects "customize" from the Able Editor, the fuzzy customizer will be able to retrieve the file object and reload the source rule file.

If there is no source rule file, the customizer 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 fuzzy 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.


setAlphaCut

public void setAlphaCut(double theAlphaCut)
                 throws FsException
Set the alphacut threshold to the specified value.
Parameters:
theAlphaCut - The new alphacut threshold.

Throws:
FsException - If the specified alphacut value is not between 0.0 (exclusive) and 1.0 (exclusive).

See Also:
getAlphaCut()

getAlphaCut

public double getAlphaCut()
Retrieve the current alphacut threshold.
Returns:
The current alphacut.

See Also:
setAlphaCut(double)

setCorrelationMethod

public void setCorrelationMethod(int theCorrelationMethod)
                          throws FsException
Set the correlation method to the specified type.
Parameters:
theCorrelationMethod - The new correlation method. Correlation methods are enumerated in class Fs.

Throws:
FsException - If the specified correlation method is not recognised.

See Also:
getCorrelationMethod(), Fs.Product, Fs.Minimise

getCorrelationMethod

public int getCorrelationMethod()
Retrieve the current correlation method.
Returns:
The current correlation method.

See Also:
setCorrelationMethod(int)

setDefuzzifyMethod

public void setDefuzzifyMethod(int theDefuzzifyMethod)
                        throws FsException
Set the defuzzification method to the specified type.
Parameters:
theDefuzzifyMethod - The new defuzzification method. Defuzzification methods are enumerated in class Fs.

Throws:
FsException - If the specified defuzzification method is not recognised.

See Also:
getDefuzzifyMethod(), Fs.Centroid, Fs.MaxHeight

getDefuzzifyMethod

public int getDefuzzifyMethod()
Retrieve the current defuzzification method.
Returns:
The current defuzzification method.

See Also:
setDefuzzifyMethod(int)

setInferenceMethod

public void setInferenceMethod(int theInferenceMethod)
                        throws FsException
Set the inference method to the specified type.
Parameters:
theInferenceMethod - The new inference method. Inference methods are enumerated in class Fs.

Throws:
FsException - If the specified inference method is not recognised.

See Also:
getInferenceMethod(), Fs.FuzzyAdd, Fs.MinMax, Fs.ProductOr

getInferenceMethod

public int getInferenceMethod()
Retrieve the current inference method.
Returns:
The current inference method.

See Also:
setInferenceMethod(int)

makeBooleanVariable

public void makeBooleanVariable(java.lang.String theVariableName,
                                boolean theBooleanValue)
                         throws FsException
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:
FsException - If a variable with the specified name already exists.

See Also:
reset()

makeContinuousVariable

public void makeContinuousVariable(java.lang.String theVariableName,
                                   double theLoValue,
                                   double theHiValue)
                            throws FsException
Create a continuous (or fuzzy) 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. Continuous variables may be given an initial "crisp" value, but during inferencing, the value of a continuous variable represents a fuzzy number within the universe of discourse. After inferencing, a crisp value can once again be obtained from the fuzzy value.

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:
FsException - If a variable with the specified name already exists.


makeNumericVariable

public void makeNumericVariable(java.lang.String theVariableName,
                                double theNumericValue)
                         throws FsException
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:
FsException - If a variable with the specified name already exists.

See Also:
reset()

makeSymbolicVariable

public void makeSymbolicVariable(java.lang.String theVariableName,
                                 java.util.Hashtable theSymbolList)
                          throws FsException
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:
FsException - If a variable with the specified name already exists.


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.


variableNamesAlreadyExist

public boolean variableNamesAlreadyExist(java.util.Vector theVariableNames)
Determine whether variables with the specified names exist within the ruleset.
Parameters:
theVariableNames - A list of names of variables that might exist.

Returns:
true if all variables with the specified list exist 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.


getVariables

public java.util.Hashtable getVariables()
Retrieve the list of variables.
Returns:
A list of variables defined in this ruleset.


resolveArgs

public java.util.Vector resolveArgs(java.util.Vector theVariableNames)
Given a list of variable names, return a list of those names resolved to actual variable references.
Parameters:
theVariableNames - A list of names of variables that are known to exist. Note that this list must have been validated before calling this method!

Returns:
A list of FsVar references.


addBetaSetToContinuousVariable

public void addBetaSetToContinuousVariable(java.lang.String theVariableName,
                                           java.lang.String theSetName,
                                           double theAlphaCut,
                                           double theSetPtCenter,
                                           double theSetFlexFactor,
                                           double theSetWeight)
                                    throws FsException
Create a new beta fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtCenter - Specifies the point on which the fuzzy set is to be centered. This point must be within the universe of discourse for the specified continuous variable.

theSetFlexFactor - The distance from the center point to the curve's inflexion point at the 0.5 truth value.

theSetWeight - A number, 0.1 to 1.0, that can attenuate the shape of the set. The default is 1.0, which means that set is unchanged. The lower the number, the flatter the shape.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String)

addComplementSetToContinuousVariable

public void addComplementSetToContinuousVariable(java.lang.String theVariableName,
                                                 java.lang.String theSetName,
                                                 java.lang.String theSetNameComplement)
                                          throws FsException
Create the complement of a previously created fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of an existing fuzzy set that is to be complemented.

theSetNameComplement - The name of the newly created complement fuzzy set. This name must not already exist for the continuous variable.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the complement set is already taken by another fuzzy set, or (4) the specified base set doesn't exist. There are various other reasons as well.


addGaussianSetToContinuousVariable

public void addGaussianSetToContinuousVariable(java.lang.String theVariableName,
                                               java.lang.String theSetName,
                                               double theAlphaCut,
                                               double theSetPtCenter,
                                               double theSetWidthFactor)
                                        throws FsException
Create a new gaussian fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtCenter - Specifies the point on which the fuzzy set is to be centered. This point must be within the universe of discourse for the specified continuous variable.

theSetWidthFactor - Influences the width of the curve; typical values are from 0.9 to 5, inclusive.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String)

addLinearSetToContinuousVariable

public void addLinearSetToContinuousVariable(java.lang.String theVariableName,
                                             java.lang.String theSetName,
                                             double theAlphaCut,
                                             double theSetPtBegin,
                                             double theSetPtEnd,
                                             int theSetDirection)
                                      throws FsException
Create a new linear fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtBegin - The point at which the line is to begin. This point must be within the universe of discourse for the specified continuous variable.

theSetPtEnd - The point at which the line is to end. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtBegin.

Note that it is not possible to define a set that is a perfectly vertical line, but one can specify points that are very close together. Note also, that due to the way truth values are stored, care must be taken that the points aren't too close together.

theSetDirection - Whether the line is to slope up or down. If the line slopes up, the beginning point (and all points to the left) will have a truth value of 0.0 and the end point (and all points to the right) will have a truth value of 1.0. If the line slopes down, the truth values are reversed. Set directions are enumerated in class Fs.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String), addShoulderSetToContinuousVariable(java.lang.String, java.lang.String, double, double, double, int), Fs.Up, Fs.Down

addPiSetToContinuousVariable

public void addPiSetToContinuousVariable(java.lang.String theVariableName,
                                         java.lang.String theSetName,
                                         double theAlphaCut,
                                         double theSetPtCenter,
                                         double theSetWidth)
                                  throws FsException
Create a new pi fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtCenter - Specifies the point on which the fuzzy set is to be centered. This point must be within the universe of discourse for the specified continuous variable.

theSetWidth - Specifies the width of the curve from the center point to an endpoint at the 0.0 truth value.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String)

addSegmentsSetToContinuousVariable

public void addSegmentsSetToContinuousVariable(java.lang.String theVariableName,
                                               java.lang.String theSetName,
                                               double theAlphaCut,
                                               int theNumberOfSegments,
                                               double[] theScalarVector,
                                               double[] theTruthVector)
                                        throws FsException
Create a new segments fuzzy set and add it to the specified continuous variable.

This type of fuzzy set lets you draw any type of curve desired; however, the number of points is limited to the value contained in Fs.MaxValues. You draw the set by specifying a series of points and their truth values. Lines are interpolated between the specified scalar points.

Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theNumberOfSegments - Specifies the number of points and their truth values.

theScalarVector - Specifies an array of points between which lines are interpolated. Each point in the array must be greater than the previous point. The size of this array must be equal to theNumberOfSegments.

theTruthVector - Specifies, for each scalar in theScalarVector, the truth value at that location. The size of this array must be equal to theNumberOfSegments.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String), Fs.MaxValues

addShoulderSetToContinuousVariable

public void addShoulderSetToContinuousVariable(java.lang.String theVariableName,
                                               java.lang.String theSetName,
                                               double theAlphaCut,
                                               double theSetPtBegin,
                                               double theSetPtEnd,
                                               int theSetDirection)
                                        throws FsException
Create a new shoulder fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtBegin - The point at which the line is to begin. This point must be within the universe of discourse for the specified continuous variable.

theSetPtEnd - The point at which the line is to end. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtBegin.

theSetDirection - Whether the shoulder is a left shoulder or a right shoulder. Left shoulders slope down, right shoulders slope up. Set directions are enumerated in class Fs.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String), addLinearSetToContinuousVariable(java.lang.String, java.lang.String, double, double, double, int), Fs.Left, Fs.Right

addSigmoidSetToContinuousVariable

public void addSigmoidSetToContinuousVariable(java.lang.String theVariableName,
                                              java.lang.String theSetName,
                                              double theAlphaCut,
                                              double theSetPtBegin,
                                              double theSetPtEnd,
                                              double theSetPtFlex,
                                              int theSetDirection)
                                       throws FsException
Create a new sigmoid fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtBegin - The point at which the sigmoidal curve is to begin. This point must be within the universe of discourse for the specified continuous variable.

theSetPtEnd - The point at which the sigmoidal curve is to end. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtBegin.

theSetPtFlex - The point at which the sigmoidal curve is to flex. This point must be within the universe of discourse for the specified continuous variable. The value must be between the values for theSetPtBegin and theSetPtEnd.

theSetDirection - Whether the sigmoidal curve is to slope up or down. If the curve slopes up, the beginning point (and all points to the left) will have a truth value of 0.0 and the end point (and all points to the right) will have a truth value of 1.0. If the curve slopes down, the truth values are reversed. Set directions are enumerated in class Fs.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String), Fs.Up, Fs.Down

addTrapezoidSetToContinuousVariable

public void addTrapezoidSetToContinuousVariable(java.lang.String theVariableName,
                                                java.lang.String theSetName,
                                                double theAlphaCut,
                                                double theSetPtLeft,
                                                double theSetPtLeftCore,
                                                double theSetPtRightCore,
                                                double theSetPtRight)
                                         throws FsException
Create a new trapezoid fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtLeft - The point at which the lower left corner of the trapezoid is placed. This point must be within the universe of discourse for the specified continuous variable.

theSetPtLeftCore - The point at which the upper left corner of the trapezoid is placed. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtLeft.

theSetPtRightCore - The point at which the upper right corner of the trapezoid is placed. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtLeftCore.

theSetPtRight - The point at which the lower right corner of the trapezoid is placed. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtRightCore.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String)

addTriangleSetToContinuousVariable

public void addTriangleSetToContinuousVariable(java.lang.String theVariableName,
                                               java.lang.String theSetName,
                                               double theAlphaCut,
                                               double theSetPtLeft,
                                               double theSetPtCenter,
                                               double theSetPtRight)
                                        throws FsException
Create a new triangle fuzzy set and add it to the specified continuous variable.
Parameters:
theVariableName - The name of the continuous variable that is to have a new fuzzy set added to it.

theSetName - The name of the new fuzzy set. This name must not already exist for the continuous variable.

theAlphaCut - The alphacut for the newly created fuzzy set.

---------------------------------

theSetPtLeft - The point at which the lower left corner of the triangle is placed. This point must be within the universe of discourse for the specified continuous variable.

theSetPtCenter - The point at which the upper point of the triangle is placed. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtLeft.

theSetPtRight - The point at which the lower right corner of the triangle is placed. This point must be within the universe of discourse for the specified continuous variable. The value must be greater than the value for theSetPtCenter.

Throws:
FsException - (1) If a variable with the specified name doesn't exist, (2) if the specified variable isn't a continuous variable, (3) if the name of the fuzzy set is already taken by another fuzzy set, or (4) any alphacut value, set point, width, or weight is out of range. There are various other reasons as well.

See Also:
addComplementSetToContinuousVariable(java.lang.String, java.lang.String, java.lang.String)

addVariableToInputSequence

public void addVariableToInputSequence(java.lang.String theVariableName)
                                throws FsException
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:
FsException - If a variable with the specified name doesn't exist.

See Also:
process()

addVariableToOutputSequence

public void addVariableToOutputSequence(java.lang.String theVariableName)
                                 throws FsException
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:
FsException - 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.


makeUnconditionalRule

public void makeUnconditionalRule(java.lang.String theRuleLabel,
                                  java.lang.String theRuleVarLhs,
                                  int theRuleOperator,
                                  java.lang.String theRuleHedges,
                                  java.lang.String theRuleValue,
                                  int theRuleValueType,
                                  java.util.Vector theCallParms)
                           throws FsException
Create an unconditional rule (that is, an assertion) from the specified bits, and add the rule to the ruleset.

Examples:

 rs.makeUnconditionalRule("label1", "myBooleanVariable",    Fs.AsgnEq, "",  "false", Fs.ValueTypeBoolean);
 rs.makeUnconditionalRule("label2", "myContinuousVariable", Fs.AsgnIs, "V", "Hot",   Fs.ValueTypeSetName);
 rs.makeUnconditionalRule("label3", "myNumericVariable",    Fs.AsgnEq, "",  "3.141", Fs.ValueTypeNumber);
 rs.makeUnconditionalRule("label4", "mySymbolicVariable",   Fs.AsgnEq, "",  "abc",   Fs.ValueTypeName);
 rs.makeUnconditionalRule("",       "myNumericVariable",    Fs.AsgnEq, "",  "myOtherNumericVar", Fs.ValueTypeName);
 
Parameters:
theRuleLabel - A human readable label, or tag, for the rule. The label can be the empty string (""), but it must not be null. If a label other than the empty string is given, the label must be unique among all rules. Labels appear in traces and exceptions.

theRuleVarLhs - The lefthand side of the rule. Currently, this must be the name of an existing variable.

theRuleOperator - The relation connecting the left- and righthand sides of the rule. For assertions, this may be only an assignment type of relation. Relations are enumerated in class FsOp (see below).

theRuleHedges - If theRuleOperator is a fuzzy assignment operator and theRuleValue is a fuzzy set, this can be a list of hedges to be applied to the fuzzy set. Hedges are enumerated in class Fs (see below).

If hedges are not used in the rule, theRuleHedges must be the empty string (""), and not null.

theRuleValue - The righthand side of the rule. Depending on the lefthand side of the rule, this can be a boolean literal ("true" or "false"), a numeric literal (for example, "6.5275"), a symbolic literal (for example, "abc"), the name of a variable, or the name of a fuzzy set.

theRuleValueType - Indicates the type of the string specified in theRuleValue above. Value types are enumerated in class Fs (see below).

Throws:
FsException - For many conditions.

See Also:
FsOp, FsOp.AsgnEq, FsOp.AsgnIs, Fs, Fs.ValueTypeBoolean, Fs.ValueTypeName, Fs.ValueTypeNumber, Fs.ValueTypeSetName

makeConditionalRule

public java.lang.Integer makeConditionalRule(java.lang.String theRuleLabel)
                                      throws FsException
Create a conditional rule (that is, an if-then rule) with the specified label, and add the rule to the ruleset.

Note that this rule has no antededent or consequent clauses and cannot be fired until such clauses are added to the rule using the returned rule key.

Parameters:
theRuleLabel - A human readable label, or tag, for the rule. The label can be the empty string (""), but it must not be null. If a label other than the empty string is given, the label must be unique among all rules. Labels appear in traces and exceptions.

Returns:
An integer object, which is an internal key to the rule. This key must be used to add antecedent and consequent clauses to the rule before the rule is processed (fired).

Throws:
FsException - For many conditions.

See Also:
addAntecedentToRule(java.lang.Integer, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, int, double, java.util.Vector), addConsequentToRule(java.lang.Integer, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, int, java.util.Vector)

getRules

public java.util.Hashtable getRules()
Retrieve the list of rules.
Returns:
A list of rules defined in this ruleset.


addAntecedentToRule

public void addAntecedentToRule(java.lang.Integer theRuleId,
                                java.lang.String theRuleLabel,
                                java.lang.String theClauseVarLhs,
                                int theClauseOperator,
                                java.lang.String theClauseHedges,
                                java.lang.String theClauseValue,
                                int theClauseValueType,
                                double theClauseWeight,
                                java.util.Vector theCallParms)
                         throws FsException
Create an antecedent (if) clause from the specified bits, and add the clause to the specified rule.

Note that there is no limit to the number of antecedent clauses for a rule, and that all antecedent clauses are connected by "and". "Or" capability can be achieved by left factoring.

Parameters:
theRuleId - The key to a conditional rule; the key must have been obtained from makeConditionalRule().

theRuleLabel - A human readable label, or tag, for the rule. The label must match the original label for the rule identified by the rule Id.

theClauseVarLhs - The lefthand side of the clause. Currently, this must be the name of an existing variable.

theClauseOperator - The relation connecting the left- and righthand sides of the clause. This may be any type of comparison relation. Relations are enumerated in class FsOp (see below).

theClauseHedges - If theClauseOperator is a fuzzy assignment operator and theClauseValue is a fuzzy set, this can be a list of hedges to be applied to the fuzzy set. Hedges are enumerated in class Fs (see below).

If hedges are not used in the rule, theClauseHedges must be the empty string (""), and not null.

theClauseValue - The righthand side of the clause. Depending on the lefthand side of the clause, this can be a boolean literal ("true" or "false"), a numeric literal (for example, "6.5275"), a symbolic literal (for example, "abc"), the name of a variable, or the name of a fuzzy set.

theClauseValueType - Indicates the type of the string specified in theClauseValue above. Value types are enumerated in class Fs (see below).

theClauseWeight - Specifies the weight the clause should be given when it evaluates to "true". You normally wouldn't use this for fuzzy clauses, but as boolean clauses can skew the outcome (they evaluate to 1.0 when true) you can use theClauseWeight to soften the influence of boolean clauses when mixed with fuzzy clauses.

Throws:
FsException - For many conditions.

See Also:
FsOp, FsOp.CmpEq, FsOp.CmpIs, Fs, Fs.ValueTypeBoolean, Fs.ValueTypeName, Fs.ValueTypeNumber, Fs.ValueTypeSetName, makeConditionalRule(java.lang.String)

addConsequentToRule

public void addConsequentToRule(java.lang.Integer theRuleId,
                                java.lang.String theRuleLabel,
                                java.lang.String theClauseVarLhs,
                                int theClauseOperator,
                                java.lang.String theClauseHedges,
                                java.lang.String theClauseValue,
                                int theClauseValueType,
                                java.util.Vector theCallParms)
                         throws FsException
Create a consequent (then) clause from the specified bits, and add the clause to the specified rule.

Note that currently a rule may have only one consequent. If this method is called multiple times, the current clause is replaced by the new one.

Parameters:
theRuleId - The key to a conditional rule; the key must have been obtained from makeConditionalRule().

theRuleLabel - A human readable label, or tag, for the rule. The label must match the original label for the rule identified by the rule Id.

theClauseVarLhs - The lefthand side of the clause. Currently, this must be the name of an existing variable.

theClauseOperator - The relation connecting the left- and righthand sides of the clause. This may be any type of comparison relation. Relations are enumerated in class FsOp (see below).

theClauseHedges - If theClauseOperator is a fuzzy assignment operator and theClauseValue is a fuzzy set, this can be a list of hedges to be applied to the fuzzy set. Hedges are enumerated in class Fs (see below).

If hedges are not used in the rule, theClauseHedges must be the empty string (""), and not null.

theClauseValue - The righthand side of the clause. Depending on the lefthand side of the clause, this can be a boolean literal ("true" or "false"), a numeric literal (for example, "6.5275"), a symbolic literal (for example, "abc"), the name of a variable, or the name of a fuzzy set.

theClauseValueType - Indicates the type of the string specified in theClauseValue above. Value types are enumerated in class Fs (see below).

theClauseWeight - Specifies the weight the clause should be given when it evaluates to "true". You normally wouldn't use this for fuzzy clauses, but as boolean clauses can skew the outcome (they evaluate to 1.0 when true) you can use theClauseWeight to soften the influence of boolean clauses when mixed with fuzzy clauses.

Throws:
FsException - For many conditions.

See Also:
FsOp, FsOp.CmpEq, FsOp.CmpIs, Fs, Fs.ValueTypeBoolean, Fs.ValueTypeName, Fs.ValueTypeNumber, Fs.ValueTypeSetName, makeConditionalRule(java.lang.String)

ruleLabelAlreadyExists

public boolean ruleLabelAlreadyExists(java.lang.String theRuleLabel)
Determine whether any rule in the ruleset contains the specified label.

Note that all rule labels within a ruleset must be unique.

Parameters:
theRuleLabel - Any string that might be a rule label.

Returns:
true if the specified label appears on any rule in the ruleset; false otherwise.


conditionalRuleIdExists

public boolean conditionalRuleIdExists(java.lang.Integer theRuleId)
Determine whether any rule in the ruleset contains the specified key.

Note that a unique key is created for each rule when a rule is added to the ruleset..

Parameters:
theRuleId - The key to be checked.

Returns:
true if a rule with the specified key exists in the ruleset; false otherwise.


getInitialFactBase

public java.util.BitSet getInitialFactBase()
Retrieve the initial fact base.
Returns:
Working memory as it exists at the start of inferencing.


defineEffector

public void defineEffector(java.lang.String theEffectorName)
                    throws FsException
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 FsException
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.


process

public void process(java.util.Hashtable theInputBuffer,
                    java.util.Hashtable theOutputBuffer)
             throws FsException
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. The ruleset is reset. (See below.)
  3. All assertions are fired.
  4. Variables identified in the input sequence are assigned values from the input buffer.
  5. Conditional rules are fired until they quiesce.
  6. Values of variables identified in the output sequence are written to the output buffer.
Parameters:
theInputBuffer - The key to each element in the input buffer is a String containing the name of a variable. The object associated with each key must be a Boolean, Double, or String object which will become the value of the named variable.

theOutputBuffer - is an empty hashtable to which variable names and their values will be written when inferencing is complete.

Note that any elements in this hashtable will be cleared before output is written to it.

Throws:
FsException - When any Fs error occurs.

See Also:
isExecutable(), reset()

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.
  5. The ruleset has a valid name!
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.


clear

public void clear()
Clear the ruleset of all variables and rules, clear out the trace logs, set the ruleset name to the empty string (""), and set all ruleset options (alphacut, correlation method, and so on) to default values.

rlString

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


xmlString

public java.lang.String xmlString()
Return a formal XML fuzzy document string.
Returns:
A String describing the object in XML.


getBaseTraceObject

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


getInfrTraceObject

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


setBaseTraceActive

public void setBaseTraceActive(boolean theTraceValue)
Turn ruleset tracing on or off. When ruleset tracing is on, messages are written to the FsTrace object indicating when variables and rules are created and updated, or when any ruleset option changes. Messages relating to inferencing or parsing are not logged.
Parameters:
theTraceValue - Use true to turn tracing on, false to turn it off.

See Also:
FsTrace, isBaseTraceActive()

isBaseTraceActive

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

See Also:
FsTrace.isActive()

setInferencingTraceActive

public void setInferencingTraceActive(boolean theTraceValue)
Turn inference tracing on or off. When inference tracing is on, messages are written to the FsTrace object indicating which rules fired and their results.
Parameters:
theTraceValue - Use true to turn tracing on, false to turn it off.

See Also:
FsTrace, isBaseTraceActive()

isInferencingTraceActive

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

See Also:
FsTrace.isActive()

addFuzzyChangeListener

public void addFuzzyChangeListener(java.beans.PropertyChangeListener theListener)
Add a property change listener to the ruleset. The listener is notified when any changes occur to the ruleset itself, and also when any changes occur to variables, rules, or fuzzy set solution areas.
Parameters:
theListener - Any property change listener.

See Also:
AbleObject.removePropertyChangeListener(java.beans.PropertyChangeListener)

removeFuzzyChangeListener

public void removeFuzzyChangeListener(java.beans.PropertyChangeListener theListener)
Remove a property change listener from the ruleset.
Parameters:
theListener - Any previously added property change listener.

See Also:
AbleObject.addPropertyChangeListener(java.beans.PropertyChangeListener)

toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Returns:
A String containing the current contents of the object.

Overrides:
toString in class AbleObject

Copyright

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


ABLE, Version 1.1b

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