rule
Class BooleanRuleBase

java.lang.Object
  |
  +--rule.BooleanRuleBase

public class BooleanRuleBase
extends java.lang.Object
implements RuleBase

The BooleanRuleBase class implements a set of rules and rule variables along with methods for forward and backward chaining.


Field Summary
(package private)  Clause clausePtr
           
(package private)  Clause[] clauseVarList
           
(package private)  java.util.Vector conclusionVarList
           
(package private)  java.util.Hashtable effectors
           
(package private)  java.util.Vector factList
           
(package private)  java.util.Stack goalClauseStack
           
(package private)  java.lang.String name
           
(package private)  java.util.Vector ruleList
           
(package private)  Rule rulePtr
           
(package private)  java.util.Hashtable sensors
           
(package private)  javax.swing.JTextArea textArea1
           
(package private)  java.util.Hashtable variableList
           
 
Constructor Summary
BooleanRuleBase(java.lang.String name)
          Creates a BooleanRuleBase with the given name.
 
Method Summary
 void addEffector(java.lang.Object obj, java.lang.String effectorName)
          Adds an effector and effector name to the rule base.
 void addFact(Fact fact)
          Adds a fact to this rule base.
 void addSensor(java.lang.Object obj, java.lang.String sensorName)
          Adds a sensor and sensor name to the rule base.
 void addVariable(RuleVariable variable)
          Adds a variable to this rule base
 void backwardChain(java.lang.String goalVarName)
          Determines if the given goal is true by finding the set of rules that refer to the goal in their consequent clause and then testing the antecedent clauses to determine if the rule should fire.
 void displayConflictSet(java.util.Vector ruleSet)
          Dislays all rules in the conflict set.
 void displayRules(javax.swing.JTextArea textArea)
          Displays all the rules and facts in text format in the given text area.
 void displayVariables(javax.swing.JTextArea textArea)
          Displays all variables and their values in the given text area.
 void forwardChain()
          Fires rules, generating new data, based on the initial set of data.
 java.lang.Object getEffectorObject(java.lang.String effectorName)
          Retrieves the effector associated with the given name.
 java.util.Vector getGoalVariables()
          Retreives all the variables referenced in the consequent of any rule in the rule base.
 java.lang.Object getSensorObject(java.lang.String sensorName)
          Retrieves the sensor associated with the given name.
 RuleVariable getVariable(java.lang.String name)
          Retrives the variable associated with the given name.
 java.util.Hashtable getVariables()
          Retrieves the list of variables.
 void initializeFacts()
          Initializes the facts associated with this rule base.
 java.util.Vector match(boolean test)
          Finds the set of rules that can fire when forward chaining.
 void reset()
          Resets the rule base for another round of inferencing.
 Rule selectRule(java.util.Vector ruleSet)
          Selects a rule to fire when forward chaining, based on specificity.
 void setDisplay(javax.swing.JTextArea txtArea)
          Sets the text area for the display of information.
 void setVariableValue(java.lang.String name, java.lang.String value)
          Sets the value of the variable associated with the given name.
 void trace(java.lang.String text)
          Adds the given text to the trace information.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

java.lang.String name

variableList

java.util.Hashtable variableList

clauseVarList

Clause[] clauseVarList

ruleList

java.util.Vector ruleList

conclusionVarList

java.util.Vector conclusionVarList

rulePtr

Rule rulePtr

clausePtr

Clause clausePtr

goalClauseStack

java.util.Stack goalClauseStack

effectors

java.util.Hashtable effectors

sensors

java.util.Hashtable sensors

factList

java.util.Vector factList

textArea1

javax.swing.JTextArea textArea1
Constructor Detail

BooleanRuleBase

public BooleanRuleBase(java.lang.String name)
Creates a BooleanRuleBase with the given name.
Parameters:
name - the String that contains the name of the rule base
Method Detail

setDisplay

public void setDisplay(javax.swing.JTextArea txtArea)
Sets the text area for the display of information.
Specified by:
setDisplay in interface RuleBase
Parameters:
txtArea - the JTextArea to be used for the display of information

trace

public void trace(java.lang.String text)
Adds the given text to the trace information.
Specified by:
trace in interface RuleBase
Parameters:
text - the String that contains the text to be displayed as part of the trace information

displayVariables

public void displayVariables(javax.swing.JTextArea textArea)
Displays all variables and their values in the given text area.
Specified by:
displayVariables in interface RuleBase
Parameters:
textArea - the JTextArea where the variables and their values are displayed

displayRules

public void displayRules(javax.swing.JTextArea textArea)
Displays all the rules and facts in text format in the given text area.
Specified by:
displayRules in interface RuleBase
Parameters:
textArea - the JTextArea where the rules and facts are displayed

displayConflictSet

public void displayConflictSet(java.util.Vector ruleSet)
Dislays all rules in the conflict set.
Parameters:
ruleSet - the Vector that contains the conflict set of rules

reset

public void reset()
Resets the rule base for another round of inferencing.
Specified by:
reset in interface RuleBase

backwardChain

public void backwardChain(java.lang.String goalVarName)
Determines if the given goal is true by finding the set of rules that refer to the goal in their consequent clause and then testing the antecedent clauses to determine if the rule should fire. If an antecedent clause cannot be tested because a variable is unknown, that variable becomes the new goal variable and the process recurses until the given goal is found to be true or false.
Specified by:
backwardChain in interface RuleBase
Parameters:
goalVarName - the String that contains the name fo the goal variable

match

public java.util.Vector match(boolean test)
Finds the set of rules that can fire when forward chaining.
Parameters:
test - the boolean value that determines if the antecedents should be tested (true) or just checked (false)
Returns:
the Vector of rules that can fire

selectRule

public Rule selectRule(java.util.Vector ruleSet)
Selects a rule to fire when forward chaining, based on specificity.
Parameters:
ruleSet - the Vector of rules that can fire
Returns:
the selected rule

forwardChain

public void forwardChain()
Fires rules, generating new data, based on the initial set of data. The process repeats with the new data until no more rules and be fired.
Specified by:
forwardChain in interface RuleBase

addEffector

public void addEffector(java.lang.Object obj,
                        java.lang.String effectorName)
Adds an effector and effector name to the rule base.
Parameters:
obj - the Object that contains the effector
effectorName - the String that contains the name of the effector

getEffectorObject

public java.lang.Object getEffectorObject(java.lang.String effectorName)
Retrieves the effector associated with the given name.
Parameters:
effectorName - the String that contains the name of the effector to be be retrieved
Returns:
the effector object associated with the given name

addSensor

public void addSensor(java.lang.Object obj,
                      java.lang.String sensorName)
Adds a sensor and sensor name to the rule base.
Parameters:
obj - the Object that contains the sensor
sensorName - the String that contains the name of the sensor

getSensorObject

public java.lang.Object getSensorObject(java.lang.String sensorName)
Retrieves the sensor associated with the given name.
Parameters:
sensorName - the String that contains the name of the sensor to be be retrieved
Returns:
the sensor object associated with the given name

initializeFacts

public void initializeFacts()
Initializes the facts associated with this rule base.

addFact

public void addFact(Fact fact)
Adds a fact to this rule base.
Parameters:
fact - the Fact to be added to the rule base

addVariable

public void addVariable(RuleVariable variable)
Adds a variable to this rule base
Parameters:
variable - the Variable to be added to the rule base

getVariables

public java.util.Hashtable getVariables()
Retrieves the list of variables.
Returns:
a Hashtable object that contains the list of variables defined in this ruleset

getGoalVariables

public java.util.Vector getGoalVariables()
Retreives all the variables referenced in the consequent of any rule in the rule base.
Specified by:
getGoalVariables in interface RuleBase
Returns:
the Vector that contains the goal variables

getVariable

public RuleVariable getVariable(java.lang.String name)
Retrives the variable associated with the given name.
Parameters:
name - the String that contains the name of the variable
Returns:
the variable associated with the given name

setVariableValue

public void setVariableValue(java.lang.String name,
                             java.lang.String value)
Sets the value of the variable associated with the given name.
Parameters:
name - the String that contains the name of the variable
value - the String object that contains
Returns:
the variable associated with the given name