public class RuleBase
extends java.lang.Object
Represents a FRBS (Fuzzy Rule Base System). A FRBS is composed of: -content: the consequents of the rules (each rule has an index to partition array) -partitions: the antecedents for each rule. -partition: the consequents shared by all the rules.
Modifier and Type | Field and Description |
---|---|
static int |
DEFUZCDM
Defuzzification by mass center.
|
static int |
DEFUZMAX
Defuzzification by maximum.
|
static int |
product
Product configuration flag.
|
static int |
sum
Sum configuration flag.
|
Constructor and Description |
---|
RuleBase(FuzzyPartition[] pe,
FuzzyPartition ps,
int tn,
int ag)
A constructor for a RuleBase.
|
RuleBase(RuleBase b)
A copy constructor for a RuleBase, given other RuleBase.
|
Modifier and Type | Method and Description |
---|---|
void |
addRules(long[] rules,
FuzzyRule[] rules2)
Adds new rules to BaseRule.
|
RuleBase |
clone()
Creates and returns a copy of this object.
|
long |
codifyAntecents(double[] example)
This method finds out the label with maximum membership value for each variable.
|
void |
debug()
Prints the results.
|
double |
defuzzify(double[] output,
int IDDEFUZZIFY)
Defuzzifies output using method IDDEFUZZIFY.
|
double |
evaluateMembership(long r,
double[] x)
Returns Grade of Membership of x to rule r antecedent.
|
FuzzyRule |
getComponent(int n)
Returns rule n.
|
double[] |
myOutput(double[] x)
Returns output (Wang-Mendel) for input x.
|
int |
numConsequents()
Returns the number of consequents in RuleBase.
|
double[] |
output(double[] x)
Returns output (Wang-Mendel) for input x.
|
void |
set(RuleBase b)
Copies the RuleBase parameter over the present instance.
|
void |
setComponent(int n,
FuzzyRule b)
Copies a new rule in the RuleBase.
|
int |
size()
Returns the number of rules.
|
double |
tnorm(double x,
double y)
Returns the T-Norm of two membership values.
|
java.lang.String |
variableNames(long r)
Returns a String with the antecedents (Vi) of rule r.
|
public static final int product
public static final int sum
public static final int DEFUZCDM
public static final int DEFUZMAX
public RuleBase(FuzzyPartition[] pe, FuzzyPartition ps, int tn, int ag)
A constructor for a RuleBase.
pe
- vector of fuzzy partitions with the antecedents for each rule.ps
- fuzzy partition with consequents for the rules.tn
- T-Norm for RuleBase.ag
- .public RuleBase(RuleBase b)
A copy constructor for a RuleBase, given other RuleBase.
b
- to be copied.public void set(RuleBase b)
Copies the RuleBase parameter over the present instance.
b
- a RuleBase object to be copiedpublic RuleBase clone()
Creates and returns a copy of this object.
clone
in class java.lang.Object
public void debug()
Prints the results.
public int size()
Returns the number of rules.
public FuzzyRule getComponent(int n)
Returns rule n.
n
- the number of rule.public void setComponent(int n, FuzzyRule b)
Copies a new rule in the RuleBase.
n
- the number of rule to rewrite.b
- the new rule to copy in present RuleBase.public java.lang.String variableNames(long r)
Returns a String with the antecedents (Vi) of rule r.
r
- the number of rule whose antecedents are to be printed.public double tnorm(double x, double y)
Returns the T-Norm of two membership values.
x
- the membership grade of one individual.y
- the membership grade of one individual.public double evaluateMembership(long r, double[] x)
Returns Grade of Membership of x to rule r antecedent.
r
- a rule index.x
- individual.public double[] output(double[] x)
Returns output (Wang-Mendel) for input x.
x
- individual.public void addRules(long[] rules, FuzzyRule[] rules2)
Adds new rules to BaseRule.
rules
- vector with coded indexes of the rules.rules2
- vector with antecedents and weights of the rules.public double[] myOutput(double[] x)
Returns output (Wang-Mendel) for input x.
x
- individual.public int numConsequents()
Returns the number of consequents in RuleBase.
public double defuzzify(double[] output, int IDDEFUZZIFY)
Defuzzifies output using method IDDEFUZZIFY.
output
- vector with the output to be defuzzified.IDDEFUZZIFY
- type of defuzzification to run (RuleBase.DEFUZCDM or RuleBase.DEFUZMAX).public long codifyAntecents(double[] example)
This method finds out the label with maximum membership value for each variable. After that, it codifies the label indexes with corresponding variable cardinality (or partition cardinality) in a long value. The codification consists in weighting each label index by the product of previous variables cardinality.
example
- input example to codify.