infosapient.system
Class FzyKnowledgebase

java.lang.Object
  |
  +--infosapient.system.ObservableImpl
        |
        +--infosapient.system.FzySystemComponent
              |
              +--infosapient.system.FzyKnowledgebase

public class FzyKnowledgebase
extends FzySystemComponent
implements Observer, XMLOutput, java.io.Serializable

Class FzyKnowledgebase is the repository for all of the information about this problem domain.

It contains the Rules, Attributes, and Sets for the domain described.

Version:
$Revision: 1.1.1.1 $
See Also:
Serialized Form

Field Summary
private  java.util.Hashtable attribClauseDictionary
           
private  java.util.Hashtable attributeDictionary
           
private  java.lang.String authorFirstName
           
private  java.lang.String authorLastName
           
private  boolean backChain
          Whether to back chain or not.
private  java.util.Hashtable deducingRules
           
private  java.lang.String def_String
           
private  FzyResolutionMethod defuzzmethod
          How fuzzySet is defuzzified
private  java.lang.String description
           
private  FzyCorrelation fzycorrmethod
          Correlation method for variable
private  FzyImplicationMethod fzyimplmethod
          Implication Method for fuzzy logic
private  FzyAttribute goalAttribute
          The attribute that we are attempting to determine the value of (defuzzify).
private  java.io.File myFile
           
private  java.lang.String name
           
private  java.util.Hashtable referringRules
           
private  java.util.Hashtable ruleDictionary
           
private  boolean runBefore
          Boolean to determine whether to run the unconditional rules BEFORE/AFTER the conditional rules have run.
(package private) static long serialVersionUID
           
private  java.util.Hashtable solutionSetDict
           
private  java.util.Hashtable unconditionalRuleDict
           
private  java.lang.String value
          current value
private  java.lang.String writtenDate
           
 
Fields inherited from class infosapient.system.FzySystemComponent
DEBUG_, myID, name, pcs, serialVersionUID, trace, vcs
 
Fields inherited from class infosapient.system.ObservableImpl
arr, changed, obs, serialVersionUID
 
Constructor Summary
FzyKnowledgebase()
          Default constructor for FzyKnowledgebase.
FzyKnowledgebase(java.lang.String aname)
           
 
Method Summary
 boolean addAttribute(FzyAttribute anAttrib)
           
 void addConseqClause(FzyAttribClause aac)
          Add an attribClause to the attribClause table.
 boolean addRule(FzyRule aRule)
           
private  boolean addUnconditionalRule(FzyUnconditionalRule aUncRule)
           
 java.util.Enumeration attributeKeys()
           
 java.util.Hashtable attributes()
           
 void attributes(java.util.Hashtable attribDict)
           
 boolean containsAttribute(java.lang.String attribName)
          Return true if the knowledgebase contains an attribute of name: attribName.
 boolean containsRule(java.lang.String ruleName)
           
 boolean containsSetGiven(java.lang.String attribName, java.lang.String setName)
          Return true if the knowledgebase contains an attribute of name: attribName AND the attribute contains a set named: setName.
 java.util.Enumeration deducingRulesKeys()
           
 java.lang.String description()
           
 void description(java.lang.String desc)
           
 FzyAttribute getAttribute(java.lang.String withKey)
          Return the named FzyAttribute
 java.util.Enumeration getAttributeSetNames()
          Return the set names within this knowledgebase Creation date: (04/14/01 1:58:04 PM)
 java.lang.String getAuthorFirstName()
          Insert the method's description here.
 java.lang.String getAuthorLastName()
          Insert the method's description here.
 java.util.Vector getConseqClauses(FzyAttribute fa)
          Get vector of all consequents that determine given FzyAttribute
 FzyCorrelation getCorrelationMethod()
           
 java.lang.String getCorrelationMethodName()
           
 java.util.Hashtable getDeducingAttributes(FzyAttribute goalAttrib, java.util.Hashtable attribs)
          Return all attributes that are used as parameters to deduce the goal attribute.
 java.util.Hashtable getDeducingRules()
           
 java.util.Vector getDeducingRulesFor(FzyAttribute attrib)
          Return a vector of all rules that refer to this attribute within the rules consequent.
 java.lang.String getDescription()
           
 java.io.File getFile()
          returns the file that is used to store this KB
 FzyAttribute getGoal()
          Return the current Goal of this knowledgebase.
 FzyImplicationMethod getImplicationMethod()
           
 java.lang.String getImplicationMethodName()
           
 java.util.Vector getReferringRulesFor(FzyAttribute attrib)
          Return a vector of all rules that refer to this attribute within the rules premise.
 FzyResolutionMethod getResolutionMethod()
           
 java.lang.String getResolutionMethodName()
           
 FzyRule getRule(java.lang.String rNameAsKey)
           
 java.util.Hashtable getSolutionSetDictionary()
           
 FzySystemComponent getTypeForName(java.lang.String aName)
          Return the type based on the name given.
 java.lang.String getWrittenDate()
          Insert the method's description here.
 boolean isBackwardChain()
           
 boolean isRunBefore()
           
 void printOn(java.io.Writer outWriter, int nTabs)
           
 java.util.Hashtable referringRules()
           
 void referringRules(java.util.Hashtable rr)
           
 java.util.Enumeration referringRulesKeys()
           
 void removeAttribute(FzyAttribute attrib)
          Delete the indicated Attribute.
 void removeReferringRulesGivenSet(FzySet fs)
          Remove all rules that refer to the specified set.
 void removeRule(FzyRule r)
          Remove a rule from the rules dictionary, and each vector pointed to by the FzyAttribute in the Hashtables 'referringRules' and 'deducingRules'
 void reset()
          Resets the knowledgebase so that a new consultation session can begin.
private  FzyAttribClause[] returnAllAttribClausesFor(FzyOperator fo)
          Return an array of FzyAttribClauses given a FzyOperator Creation date: (1/28/00 12:45:57 PM)
 java.util.Enumeration ruleKeys()
           
 java.util.Hashtable rules()
           
 void rules(java.util.Hashtable dictionary)
           
 void setAuthorFirstName(java.lang.String newAuthorFirstName)
          Insert the method's description here.
 void setAuthorLastName(java.lang.String newAuthorLastName)
          Insert the method's description here.
 void setCorrelationMethod(FzyCorrelation fcm)
           
 void setCorrelationMethod(java.lang.String name)
          set the correlation method using a name of a class default to FzyCorrelationMinimum on error
 void setDeducingRules(java.util.Hashtable dr)
           
 void setDescription(java.lang.String desc)
           
 void setFile(java.io.File f)
          sets the file used to store this KB.
 void setGoalAttribute(FzyAttribute theGoal)
           
 void setImplicationMethod(FzyImplicationMethod fim)
           
 void setImplicationMethod(java.lang.String name)
          set the implication method using a name of a class default to FzyImplicationMINMAX on error
 void setName(java.lang.String kbn)
          Sets the name of the knowledgbase
 void setResolutionMethod(FzyResolutionMethod frm)
          Set the Resolution method for this Knowledgebase.
 void setResolutionMethod(java.lang.String name)
          set the resolution method using a name of a class default to FzyResolutionCENTROID on error
 void setRunBefore(boolean f)
          Declare unconditional rules to be run before unconditional rules.(Default)
 void setSolutionSetDictionary(java.util.Hashtable ssDict)
           
 void setWrittenDate(java.lang.String newWrittenDate)
          Insert the method's description here.
 java.lang.StringBuffer toXML(int nTabs)
          Represent this knowledgebase as XML tagged nodes.
 java.util.Enumeration unconditionalRuleKeys()
           
 java.util.Hashtable unconditionalRules()
           
 void update(Observable fso, java.lang.Object obj)
          Notifications of objects that this KB is observing.
 
Methods inherited from class infosapient.system.FzySystemComponent
addPropertyChangeListener, addVetoableChangeListener, equals, getID, getName, getPropertyChangeSupport, getVetoableChangeSupport, hashCode, removePropertyChangeListener, removeVetoableChangeListener, setID
 
Methods inherited from class infosapient.system.ObservableImpl
addObserver, clearChanged, containsObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID

myFile

private java.io.File myFile

value

private java.lang.String value
current value

def_String

private java.lang.String def_String

authorFirstName

private java.lang.String authorFirstName

authorLastName

private java.lang.String authorLastName

writtenDate

private java.lang.String writtenDate

solutionSetDict

private java.util.Hashtable solutionSetDict

referringRules

private java.util.Hashtable referringRules

deducingRules

private java.util.Hashtable deducingRules

ruleDictionary

private java.util.Hashtable ruleDictionary

unconditionalRuleDict

private java.util.Hashtable unconditionalRuleDict

attributeDictionary

private java.util.Hashtable attributeDictionary

defuzzmethod

private FzyResolutionMethod defuzzmethod
How fuzzySet is defuzzified

fzycorrmethod

private FzyCorrelation fzycorrmethod
Correlation method for variable

fzyimplmethod

private FzyImplicationMethod fzyimplmethod
Implication Method for fuzzy logic

runBefore

private boolean runBefore
Boolean to determine whether to run the unconditional rules BEFORE/AFTER the conditional rules have run.

backChain

private final boolean backChain
Whether to back chain or not. Currently only supports backchaining.

goalAttribute

private FzyAttribute goalAttribute
The attribute that we are attempting to determine the value of (defuzzify).

name

private java.lang.String name

description

private java.lang.String description

attribClauseDictionary

private java.util.Hashtable attribClauseDictionary
Constructor Detail

FzyKnowledgebase

public FzyKnowledgebase()
Default constructor for FzyKnowledgebase.

FzyKnowledgebase

public FzyKnowledgebase(java.lang.String aname)
Parameters:
String - The knowledgebase name.
Method Detail

addAttribute

public boolean addAttribute(FzyAttribute anAttrib)

addConseqClause

public void addConseqClause(FzyAttribClause aac)
Add an attribClause to the attribClause table. this is used to determine which attribClauses are used to determine the attribute of interest.
Parameters:
FzyAttribClause - the attribute clause to be added.

addRule

public boolean addRule(FzyRule aRule)

addUnconditionalRule

private boolean addUnconditionalRule(FzyUnconditionalRule aUncRule)

attributeKeys

public java.util.Enumeration attributeKeys()

attributes

public java.util.Hashtable attributes()

attributes

public void attributes(java.util.Hashtable attribDict)

containsAttribute

public boolean containsAttribute(java.lang.String attribName)
Return true if the knowledgebase contains an attribute of name: attribName.
Parameters:
String - - attribName
Returns:
boolean true if attribName is the name of an attribute.

containsRule

public boolean containsRule(java.lang.String ruleName)

containsSetGiven

public boolean containsSetGiven(java.lang.String attribName,
                                java.lang.String setName)
Return true if the knowledgebase contains an attribute of name: attribName AND the attribute contains a set named: setName.
Parameters:
String - - attribName
String - - setName
Returns:
boolean true if attribName is the name of an attribute containing the named set.

deducingRulesKeys

public java.util.Enumeration deducingRulesKeys()

description

public java.lang.String description()

description

public void description(java.lang.String desc)

getAttribute

public FzyAttribute getAttribute(java.lang.String withKey)
                          throws java.lang.IllegalArgumentException
Return the named FzyAttribute
Parameters:
the - name of the fuzzy attribute - String
Returns:
the FzyAttribute - FzyAttribute
Throws:
java.lang.IllegalArgumentException - if the name is null

getAttributeSetNames

public java.util.Enumeration getAttributeSetNames()
Return the set names within this knowledgebase Creation date: (04/14/01 1:58:04 PM)
Returns:
java.util.Enumeration

getAuthorFirstName

public java.lang.String getAuthorFirstName()
Insert the method's description here. Creation date: (02/12/01 3:46:02 PM)
Returns:
java.lang.String

getAuthorLastName

public java.lang.String getAuthorLastName()
Insert the method's description here. Creation date: (02/12/01 3:46:02 PM)
Returns:
java.lang.String

getConseqClauses

public java.util.Vector getConseqClauses(FzyAttribute fa)
Get vector of all consequents that determine given FzyAttribute
Parameters:
FzyAttribute - -- FzyAttribute key to consequents
Returns:
Vector -- consequent clauses (ASTAttribClause)

getCorrelationMethod

public FzyCorrelation getCorrelationMethod()

getCorrelationMethodName

public java.lang.String getCorrelationMethodName()

getDeducingAttributes

public java.util.Hashtable getDeducingAttributes(FzyAttribute goalAttrib,
                                                 java.util.Hashtable attribs)
Return all attributes that are used as parameters to deduce the goal attribute.
Parameters:
goalAttrib - infosapient.system.FzyAttribute
attribs - java.util.Hashtable

getDeducingRules

public java.util.Hashtable getDeducingRules()

getDeducingRulesFor

public java.util.Vector getDeducingRulesFor(FzyAttribute attrib)
Return a vector of all rules that refer to this attribute within the rules consequent.
Returns:
Vector - all deducing rules.
Throws:
java.lang.IllegalArgumentException - - if the attribute is null.

getDescription

public java.lang.String getDescription()

getFile

public java.io.File getFile()
returns the file that is used to store this KB

getGoal

public FzyAttribute getGoal()
Return the current Goal of this knowledgebase.
Returns:
goal -- the FzyAttribute goal.

getImplicationMethod

public FzyImplicationMethod getImplicationMethod()

getImplicationMethodName

public java.lang.String getImplicationMethodName()

getReferringRulesFor

public java.util.Vector getReferringRulesFor(FzyAttribute attrib)
Return a vector of all rules that refer to this attribute within the rules premise.
Returns:
Vector - all referring rules.
Throws:
java.lang.IllegalArgumentException - - if the attribute is null.

getResolutionMethod

public FzyResolutionMethod getResolutionMethod()

getResolutionMethodName

public java.lang.String getResolutionMethodName()

getRule

public FzyRule getRule(java.lang.String rNameAsKey)

getSolutionSetDictionary

public java.util.Hashtable getSolutionSetDictionary()

getTypeForName

public FzySystemComponent getTypeForName(java.lang.String aName)
Return the type based on the name given. Creation date: (04/02/01 10:18:39 AM)
Parameters:
aName - java.lang.String
Returns:
infosapient.system.FzySystemComponent - the type for the name found. (null if not found.)

getWrittenDate

public java.lang.String getWrittenDate()
Insert the method's description here.
Returns:
java.lang.String

isBackwardChain

public boolean isBackwardChain()

isRunBefore

public boolean isRunBefore()
Returns:
runBefore - flag to denote whether unconditional rules are to be run before (true) or after conditional rules.

printOn

public void printOn(java.io.Writer outWriter,
                    int nTabs)
             throws java.io.IOException
Overrides:
printOn in class FzySystemComponent

referringRules

public java.util.Hashtable referringRules()

referringRules

public void referringRules(java.util.Hashtable rr)

referringRulesKeys

public java.util.Enumeration referringRulesKeys()

removeAttribute

public void removeAttribute(FzyAttribute attrib)
                     throws java.lang.IllegalArgumentException,
                            java.lang.IllegalStateException
Delete the indicated Attribute. Warning: this method will perform a cascading delete on ALL references to this attribute including rules.
Parameters:
FzyAttribute - -- the attribute to be removed from the knowledgebase.
Throws:
java.lang.IllegalArgumentException - -- thrown if attribute is null.
java.lang.IllegalStateException - -- thrown if the attribute is not in the attribute dictionary.

removeReferringRulesGivenSet

public void removeReferringRulesGivenSet(FzySet fs)
                                  throws java.lang.IllegalArgumentException
Remove all rules that refer to the specified set. Used when a set is removed from an attribute. Creation date: (1/28/00 9:58:30 AM)
Parameters:
fs - infosapient.system.FzySet
Throws:
java.lang.IllegalArgumentException - If the argument is null.

removeRule

public void removeRule(FzyRule r)
                throws java.lang.IllegalArgumentException
Remove a rule from the rules dictionary, and each vector pointed to by the FzyAttribute in the Hashtables 'referringRules' and 'deducingRules'
Parameters:
the - rule to be removed - FzyRule
Throws:
java.lang.IllegalArgumentException - if the rule is null

reset

public void reset()
Resets the knowledgebase so that a new consultation session can begin.

returnAllAttribClausesFor

private FzyAttribClause[] returnAllAttribClausesFor(FzyOperator fo)
                                             throws java.lang.IllegalArgumentException
Return an array of FzyAttribClauses given a FzyOperator Creation date: (1/28/00 12:45:57 PM)
Parameters:
fo - infosapient.opr.FzyOperator
Returns:
infosapient.system.FzyAttribClause[]
Throws:
java.lang.IllegalArgumentException - If FzyOperator is null.

ruleKeys

public java.util.Enumeration ruleKeys()

rules

public java.util.Hashtable rules()

rules

public void rules(java.util.Hashtable dictionary)

setAuthorFirstName

public void setAuthorFirstName(java.lang.String newAuthorFirstName)
Insert the method's description here. Creation date: (02/12/01 3:46:02 PM)
Parameters:
newAuthorFirstName - java.lang.String

setAuthorLastName

public void setAuthorLastName(java.lang.String newAuthorLastName)
Insert the method's description here. Creation date: (02/12/01 3:46:02 PM)
Parameters:
newAuthorLastName - java.lang.String

setCorrelationMethod

public void setCorrelationMethod(java.lang.String name)
set the correlation method using a name of a class default to FzyCorrelationMinimum on error

setCorrelationMethod

public void setCorrelationMethod(FzyCorrelation fcm)

setDeducingRules

public void setDeducingRules(java.util.Hashtable dr)

setDescription

public void setDescription(java.lang.String desc)

setFile

public void setFile(java.io.File f)
sets the file used to store this KB.
Parameters:
f - -- the java.io.File that contains this KB

setGoalAttribute

public void setGoalAttribute(FzyAttribute theGoal)
                      throws java.lang.IllegalArgumentException
Parameters:
FzyAttribute - the goal attribute.

setImplicationMethod

public void setImplicationMethod(java.lang.String name)
set the implication method using a name of a class default to FzyImplicationMINMAX on error

setImplicationMethod

public void setImplicationMethod(FzyImplicationMethod fim)

setName

public void setName(java.lang.String kbn)
Sets the name of the knowledgbase
Overrides:
setName in class FzySystemComponent

setResolutionMethod

public void setResolutionMethod(java.lang.String name)
set the resolution method using a name of a class default to FzyResolutionCENTROID on error

setResolutionMethod

public void setResolutionMethod(FzyResolutionMethod frm)
Set the Resolution method for this Knowledgebase.
Parameters:
FzyResolutionMethod - -- the method object used to defuzzify the goal solution set.
See Also:
FzyResolutionMethod

setRunBefore

public void setRunBefore(boolean f)
Declare unconditional rules to be run before unconditional rules.(Default)
Parameters:
f - - boolean value

setSolutionSetDictionary

public void setSolutionSetDictionary(java.util.Hashtable ssDict)

setWrittenDate

public void setWrittenDate(java.lang.String newWrittenDate)
Insert the method's description here.
Parameters:
newWrittenDate - java.lang.String

toXML

public java.lang.StringBuffer toXML(int nTabs)
Represent this knowledgebase as XML tagged nodes. Creation date: (1/30/00 4:46:34 PM)
Specified by:
toXML in interface XMLOutput
Returns:
java.lang.StringBuffer

unconditionalRuleKeys

public java.util.Enumeration unconditionalRuleKeys()

unconditionalRules

public java.util.Hashtable unconditionalRules()

update

public void update(Observable fso,
                   java.lang.Object obj)
Notifications of objects that this KB is observing. Currently the only action it takes is to forward events to this KB observers.
Specified by:
update in interface Observer

License to use this program is provided under the TERMS OF THE COMMON PUBLIC LICENSE 0.5. ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

Copyright (c) 2001, Workplace Performance Tools, All Rights Reserved