|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nrc.fuzzy.FuzzyValue
The FuzzyValue
class represents a fuzzy value, which is an association of a
FuzzyVariable, a FuzzySet, and the linguistic
expression which describe the FuzzyValue.
The FuzzyVariable provides a set of Terms that can be used to describe concepts being developed for the variable. For example, temperature may be a fuzzy variable, with terms such as hot, cold and warm being used to describe concepts such as 'hot or cold'.
The linguistic expression is formed using the terms of the FuzzyVariable along with the operators 'or' and 'and' and the set of supplied modifiers such as 'very', 'not' and 'slightly'. These english-like expressions are used to describe the required fuzzy concepts for the variable.
For example, let us consider the FuzzyVariable temperature, with terms
cold, warm,
and hot
. It is decided that we
would like a FuzzyValue that represents the concept "slightly cold AND warm"
for the temperature variable. This string is parsed, and based on the
parse a suitable FuzzySet is created for the FuzzyValue, and the
linguistic expression is stored as "slightly cold AND warm".
See the documentation for the FuzzyScanner class for more detailed
information on the grammar and parsing.
However, it is also possible to create a FuzzyValue by providing the
data it requires to create its FuzzySet. It this case, no linguistic
expression has been used, and the linguisticExpression
is assigned the default String value which, unless changed, is "???".
The FuzzySet in a FuzzyValue contains a set of points. This set of points is the mathematical representation of the fuzzy concept being expressed for this FuzzyValue.
The code below shows the creation of a FuzzyVariable and a FuzzyValue:
double xHot[] = {25, 35};
double yHot[] = {0, 1};
double xCold[] = {5, 15};
double yCold[] = {1, 0};
FuzzyValue fval = null;
...
FuzzyVariable temp = new FuzzyVariable("temperature", 0, 100, "C");
...
temp.addTerm("hot", xHot, yHot, 2);
temp.addTerm("cold", xCold, yCold, 2);
// note: once a term is added it can be used to define other terms
temp.addTerm("medium", "not hot and not cold");
...
fval = new FuzzyValue(temp, "very hot or cold");
System.out.println(fval);
The output from this would be:
FuzzyVariable -> temperature [ 0.0, 100.0 ] C
Linguistic Expression -> very hot or cold
FuzzySet -> { 1/5 0/15 0/25 0.01/26 0.04/27 0.09/28 0.16/29 0.25/30
0.36/31 0.49/32 0.64/33 0.81/34 1/35 }
NOTE: Although the range of allowed membership values is [0, 1], it is possible to form FuzzySets of FuzzyValues with membership values > 1.0. There are instances where this is desirable. For example in some approaches it is preferred to collect the outputs of fuzzy rules by doing a 'fuzzySum' of the resultant FuzzyValues (global contribution of rules). The fuzzySum operation can result in FuzzySets with membership values > 1.0. When a FuzzyValue is created with a FuzzyValue constructor (that does not use an existing FuzzyValue or an existing FuzzySet) the values are restricted to being between 0 and 1. However, the fuzzySum operation and the FuzzySet methods appendSetPoint and insertSetPoint can be used to override this restriction.
FuzzyVariable
,
FuzzySet
,
FuzzyScanner
,
Serialized FormField Summary | |
static int |
STRONG_EQUALS
Use this value with setEqualsStrength method to set a strong 'equals' compare of FuzzyValues. |
static int |
WEAK_EQUALS
Use this value with setEqualsStrength method to set a weak 'equals' compare of FuzzyValues. |
Constructor Summary | |
FuzzyValue(nrc.fuzzy.FuzzyValue fuzzyValue)
Constructs a new FuzzyValue object from an existing FuzzyValue. |
|
FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
double[] x,
double[] y,
int numPoints)
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and creates a FuzzySet from the two arrays of double values. |
|
FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
nrc.fuzzy.FuzzySet fuzzySet)
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and which contains the FuzzySet argument. |
|
FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
nrc.fuzzy.SetPoint[] setPoints,
int numPoints)
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and creates a FuzzySet from the array of SetPoints. |
|
FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
java.lang.String linguisticExpression)
Constructs a FuzzyValue with the fuzzyVariable variable set equal
to the FuzzyVariable argument, and the linguisticExpression variable
initialized to the passed linguistic expression String argument. |
Method Summary | |
void |
assignFuzzySet(nrc.fuzzy.FuzzySet fuzzySet)
Assigns a new FuzzySet to the FuzzyValue. |
void |
binaryModifyLinguisticExpression(java.lang.String op,
java.lang.String oldLinguisticExpression1,
java.lang.String oldLinguisticExpression2)
Modifies the linguistic expression when a binary operation (such union or intersection) of 2 fuzzy values is done to produce a new fuzzy value. |
double |
centerOfAreaDefuzzify()
Center of Area (COA) defuzzification defuzzifies a fuzzy set returning a floating point (double value) that represents the fuzzy set. |
nrc.fuzzy.FuzzyValue |
copyFuzzyValue()
Returns a copy of this FuzzyValue. |
boolean |
equals(java.lang.Object v)
Compare two FuzzyValues for a fuzzy equality. |
boolean |
equalsStar(java.lang.Object v)
An alternative weak method for comparing two FuzzyValues. |
nrc.fuzzy.FuzzyValue |
fuzzyComplement()
Takes the complement of the FuzzyValue . |
nrc.fuzzy.FuzzyValue |
fuzzyIntersection(nrc.fuzzy.FuzzyValue otherValue)
Perform the fuzzy intersection of 2 fuzzy values. |
nrc.fuzzy.FuzzyValue |
fuzzyIntersection(java.lang.String linguisticExpression)
Perform the fuzzy intersection of 2 fuzzy values. |
boolean |
fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue)
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by the FuzzyValue class variable matchThreshold. |
boolean |
fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue,
double threshold)
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by parameter threshold. |
boolean |
fuzzyMatch(java.lang.String linguisticExpression)
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by the FuzzyValue class variable matchThreshold. |
boolean |
fuzzyMatch(java.lang.String linguisticExpression,
double threshold)
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by parameter 'threshold'. |
nrc.fuzzy.FuzzyValue |
fuzzyNormalize()
Normalizes the FuzzyValue . |
nrc.fuzzy.FuzzyValue |
fuzzyScale(double y)
Scale this FuzzyValue . |
nrc.fuzzy.FuzzyValue |
fuzzySum(nrc.fuzzy.FuzzyValue otherValue)
Returns the sum of this FuzzyValue with the FuzzyValue argument. |
nrc.fuzzy.FuzzyValue |
fuzzySum(java.lang.String linguisticExpression)
Returns the sum of this FuzzyValue with the FuzzyValue argument. |
nrc.fuzzy.FuzzyValue |
fuzzyUnion(nrc.fuzzy.FuzzyValue otherValue)
Perform the fuzzy union of 2 fuzzy values. |
nrc.fuzzy.FuzzyValue |
fuzzyUnion(java.lang.String linguisticExpression)
Perform the fuzzy union of 2 fuzzy values. |
nrc.fuzzy.IntervalVector |
getAlphaCut(boolean cutType,
double alpha)
Returns the alpha cut of the FuzzyValue at the membership level specified by the alpha argument. |
static nrc.fuzzy.SimilarityOperator |
getDefaultSimilarityOperator()
Get the default similarity operator that is used by the FuzzyValue similarity method. |
static int |
getEqualsStrength()
Returns the value of the current setting for the strength with which the equals method compares FuzzyValues. |
nrc.fuzzy.FuzzySet |
getFuzzySet()
Returns the FuzzySet that is contained within this FuzzyValue. |
nrc.fuzzy.FuzzyVariable |
getFuzzyVariable()
Returns the FuzzyVariable to which this FuzzyValue belongs. |
java.lang.String |
getLinguisticExpression()
Returns the String which represents the linguistic expression of this FuzzyValue. |
static double |
getMatchThreshold()
Returns the current matchThreshold which is used when comparing fuzzy values with the fuzzyMatch method. |
double |
getMaxUOD()
Returns the x value which represents the maximum x value in the Universe of Discourse of the FuzzyVariable to which this FuzzyValue belongs, and therefore the maxinum x value of the Universe of Discourse of this FuzzyValue. |
double |
getMaxY()
Returns the maximum membership value of the FuzzySet. |
double |
getMembership(double x)
Returns the membership value of the FuzzyValue at the specified x value. |
double |
getMinUOD()
Returns the x value which represents the minimum x value in the Universe of Discourse of the FuzzyVariable to which this FuzzyValue belongs, and therefore the mininum x value of the Universe of Discourse of this FuzzyValue. |
double |
getMinY()
Returns the minimum membership value of the FuzzySet. |
nrc.fuzzy.IntervalVector |
getSupport()
Returns the support of this FuzzyValue. |
java.lang.String |
getUnits()
Returns the units of the FuzzyVariable to which this FuzzyValue belongs, and therefore the units of this FuzzyValue. |
double |
getX(int index)
Returns the x value of the point in the FuzzyValue at the specified index. |
double |
getXforMembership(double m)
Returns the 1st X value with the specified membership value in the FuzzySet This is done by interpolation. |
double |
getY(int index)
Returns the y value of the point in the FuzzyValue at the specified index. |
int |
hashCode()
Return a hashcode value for the FuzzyValue. |
nrc.fuzzy.FuzzyValue |
horizontalIntersection(double y)
Returns the horizontal intersection of the FuzzyValue at the membership level specified by the y parameter. |
nrc.fuzzy.FuzzyValue |
horizontalUnion(double y)
Returns the horizontal union of the FuzzySet at the membership level specified by the y parameter. |
boolean |
isAnyXValueOutsideUOD(nrc.fuzzy.FuzzySet fs,
nrc.fuzzy.FuzzyVariable fvar)
Checks to see if all of the X values of a fuzzy set are within the range of the universe of discourse (UOD) of a fuzzy variable. |
static boolean |
isConfineFuzzySetsToUOD()
Returns true if FuzzySets will be confined to lie within the Universe of Discourse (UOD) when FuzzyValues are constructed. |
boolean |
isConvex()
Returns true if this FuzzyValue is convex. |
boolean |
isEmpty()
Returns true if this FuzzyValue is empty; in other words, if this FuzzyValue has a null FuzzySet, or a FuzzySet which doesn't contain any points. |
boolean |
isNormal()
Returns true if this FuzzyValue is normal. |
boolean |
isXValueOutsideUOD(double x,
nrc.fuzzy.FuzzyVariable fvar)
Returns true if the x value passed to the method is outside of the Universe of Discourse. |
double |
maximumDefuzzify()
Finds the mean of maxima of a fuzzy set as the defuzzification value. |
double |
maximumOfIntersection(nrc.fuzzy.FuzzyValue otherValue)
Find the minimum membership values between 2 FuzzyValues at all x values and then find the maximum of these minimums (in effect take the intersection of the 2 FuzzyValues and find the maximum membership value of this). |
double |
maximumOfIntersection(java.lang.String linguisticExpression)
Find the minimum membership values between 2 FuzzyValues at all x values and then find the maximum of these minimums (in effect take the intersection of the 2 FuzzyValues and find the maximum membership value of this). |
double |
momentDefuzzify()
Moment defuzzification defuzzifies a fuzzy set returning a floating point (double value) that represents the fuzzy set. |
java.lang.String |
plotFuzzyValue(java.lang.String plotChar)
Plots the fuzzy value in an ascii format producing a String that can be displayed. |
java.lang.String |
plotFuzzyValue(java.lang.String plotChar,
double lowX,
double highX)
Plots the fuzzy value in an ascii format producing a String that can be displayed. |
static java.lang.String |
plotFuzzyValues(java.lang.String plotChars,
double lowX,
double highX,
nrc.fuzzy.FuzzyValue[] fvals)
Plots the fuzzy values in an ascii format producing a String that can be displayed. |
static java.lang.String |
plotFuzzyValues(java.lang.String plotChars,
nrc.fuzzy.FuzzyValue[] fvals)
Plots the given fuzzy values in an ascii format producing a String that can be displayed. |
static void |
setConfineFuzzySetsToUOD(boolean b)
If param is true FuzzySets will be confined to lie within the Universe of Discourse (UOD) when FuzzyValues are constructed. |
static void |
setDefaultSimilarityOperator(nrc.fuzzy.SimilarityOperator simOp)
Set the default similarity operator that will be used by the FuzzyValue similarity method. |
static void |
setEqualsStrength(int strength,
int equalsStrengthPassword)
Control how to compare two FuzzyValues for fuzzy equality with the 'equals' method. |
void |
setLinguisticExpression(java.lang.String lexpr)
Sets the String which represents the linguistic expression of this FuzzyValue. |
static void |
setMatchThreshold(double value)
Sets the current default matchThreshold which is used when comparing fuzzy values with the fuzzyMatch method. |
double |
similarity(nrc.fuzzy.FuzzyValue fv)
SIMILARITY: calculates a similarity measure between two fuzzy values using the default similarity operator. |
double |
similarity(nrc.fuzzy.FuzzyValue fv,
nrc.fuzzy.SimilarityOperator simOp)
SIMILARITY: calculates a similarity measure between two fuzzy values using a specified similarity operator. |
int |
size()
Returns the size of the FuzzyValue; in other words, the number of points contained in the FuzzySet. |
java.lang.String |
toString()
Returns the String representation of the FuzzyValue. |
void |
unaryModifyLinguisticExpression(java.lang.String operator,
java.lang.String oldLinguisticExpression)
Modifies the linguistic expression when a unary operation (such as very, more_or_less, etc.) is applied to produce a new fuzzy value. |
double |
weightedAverageDefuzzify()
Finds the weighted average of the values of a fuzzy set as the defuzzification value. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int WEAK_EQUALS
public static final int STRONG_EQUALS
Constructor Detail |
public FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable, java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException
fuzzyVariable
variable set equal
to the FuzzyVariable argument, and the linguisticExpression
variable
initialized to the passed linguistic expression String argument.
To initialize the FuzzySet of the FuzzyValue, the linguistic expression argument is parsed and the respective modifiers and operators are applied to the FuzzyValue terms refered to in the linguistic expression. The result of the modifier application and operations is then assigned to the FuzzySet of this FuzzyValue.
fuzzyVariable
- the FuzzyVariable that the FuzzyValue belongs to,
or is defined in terms of.linguisticExpression
- the linguistic expression defining the FuzzySet.
It is important that the linguistic expression parameter
contains no ambiguities in intention. For example,
the String "not cold AND very warm" could be interpreted
as either "(not cold) AND (very warm)", or
"not (cold AND very warm)". The use of parentheses is
of utmost importance, as the absence of parentheses required
to prevent ambiguities in meaning will lead to
unpredictable results.
The parsing of the linguistic expression results in the specified modifiers and operators applied to the specified terms. The end product is the FuzzySet that belongs to the new FuzzyValue.
InvalidLinguisticExpressionException
- if the parse/evaluation of the linguistic expression failspublic FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable, nrc.fuzzy.FuzzySet fuzzySet) throws XValueOutsideUODException
fuzzyVariable
- the FuzzyVariable that the FuzzyValue belongs to,
or is defined in terms of.fuzzySet
- the FuzzySet to be assigned to the FuzzyValue
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discoursepublic FuzzyValue(nrc.fuzzy.FuzzyValue fuzzyValue)
fuzzyValue
- the FuzzyValue to copy
range of the universe of discoursepublic FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable, double[] x, double[] y, int numPoints) throws XValuesOutOfOrderException, YValueOutOfRangeException, XValueOutsideUODException
fuzzyVariable
- the FuzzyVariable that the FuzzyValue belongs to,
or is defined in terms of.x
- the double array containing the x values of the points that are to
constitute the FuzzySet.y
- the double array containing the y values of the points that are to
constitute the FuzzySet.numPoints
- the number of points that are contained within the two arrays.
In other words, it would be logically expected that the length of the
x values array would be equal to the y values array, which would also
be equal to the number of points that are to be inserted into the FuzzySet.
XValuesOutOfOrderException
- if the x values in the x double array are not in
strictly ascending order.
YValueOutOfRangeException
- if the y values are not within the range [0.0, 1.0]
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discoursepublic FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable, nrc.fuzzy.SetPoint[] setPoints, int numPoints) throws XValuesOutOfOrderException, YValueOutOfRangeException, XValueOutsideUODException
fuzzyVariable
- the FuzzyVariable that the FuzzyValue belongs to,
or is defined in terms of.setPoints
- the array of SetPoints that are to constitute the FuzzySet.numPoints
- the number of points that are contained in the SetPoint array.
XValuesOutOfOrderException
- if the x values in the x double array are not in
strictly ascending order.
YValueOutOfRangeException
- if the y values are not within the range [0.0, 1.0]
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourseMethod Detail |
public static void setEqualsStrength(int strength, int equalsStrengthPassword)
So the actual compare done by equals can be changed with the method setEqualsStrength. Normally this will be a temporary change and it should be done in a synchronized manner. E.g.:
synchronized (this)
{
int currentStrength = FuzzyValue.getEqualsStrength();
FuzzyValue.setEqualsStrength(FuzzyValue.WEAK_EQUALS, PASSWORD);
...
some code that requires a WEAK compare temporarily
...
FuzzyValue.setEqualsStrength(currentStrength, PASSWORD);
}
The PASSWORD is private and only know to developers with access to the code. In other words it is not to be used in general. If the FuzzyJess code were not in a 'separate' package (nrc.fuzzy.jess) and were in the nrc.fuzzy package all of this would have been nicely hidden from the general user in private methods.
strength
- should be one of FuzzyValue.WEAK_EQUALS or FuzzyValue.STRONG_EQUALS. If
it is neither of these then nothing will be done.equalsStrengthPassword
- should be the required password to use this method. If
it is incorrect then nothing will be done.
public static int getEqualsStrength()
public boolean equals(java.lang.Object v)
However, in some exceptional circumstances a weaker condition is useful (they just need to have the same FuzzyVariable). This is true in the FuzzyJess implementation so that Global contribution can be done automatically. In this case we want to combine facts that have identical non-fuzzy slots and fuzzy slots with the same FuzzyVariable. Since Jess uses the 'equals' method to compare the slots when retrieving facts (with findFactByFact) we can temporarily change the behaviour of the FuzzyValue equals method to do a weak comparison. This should only be used with care since it can have a considerable effect. Normally one would use the equalsStar method to do a weak compare. See setEqualsStrength and getEqualsStrength.
NOTE: This is a change in version 1.10 and later versions of FuzzyJ (previously equals did a weak compare).
equals
in class java.lang.Object
v
- the object to compare to the FuzzyValue.
public boolean equalsStar(java.lang.Object v)
NOTE: This is a change in version 1.10 and later versions of FuzzyJ (previously equalsStar did a strong compare).
v
- the object to compare to the FuzzyValue.
FuzzySet
public int hashCode()
hashCode
in class java.lang.Object
public nrc.fuzzy.FuzzyValue copyFuzzyValue() throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException
- if this class does not implement the Cloneable
interface (which it does, so don't worry about it).public void unaryModifyLinguisticExpression(java.lang.String operator, java.lang.String oldLinguisticExpression)
operator
- the operator (very, more_or_less, etc.) that was appliedoldLinguisticExpression
- the linguistic expression from the fuzzy value that was modifiedpublic void binaryModifyLinguisticExpression(java.lang.String op, java.lang.String oldLinguisticExpression1, java.lang.String oldLinguisticExpression2)
op
- the operator (and, or, etc.) that was appliedoldLinguisticExpression1
- the linguistic expression from the 1st fuzzy valueoldLinguisticExpression2
- the linguistic expression from the 2nd fuzzy valuepublic void assignFuzzySet(nrc.fuzzy.FuzzySet fuzzySet) throws XValueOutsideUODException
fuzzySet
- the FuzzySet to be assigned.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discoursepublic nrc.fuzzy.FuzzyValue fuzzyComplement()
FuzzyValue
.
More specifically, it takes the compliment of the y values of the SetPoints of the FuzzySet.
Mathematically (NOT), u(x) = 1 - u(x), or y = 1 - y.
This assumes that all of the membership values of the fuzzy set are <= 1.0 and >= 0.0. If values lie outside this then values >1.0 will be set to 0.0 and those < 0.0 will be set to 1.0
public nrc.fuzzy.FuzzyValue fuzzyScale(double y)
FuzzyValue
.
Returns the FuzzyValue which is scaled by:
yvalue/maxYValueOfSet
y
- scaling factor
public nrc.fuzzy.FuzzyValue fuzzyNormalize() throws XValueOutsideUODException
FuzzyValue
.
Normalization involves identifying the point in the FuzzyValue
with the highest membership value and multiplying all the membership values
in the FuzzyValue by a scale factor such that this highest point then has
a membership value of 1.0.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discoursepublic nrc.fuzzy.IntervalVector getSupport()
public nrc.fuzzy.IntervalVector getAlphaCut(boolean cutType, double alpha)
alpha
argument. Formally, a distinction is made betweeen two
types of alpha cuts, the strong and the weak alpha cut.
The alpha cut of a FuzzyValue (FuzzySet) is the set of all x values in the
Universe of Discourse for which the membership value of the FuzzyValue (FuzzySet)
is greater than (STRONG cut) or greater than or equal to (WEAK cut)
the alpha
argument.
cutType
- Parameters.STRONG for a strong alpha cut or Parameters.WEAK for a weak alpha cutalpha
- the double membership value at which the alpha cut is taken. The
resulting set is the set of all elements for which the
membership value is greater than or equal to the alpha value.
alpha
argument.public double getMembership(double x) throws XValueOutsideUODException
x
- the double x value at which the membership value requested will
be interpolated
XValueOutsideUODException
- if the x value passed to the
method is outside the Universe of Discourse for this
FuzzyValue (ie. for the FuzzyVariable to which this
FuzzyValue belongs)public double getXforMembership(double m) throws NoXValueForMembershipException
NoXValueForMembershipException
public nrc.fuzzy.FuzzyValue horizontalIntersection(double y)
y
- the y value with which the set is being intersected
public nrc.fuzzy.FuzzyValue horizontalUnion(double y)
y
- the y value with which the set is being unioned
public nrc.fuzzy.FuzzyValue fuzzyIntersection(java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException, XValueOutsideUODException, IncompatibleFuzzyValuesException
fuzzyIntersection(FuzzySet otherSet)
.
linguisticExpression
- a linguistic expression that defines the other fuzzyValue
to be used in the intersection operation.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be done
InvalidLinguisticExpressionException
- if the linguistic expression is not validpublic nrc.fuzzy.FuzzyValue fuzzyIntersection(nrc.fuzzy.FuzzyValue otherValue) throws XValueOutsideUODException, IncompatibleFuzzyValuesException
fuzzyIntersection(FuzzySet otherSet)
.
otherValue
- the 2nd FuzzyValue for the operation
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic nrc.fuzzy.FuzzyValue fuzzyUnion(java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException, XValueOutsideUODException, IncompatibleFuzzyValuesException
fuzzyUnion(FuzzySet otherSet)
.
linguisticExpression
- a linguistic expression that defines the other fuzzyValue
to be used in the union operation.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be done
InvalidLinguisticExpressionException
- if the linguistic expression is not validpublic nrc.fuzzy.FuzzyValue fuzzyUnion(nrc.fuzzy.FuzzyValue otherValue) throws XValueOutsideUODException, IncompatibleFuzzyValuesException
fuzzyUnion(FuzzySet otherSet)
.
otherValue
- the 2nd FuzzyValue for the operation
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic nrc.fuzzy.FuzzyValue fuzzySum(java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException, XValueOutsideUODException, IncompatibleFuzzyValuesException
NOTE WELL: The sum can lead to FuzzySets with membership values greater than 1.0. This is sometimes used to collect output of fuzzy rules (global contribution) rather than doing the union.
linguisticExpression
- a linguistic expression that defines the other fuzzyValue
to be used in the sum operation.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be done
InvalidLinguisticExpressionException
- if the linguistic expression is not validpublic nrc.fuzzy.FuzzyValue fuzzySum(nrc.fuzzy.FuzzyValue otherValue) throws XValueOutsideUODException, IncompatibleFuzzyValuesException
NOTE WELL: The sum can lead to FuzzySets with membership values greater than 1.0. This is sometimes used to collect output of fuzzy rules (global contribution) rather than doing a union.
otherValue
- the 2nd FuzzyValue for the sum operation.
XValueOutsideUODException
- if the fuzzy set x values are not within the
range of the universe of discourse
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic double maximumOfIntersection(java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException, IncompatibleFuzzyValuesException
linguisticExpression
- a linguistic expression that defines the other fuzzyValue
to be compared to this FuzzyValue
InvalidLinguisticExpressionException
- if the linguistic expression is not valid
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic double maximumOfIntersection(nrc.fuzzy.FuzzyValue otherValue) throws IncompatibleFuzzyValuesException
otherValue
- the 2nd FuzzyValue for the operation
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic double momentDefuzzify() throws InvalidDefuzzifyException, XValuesOutOfOrderException
sum of ( moment(i) * area(i) ) <-- top ------------------------------ sum of (area(i)) <-- bottomIf the total area is 0 then throw an exception since the moment is not defined.
InvalidDefuzzifyException
- there is no valid moment for the fuzzy set
(generally the area is 0 under the fuzzy set graph)
XValuesOutOfOrderException
- occurs when the MinUOD is
greater than or equal to the MaxUOD parameter (this
should never happen).public double centerOfAreaDefuzzify() throws InvalidDefuzzifyException, XValuesOutOfOrderException
InvalidDefuzzifyException
- there is no valid COA for the fuzzy set
(generally the area is 0 under the fuzzy set graph)
XValuesOutOfOrderException
- occurs when the xMin parameter is
greater than or equal to the xMax parameter.public double weightedAverageDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException
/------\ /\ / \ / \ --/ \---------------/ \------------- ^ ^ | | | | gives this as the weighted average | this is more reasonable???However, it is especially effective if the output has a number of singleton points in it. This might be, for example, when one has only singleton values describing the output fuzzy values (Takagi-Sugeno-Kang zero order type rules). In this case one gets a result that would be expected and one that would result in an exception with the momentDefuzzify (area is 0) and a poor result with the maximumDefuzzify (since only the values with the max membership are used - 20 in the example below).
1.0 | | 0.5 | | | | | --------|--------|--------|-------- 0 10 20 30 40 ^ | | gives 18.57 as the weighted average (10*0.5 + 20*1 + 30*0.25) / (0.5 + 1 + 0.25) = 18.57Centre of gravity (moment) defuzzify is likely more useful most of the time.
InvalidDefuzzifyException
- there are no points in the FuzzySet
XValuesOutOfOrderException
- occurs when the MinUOD is
greater than or equal to the MaxUOD parameter (this
should never happen).public double maximumDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException
/------\ /\ / \ / \ --/ \---------------/ \------------- ^ ^ | | | | gives this as the mean of maximum | this is more reasonable???Centre of gravity (moment) defuzzify is likely more useful most of the time.
InvalidDefuzzifyException
- there are no points in the FuzzySet
XValuesOutOfOrderException
- occurs when the MinUOD is
greater than or equal to the MaxUOD parameter (this
should never happen).public boolean fuzzyMatch(java.lang.String linguisticExpression) throws InvalidLinguisticExpressionException, IncompatibleFuzzyValuesException
linguisticExpression
- a linguistic expression that defines the other fuzzyValue
to be compared to this FuzzyValue
InvalidLinguisticExpressionException
- if the linguistic expression is not valid
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic boolean fuzzyMatch(java.lang.String linguisticExpression, double threshold) throws InvalidLinguisticExpressionException, IncompatibleFuzzyValuesException
threshold
- determines the value above which a match is considered to be true,
over-riding the class variable matchThreshold value.
InvalidLinguisticExpressionException
- if the linguistic expression is not valid
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic boolean fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue) throws IncompatibleFuzzyValuesException
otherValue
- the 2nd FuzzyValue for the operation
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic boolean fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue, double threshold) throws IncompatibleFuzzyValuesException
otherValue
- the 2nd FuzzyValue for the operation.threshold
- determines the value above which a match is considered to be true,
over-riding the class variable matchThreshold value.
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be donepublic double similarity(nrc.fuzzy.FuzzyValue fv) throws IncompatibleFuzzyValuesException
Note: the 2 fuzzy values must have the same Fuzzy variable
fv
- the fuzzy value with which this fuzzy value is compared
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be doneSimilarityByAreaOperator
,
SimilarityByPossibilityOperator
public double similarity(nrc.fuzzy.FuzzyValue fv, nrc.fuzzy.SimilarityOperator simOp) throws IncompatibleFuzzyValuesException
Note: the 2 fuzzy values must have the same Fuzzy variable
fv
- the fuzzy value with which this fuzzy value is comparedsimOp
- the SimilarityOperator to use to calculate the similarity
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables the operation cannot be doneSimilarityByAreaOperator
,
SimilarityByPossibilityOperator
public static void setDefaultSimilarityOperator(nrc.fuzzy.SimilarityOperator simOp)
simOp
- is the similarity operator to be used when the
FuzzyValue method similarity is called.public static nrc.fuzzy.SimilarityOperator getDefaultSimilarityOperator()
public static void setConfineFuzzySetsToUOD(boolean b)
b
- true if f FuzzySets will be confined to lie within the
UOD when constructing FuzzyValues.public static boolean isConfineFuzzySetsToUOD()
public boolean isEmpty()
public boolean isConvex()
public boolean isNormal()
public int size()
public double getX(int index)
index
- the 0 based index into the fuzzy set points of the fuzzy value.
public double getY(int index)
index
- the 0 based index into the fuzzy set points of the fuzzy value.
public double getMaxY()
public double getMinY()
public java.lang.String toString()
For example:
FuzzyVariable -> TEMPERATURE [0, 60] Degree Celsius Linguistic Expression -> HOT FuzzySet -> { 0/30 1/45 0/60}
toString
in class java.lang.Object
public nrc.fuzzy.FuzzyVariable getFuzzyVariable()
public nrc.fuzzy.FuzzySet getFuzzySet()
public java.lang.String getUnits()
public double getMinUOD()
public double getMaxUOD()
public void setLinguisticExpression(java.lang.String lexpr)
lexpr
- the linguistic expression to replace the current onepublic java.lang.String getLinguisticExpression()
public boolean isAnyXValueOutsideUOD(nrc.fuzzy.FuzzySet fs, nrc.fuzzy.FuzzyVariable fvar)
fs
- the fuzzy set to be checkedfvar
- the fuzzy variable with the UOD definition
public boolean isXValueOutsideUOD(double x, nrc.fuzzy.FuzzyVariable fvar)
x
- the x value being tested to be within the range of the UODfvar
- the fuzzy variable that defines the UOD
public static double getMatchThreshold()
public static void setMatchThreshold(double value)
value
- the new value for matchThreshold. If the value is > 1.0
set it to 1.0; if it is < 0.0 set it to 0.0.public java.lang.String plotFuzzyValue(java.lang.String plotChar, double lowX, double highX)
FuzzyValue fval;
FuzzyVariable temp = new FuzzyVariable("temperature", 0, 100, "C");
...
fval = new FuzzyValue(temp, "very hot or cold");
System.out.println(fval.plotFuzzyValue("+", 0, 40));
will display
Fuzzy Value: temperature
Linguistic Value: very hot or cold (+)
1.00+++++++ +++++++
0.95 +
0.90 +
0.85 +
0.80 +
0.75 +
0.70 +
0.65
0.60 + +
0.55 +
0.50 +
0.45 +
0.40 + +
0.35
0.30 + +
0.25
0.20 + +
0.15 + +
0.10 +
0.05 + +
0.00 +++++++++++++++
|----|----|----|----|----|----|----|----|----|----|
0.00 8.00 16.00 24.00 32.00 40.00
public java.lang.String plotFuzzyValue(java.lang.String plotChar)
See plotFuzzyValue( String plotChars, double lowX, double highX )
for an example.
public static java.lang.String plotFuzzyValues(java.lang.String plotChars, nrc.fuzzy.FuzzyValue[] fvals)
See plotFuzzyValues( String plotChars, double lowX, double highX, FuzzyValue fvals[])
for an example.
plotChars
- characters to use for plotting (normally *, +, ., etc)public static java.lang.String plotFuzzyValues(java.lang.String plotChars, double lowX, double highX, nrc.fuzzy.FuzzyValue[] fvals)
FuzzyValue fval2, fval3;
FuzzyValue fvals[] = new FuzzyValue[2];
FuzzyVariable temp = new FuzzyVariable("temperature", 0, 100, "C");
...
fval2 = new FuzzyValue(temp, "very hot or cold");
fval3 = new FuzzyValue(temp, "medium");
fvals[0] = fval2;
fvals[1] = fval3;
System.out.println(FuzzyValue.plotFuzzyValues("*+", 0, 40, fvals));
will display
Fuzzy Value: temperature
Linguistic Value: very hot or cold (*), medium (+)
1.00******* +++++++++++++ *******
0.95 * + +
0.90 *
0.85 * + +
0.80 * + +
0.75 *
0.70 * + +
0.65
0.60 * + + *
0.55 *+ +
0.50 *
0.45 +* +
0.40 + * +
0.35
0.30 + * * +
0.25
0.20 + * * +
0.15 + * * +
0.10 *
0.05 + * * +
0.00+++++++ *************** +++++++
|----|----|----|----|----|----|----|----|----|----|
0.00 8.00 16.00 24.00 32.00 40.00
plotChars
- characters to use for plotting (normally *, +, ., etc)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |