net.sourceforge.jFuzzyLogic.rule
Class FuzzyRuleSet

java.lang.Object
  extended by net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet

public class FuzzyRuleSet
extends java.lang.Object

A set of fuzzy rules

Author:
pcingola@users.sourceforge.net

Field Summary
static boolean debug
          Debug mode?
(package private)  RuleImplicationMethod ruleImplicationMethod
          Rule implication method
(package private)  java.util.LinkedList<FuzzyRule> rules
          A list of rules
(package private)  java.util.LinkedList<Variable> variables
          Every variable is listed here
 
Constructor Summary
FuzzyRuleSet()
           
 
Method Summary
 FuzzyRuleSet add(FuzzyRule fuzzyRule)
          Add a rule to this ruleSet
 void chart()
          Show a chart for each variable in this ruleSet
 void evaluate()
          Evaluate fuzzy rule set
 java.lang.String fclTree(antlr.collections.AST tree)
          Buils rule set based on FCL tree (parsed from an FCL file)
private  Variable fclTreeDefuzzify(antlr.collections.AST tree)
          Parse a tree for "Defuzzify" item
private  Variable fclTreeFuzzify(antlr.collections.AST tree)
          Parse a tree for "Fuzzify" item
private  LinguisticTerm fclTreeFuzzifyTerm(antlr.collections.AST tree, Variable variable)
          Parse a tree for "Term" item
private  MembershipFunction fclTreeFuzzifyTermGauss(antlr.collections.AST tree)
          Parse a tree for gaussian memebership function
private  MembershipFunction fclTreeFuzzifyTermGenBell(antlr.collections.AST tree)
          Parse a tree for generilized bell memebership function
private  MembershipFunction fclTreeFuzzifyTermPieceWiseLinear(antlr.collections.AST tree)
          Parse a tree for piece-wice linear memebership function
private  MembershipFunction fclTreeFuzzifyTermPieceWiseLinearPoints(antlr.collections.AST tree, int numberOfPoints)
          Parse a tree for piece-wice linear memebership function series of points
private  MembershipFunction fclTreeFuzzifyTermSigmoidal(antlr.collections.AST tree)
          Parse a tree for sigmoidal memebership function
private  MembershipFunction fclTreeFuzzifyTermSingleton(antlr.collections.AST tree)
          Parse a tree for piece-wice linear memebership function item
private  MembershipFunction fclTreeFuzzifyTermSingletons(antlr.collections.AST tree)
          Parse a tree for singletons memebership function
private  MembershipFunction fclTreeFuzzifyTermSingletonsPoints(antlr.collections.AST tree, int numberOfPoints)
          Parse a tree for singletons memebership function series of points
private  MembershipFunction fclTreeFuzzifyTermTrapetzoidal(antlr.collections.AST tree)
          Parse a tree for trapetzoidal memebership function
private  MembershipFunction fclTreeFuzzifyTermTriangular(antlr.collections.AST tree)
          Parse a tree for traingular memebership function
private  void fclTreeRuleBlock(antlr.collections.AST tree)
           
private  void fclTreeRuleBlockActivation(antlr.collections.AST tree)
          Parse rule Implication Method (or rule activation method)
private  void fclTreeRuleBlockRule(antlr.collections.AST tree, RuleConnectionMethod and, RuleConnectionMethod or)
          Parse rule Implication Method (or rule activation method)
private  FuzzyRuleExpression fclTreeRuleBlockRuleIf(antlr.collections.AST tree, RuleConnectionMethod and, RuleConnectionMethod or)
          Parse rule 'IF' (or rule's weight)
private  void fclTreeRuleBlockRuleThen(antlr.collections.AST tree, FuzzyRule fuzzyRule)
          Parse rule 'THEN' (or rule's weight)
private  void fclTreeRuleBlockRuleWith(antlr.collections.AST tree, FuzzyRule fuzzyRule)
          Parse rule 'WITH' (or rule's weight)
private  void fclTreeVariables(antlr.collections.AST tree)
          Parse a tree for "Variable" item (either input or output variables)
 RuleImplicationMethod getRuleImplicationMethod()
           
 java.util.LinkedList getRules()
           
 Variable getVariable(java.lang.String variableName)
          Get Variable by name
 java.util.LinkedList<Variable> getVariables()
           
static boolean isDebug()
           
 void reset()
          Reset ruleset (should be done prior to each inference) Also create 'variables' list (if needed)
static void setDebug(boolean debug)
           
 void setRuleImplicationMethod(RuleImplicationMethod ruleImplicationMethod)
           
 void setRules(java.util.LinkedList<FuzzyRule> rules)
           
 FuzzyRuleSet setVariable(java.lang.String variableName, double value)
          Set a variable
 void setVariables(java.util.LinkedList<Variable> consequentVariables)
           
 java.lang.String toString()
           
 java.lang.String toStringFCL()
           
 boolean varibleExists(java.lang.String variableName)
          Does this variable exist in this ruleset?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static boolean debug
Debug mode?


ruleImplicationMethod

RuleImplicationMethod ruleImplicationMethod
Rule implication method


rules

java.util.LinkedList<FuzzyRule> rules
A list of rules


variables

java.util.LinkedList<Variable> variables
Every variable is listed here

Constructor Detail

FuzzyRuleSet

public FuzzyRuleSet()
Method Detail

isDebug

public static boolean isDebug()

setDebug

public static void setDebug(boolean debug)

add

public FuzzyRuleSet add(FuzzyRule fuzzyRule)
Add a rule to this ruleSet

Parameters:
fuzzyRule - : Rule to add
Returns:
this

chart

public void chart()
Show a chart for each variable in this ruleSet


evaluate

public void evaluate()
Evaluate fuzzy rule set


fclTree

public java.lang.String fclTree(antlr.collections.AST tree)
Buils rule set based on FCL tree (parsed from an FCL file)

Parameters:
tree - : Tree to use
Returns:
: RuleSet's name (or "" if no name)

fclTreeDefuzzify

private Variable fclTreeDefuzzify(antlr.collections.AST tree)
Parse a tree for "Defuzzify" item

Parameters:
tree - : Tree to parse
Returns:
Variable (old or created)

fclTreeFuzzify

private Variable fclTreeFuzzify(antlr.collections.AST tree)
Parse a tree for "Fuzzify" item

Parameters:
tree - : Tree to parse
Returns:
Variable (old or created)

fclTreeFuzzifyTerm

private LinguisticTerm fclTreeFuzzifyTerm(antlr.collections.AST tree,
                                          Variable variable)
Parse a tree for "Term" item

Parameters:
tree - : Tree to parse
Returns:
A new LinguisticTerm

fclTreeFuzzifyTermGauss

private MembershipFunction fclTreeFuzzifyTermGauss(antlr.collections.AST tree)
Parse a tree for gaussian memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermGenBell

private MembershipFunction fclTreeFuzzifyTermGenBell(antlr.collections.AST tree)
Parse a tree for generilized bell memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermPieceWiseLinear

private MembershipFunction fclTreeFuzzifyTermPieceWiseLinear(antlr.collections.AST tree)
Parse a tree for piece-wice linear memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermPieceWiseLinearPoints

private MembershipFunction fclTreeFuzzifyTermPieceWiseLinearPoints(antlr.collections.AST tree,
                                                                   int numberOfPoints)
Parse a tree for piece-wice linear memebership function series of points

Parameters:
tree - : Tree to parse
numberOfPoints - : Number of points in this function
Returns:
A new membership function

fclTreeFuzzifyTermSigmoidal

private MembershipFunction fclTreeFuzzifyTermSigmoidal(antlr.collections.AST tree)
Parse a tree for sigmoidal memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermSingleton

private MembershipFunction fclTreeFuzzifyTermSingleton(antlr.collections.AST tree)
Parse a tree for piece-wice linear memebership function item

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermSingletons

private MembershipFunction fclTreeFuzzifyTermSingletons(antlr.collections.AST tree)
Parse a tree for singletons memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermSingletonsPoints

private MembershipFunction fclTreeFuzzifyTermSingletonsPoints(antlr.collections.AST tree,
                                                              int numberOfPoints)
Parse a tree for singletons memebership function series of points

Parameters:
tree - : Tree to parse
numberOfPoints - : Number of points in this function
Returns:
A new membership function

fclTreeFuzzifyTermTrapetzoidal

private MembershipFunction fclTreeFuzzifyTermTrapetzoidal(antlr.collections.AST tree)
Parse a tree for trapetzoidal memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeFuzzifyTermTriangular

private MembershipFunction fclTreeFuzzifyTermTriangular(antlr.collections.AST tree)
Parse a tree for traingular memebership function

Parameters:
tree - : Tree to parse
Returns:
A new membership function

fclTreeRuleBlock

private void fclTreeRuleBlock(antlr.collections.AST tree)

fclTreeRuleBlockActivation

private void fclTreeRuleBlockActivation(antlr.collections.AST tree)
Parse rule Implication Method (or rule activation method)

Parameters:
tree - : Tree to parse

fclTreeRuleBlockRule

private void fclTreeRuleBlockRule(antlr.collections.AST tree,
                                  RuleConnectionMethod and,
                                  RuleConnectionMethod or)
Parse rule Implication Method (or rule activation method)

Parameters:
tree - : Tree to parse

fclTreeRuleBlockRuleIf

private FuzzyRuleExpression fclTreeRuleBlockRuleIf(antlr.collections.AST tree,
                                                   RuleConnectionMethod and,
                                                   RuleConnectionMethod or)
Parse rule 'IF' (or rule's weight)

Parameters:
tree - : Tree to parse

fclTreeRuleBlockRuleThen

private void fclTreeRuleBlockRuleThen(antlr.collections.AST tree,
                                      FuzzyRule fuzzyRule)
Parse rule 'THEN' (or rule's weight)

Parameters:
tree - : Tree to parse

fclTreeRuleBlockRuleWith

private void fclTreeRuleBlockRuleWith(antlr.collections.AST tree,
                                      FuzzyRule fuzzyRule)
Parse rule 'WITH' (or rule's weight)

Parameters:
tree - : Tree to parse

fclTreeVariables

private void fclTreeVariables(antlr.collections.AST tree)
Parse a tree for "Variable" item (either input or output variables)

Parameters:
tree -

getRuleImplicationMethod

public RuleImplicationMethod getRuleImplicationMethod()

getRules

public java.util.LinkedList getRules()

getVariable

public Variable getVariable(java.lang.String variableName)
Get Variable by name


getVariables

public java.util.LinkedList<Variable> getVariables()

reset

public void reset()
Reset ruleset (should be done prior to each inference) Also create 'variables' list (if needed)


setRuleImplicationMethod

public void setRuleImplicationMethod(RuleImplicationMethod ruleImplicationMethod)

setRules

public void setRules(java.util.LinkedList<FuzzyRule> rules)

setVariable

public FuzzyRuleSet setVariable(java.lang.String variableName,
                                double value)
Set a variable

Parameters:
variableName - : Variable's name
value - : variable's value to be setted
Returns:
this

setVariables

public void setVariables(java.util.LinkedList<Variable> consequentVariables)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringFCL

public java.lang.String toStringFCL()

varibleExists

public boolean varibleExists(java.lang.String variableName)
Does this variable exist in this ruleset?