nrc.fuzzy
Class FuzzyValue

java.lang.Object
  |
  +--nrc.fuzzy.FuzzyValue
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class FuzzyValue
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

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.

See Also:
FuzzyVariable, FuzzySet, FuzzyScanner, Serialized Form

Field 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

WEAK_EQUALS

public static final int WEAK_EQUALS
Use this value with setEqualsStrength method to set a weak 'equals' compare of FuzzyValues.

See Also:
Constant Field Values

STRONG_EQUALS

public static final int STRONG_EQUALS
Use this value with setEqualsStrength method to set a strong 'equals' compare of FuzzyValues.

See Also:
Constant Field Values
Constructor Detail

FuzzyValue

public FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
                  java.lang.String linguisticExpression)
           throws InvalidLinguisticExpressionException
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.

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.

Parameters:
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.

Throws:
InvalidLinguisticExpressionException - if the parse/evaluation of the linguistic expression fails

FuzzyValue

public FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
                  nrc.fuzzy.FuzzySet fuzzySet)
           throws XValueOutsideUODException
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and which contains the FuzzySet argument. Because the FuzzySet is already in existence when the FuzzyValue is created, a linguistic expression is not required to build the FuzzySet. Therefore, there is no reference which defines the FuzzySet linguistically, and as a result the linguistic expression of a FuzzyValue constructed in this a manner will be the default linguistic expression, ie. "???".

Parameters:
fuzzyVariable - the FuzzyVariable that the FuzzyValue belongs to, or is defined in terms of.
fuzzySet - the FuzzySet to be assigned to the FuzzyValue
Throws:
XValueOutsideUODException - if the fuzzy set x values are not within the range of the universe of discourse

FuzzyValue

public FuzzyValue(nrc.fuzzy.FuzzyValue fuzzyValue)
Constructs a new FuzzyValue object from an existing FuzzyValue. This is basically a copy.

Parameters:
fuzzyValue - the FuzzyValue to copy range of the universe of discourse

FuzzyValue

public FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
                  double[] x,
                  double[] y,
                  int numPoints)
           throws XValuesOutOfOrderException,
                  YValueOutOfRangeException,
                  XValueOutsideUODException
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and creates a FuzzySet from the two arrays of double values. Because the FuzzySet is created from double arrays, a linguistic expression is not required to build the FuzzySet. Therefore, there is no reference which defines the FuzzySet linguistically, and as a result the linguistic expression of a FuzzyValue constructed in this a manner will be the default linguistic expression, ie. "???".

Parameters:
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.
Throws:
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 discourse

FuzzyValue

public FuzzyValue(nrc.fuzzy.FuzzyVariable fuzzyVariable,
                  nrc.fuzzy.SetPoint[] setPoints,
                  int numPoints)
           throws XValuesOutOfOrderException,
                  YValueOutOfRangeException,
                  XValueOutsideUODException
Constructs a new FuzzyValue object which has a reference to the FuzzyVariable argument and creates a FuzzySet from the array of SetPoints. Because the FuzzySet is created from a SetPoint array, a linguistic expression is not required to build the FuzzySet. Therefore, there is no reference which defines the FuzzySet linguistically, and as a result the linguistic expression of a FuzzyValue constructed in this a manner will be the default linguistic expression, ie. "???".

Parameters:
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.
Throws:
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 discourse
Method Detail

setEqualsStrength

public static void setEqualsStrength(int strength,
                                     int equalsStrengthPassword)
Control how to compare two FuzzyValues for fuzzy equality with the 'equals' method. Normally for the two FuzzyValues to be 'equal' (using the equals method), they must have the same FuzzyVariable and their fuzzy sets must also be equal. Note that this 'definition' of equality is useful and natural in most contexts. However, sometimes a weaker condition is useful (where 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 (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.

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.

Parameters:
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.
Returns:
none

getEqualsStrength

public static int getEqualsStrength()
Returns the value of the current setting for the strength with which the equals method compares FuzzyValues. Will always be one of FuzzyValue.WEAK_EQUALS or FuzzyValue.STRONG_EQUALS and except in exceptional circumstances will be the default, FuzzyValue.STRONG_EQUALS.

Returns:
returns FuzzyValue.WEAK_EQUALS or FuzzyValue.STRONG_EQUALS.

equals

public boolean equals(java.lang.Object v)
Compare two FuzzyValues for a fuzzy equality. For the two FuzzyValues to be 'equal' they must have the same FuzzyVariable and their fuzzy sets must also be equal. Note that this 'definition' of equality is useful and natural in most contexts.

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).

Overrides:
equals in class java.lang.Object
Parameters:
v - the object to compare to the FuzzyValue.
Returns:
true if the FuzzyValues are associated with the same FuzzyVariable and identical FuzzySets (default) OR just the same FuzzyVariable (depends on the setting of EqualsStrength).

equalsStar

public boolean equalsStar(java.lang.Object v)
An alternative weak method for comparing two FuzzyValues. To be 'equalsStar' the two FuzzyValues must only have the same FuzzyVariable. This may have use in some limited circumstances. Use this method rather than trying to change the way equals compares the FuzzyValues with setEqualsStrength and getEqualsStrength.

NOTE: This is a change in version 1.10 and later versions of FuzzyJ (previously equalsStar did a strong compare).

Parameters:
v - the object to compare to the FuzzyValue.
Returns:
true if the FuzzyValues are associated with the same FuzzyVariable.
See Also:
FuzzySet

hashCode

public int hashCode()
Return a hashcode value for the FuzzyValue.

Overrides:
hashCode in class java.lang.Object
Returns:
an integer hashCode value determined by the FuzzyVariable associated with the FuzzyValue. This is consistent with equals method.

copyFuzzyValue

public nrc.fuzzy.FuzzyValue copyFuzzyValue()
                                    throws java.lang.CloneNotSupportedException
Returns a copy of this FuzzyValue.

Returns:
a new FuzzyValue object which is the copy of this FuzzyValue.
Throws:
java.lang.CloneNotSupportedException - if this class does not implement the Cloneable interface (which it does, so don't worry about it).

unaryModifyLinguisticExpression

public 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. If the linguistic expression is the default linguistic expression (for unknown linguistic values -- normally ???) then just leave it as the default linguistic expression.

Parameters:
operator - the operator (very, more_or_less, etc.) that was applied
oldLinguisticExpression - the linguistic expression from the fuzzy value that was modified

binaryModifyLinguisticExpression

public 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. If either of the linguistic expressions is the default linguistic expression (for unknown linguistic values -- normally ???) then just set if to the default linguistic expression.

Parameters:
op - the operator (and, or, etc.) that was applied
oldLinguisticExpression1 - the linguistic expression from the 1st fuzzy value
oldLinguisticExpression2 - the linguistic expression from the 2nd fuzzy value

assignFuzzySet

public void assignFuzzySet(nrc.fuzzy.FuzzySet fuzzySet)
                    throws XValueOutsideUODException
Assigns a new FuzzySet to the FuzzyValue. Note that the linguistic expression is no longer valid and will be set to the DEFAULT_LE. Also NOTE that this method will likely be removed ... fuzzyValues should be created with constructors and the unary (modifiers) and binary (union, intersection etc.) supplied.

Parameters:
fuzzySet - the FuzzySet to be assigned.
Throws:
XValueOutsideUODException - if the fuzzy set x values are not within the range of the universe of discourse

fuzzyComplement

public nrc.fuzzy.FuzzyValue fuzzyComplement()
Takes the complement of the 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

Returns:
a new FuzzyValue object that represents the complement of this FuzzyValue.

fuzzyScale

public nrc.fuzzy.FuzzyValue fuzzyScale(double y)
Scale this FuzzyValue. Returns the FuzzyValue which is scaled by:
    yvalue/maxYValueOfSet   
 

Effectively this adjusts the set so that the maximum membership value of the set has the value y and all other membership values are scaled accordingly. If the membership values are all less than y then a copy of the FuzzySet is returned (ie. it scales values down but never up).

Parameters:
y - scaling factor
Returns:
a newly constructed FuzzySet containing the scaled version of this FuzzySet

fuzzyNormalize

public nrc.fuzzy.FuzzyValue fuzzyNormalize()
                                    throws XValueOutsideUODException
Normalizes the 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.

Returns:
a new FuzzyValue object that represents the normalization of this FuzzyValue.
Throws:
XValueOutsideUODException - if the fuzzy set x values are not within the range of the universe of discourse

getSupport

public nrc.fuzzy.IntervalVector getSupport()
Returns the support of this FuzzyValue. The support set of a FuzzyValue (FuzzySet) is the set of x values that have a membership value other than zero. Note that this is identical to a STRONG alpha cut with alpha value of 0.

Returns:
an IntervalVector object which represents the support set of this FuzzyValue.

getAlphaCut

public nrc.fuzzy.IntervalVector getAlphaCut(boolean cutType,
                                            double alpha)
Returns the alpha cut of the FuzzyValue at the membership level specified by the 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.

Parameters:
cutType - Parameters.STRONG for a strong alpha cut or Parameters.WEAK for a weak alpha cut
alpha - 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.
Returns:
the IntervalVector object which represents the alpha cut of this FuzzyValue at the double value of the alpha argument.

getMembership

public double getMembership(double x)
                     throws XValueOutsideUODException
Returns the membership value of the FuzzyValue at the specified x value.

Parameters:
x - the double x value at which the membership value requested will be interpolated
Returns:
the value -1.0 if the FuzzySet of this FuzzyValue has zero points; otherwise, the membership value of the FuzzySet interpolated at the given x value
Throws:
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)

getXforMembership

public double getXforMembership(double m)
                         throws NoXValueForMembershipException
Returns the 1st X value with the specified membership value in the FuzzySet This is done by interpolation. Note that if there are multiple x values with this membership value then the only the 1st X value is returned.
Note that this is most often used to get the X value corresponding to a membership value in a FuzzySet that is strictly increasing from 0.0 to 1.0 or strictly decreasing from 1.0 to 0.0 (e.g. an SFuzzySet or a ZFuzzySet).

Returns:
the 1st X value of the FuzzySet with the specified membership value or exception if the set does not have this membership value
NoXValueForMembershipException

horizontalIntersection

public nrc.fuzzy.FuzzyValue horizontalIntersection(double y)
Returns the horizontal intersection of the FuzzyValue at the membership level specified by the y parameter. Please see the diagram below for a visual depiction. If y is < 0 then y is set to 0.

Parameters:
y - the y value with which the set is being intersected
Returns:
a new FuzzyValue object representing the horizontal intersection for the FuzzyValue with the y value argument

horizontalUnion

public nrc.fuzzy.FuzzyValue horizontalUnion(double y)
Returns the horizontal union of the FuzzySet at the membership level specified by the y parameter. Please see the diagram below for a visual depiction. If y is < 0 then y is set to 0.

Parameters:
y - the y value with which the set is being unioned
Returns:
a new FuzzySet object representing the horizontal union for the FuzzySet with the y value argument

fuzzyIntersection

public nrc.fuzzy.FuzzyValue fuzzyIntersection(java.lang.String linguisticExpression)
                                       throws InvalidLinguisticExpressionException,
                                              XValueOutsideUODException,
                                              IncompatibleFuzzyValuesException
Perform the fuzzy intersection of 2 fuzzy values. The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid. For a visual depiction of the intersection set and more information, please see the documentation for the FuzzySet method fuzzyIntersection(FuzzySet otherSet).

Parameters:
linguisticExpression - a linguistic expression that defines the other fuzzyValue to be used in the intersection operation.
Returns:
a new FuzzyValue that is the intersection of this FuzzyValue and the one passed as a parameter
Throws:
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 valid

fuzzyIntersection

public nrc.fuzzy.FuzzyValue fuzzyIntersection(nrc.fuzzy.FuzzyValue otherValue)
                                       throws XValueOutsideUODException,
                                              IncompatibleFuzzyValuesException
Perform the fuzzy intersection of 2 fuzzy values. The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid. For a visual depiction of the intersection set and more information, please see the documentation for the FuzzySet method fuzzyIntersection(FuzzySet otherSet).

Parameters:
otherValue - the 2nd FuzzyValue for the operation
Returns:
a new FuzzyValue that is the intersection of this FuzzyValue and the one passed as a parameter
Throws:
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

fuzzyUnion

public nrc.fuzzy.FuzzyValue fuzzyUnion(java.lang.String linguisticExpression)
                                throws InvalidLinguisticExpressionException,
                                       XValueOutsideUODException,
                                       IncompatibleFuzzyValuesException
Perform the fuzzy union of 2 fuzzy values. The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid. For a visual depiction of the union and more information, please see the documentation for the FuzzySet method fuzzyUnion(FuzzySet otherSet).

Parameters:
linguisticExpression - a linguistic expression that defines the other fuzzyValue to be used in the union operation.
Returns:
a new FuzzyValue that is the union of this FuzzyValue and the one passed as a parameter
Throws:
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 valid

fuzzyUnion

public nrc.fuzzy.FuzzyValue fuzzyUnion(nrc.fuzzy.FuzzyValue otherValue)
                                throws XValueOutsideUODException,
                                       IncompatibleFuzzyValuesException
Perform the fuzzy union of 2 fuzzy values. The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid. For a visual depiction of the union and more information, please see the documentation for the FuzzySet method fuzzyUnion(FuzzySet otherSet).

Parameters:
otherValue - the 2nd FuzzyValue for the operation
Returns:
a new FuzzyValue that is the union of this FuzzyValue and the one passed as a parameter
Throws:
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

fuzzySum

public nrc.fuzzy.FuzzyValue fuzzySum(java.lang.String linguisticExpression)
                              throws InvalidLinguisticExpressionException,
                                     XValueOutsideUODException,
                                     IncompatibleFuzzyValuesException
Returns the sum of this FuzzyValue with the FuzzyValue argument. The sum of 2 fuzzy sets is a set where the membership (y) value at every x position is the sum of the memberships values of the two sets at the corresponding x values.
The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid.

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.

Parameters:
linguisticExpression - a linguistic expression that defines the other fuzzyValue to be used in the sum operation.
Returns:
a new FuzzyValue that is the sum of this FuzzyValue and the one passed as a parameter
Throws:
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 valid

fuzzySum

public nrc.fuzzy.FuzzyValue fuzzySum(nrc.fuzzy.FuzzyValue otherValue)
                              throws XValueOutsideUODException,
                                     IncompatibleFuzzyValuesException
Returns the sum of this FuzzyValue with the FuzzyValue argument. The sum of 2 fuzzy sets is a set where the membership (y) value at every x position is the sum of the memberships values of the two sets at the corresponding x values.
The fuzzy variables of the 2 fuzzy values must be the same or the operation is not valid.

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.

Parameters:
otherValue - the 2nd FuzzyValue for the sum operation.
Returns:
a new FuzzyValue that is the sum of this FuzzyValue and the one passed as a parameter
Throws:
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

maximumOfIntersection

public double maximumOfIntersection(java.lang.String linguisticExpression)
                             throws InvalidLinguisticExpressionException,
                                    IncompatibleFuzzyValuesException
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).

Parameters:
linguisticExpression - a linguistic expression that defines the other fuzzyValue to be compared to this FuzzyValue
Returns:
the maximum membership value of the intersection between the 2 FuzzyValues
Throws:
InvalidLinguisticExpressionException - if the linguistic expression is not valid
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

maximumOfIntersection

public double maximumOfIntersection(nrc.fuzzy.FuzzyValue otherValue)
                             throws IncompatibleFuzzyValuesException
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).

Parameters:
otherValue - the 2nd FuzzyValue for the operation
Returns:
the maximum membership value of the intersection between the 2 FuzzyValues
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

momentDefuzzify

public double momentDefuzzify()
                       throws InvalidDefuzzifyException,
                              XValuesOutOfOrderException
Moment defuzzification defuzzifies a fuzzy set returning a floating point (double value) that represents the fuzzy set. It calculates the first moment of area of a fuzzy set about the y axis. The set is subdivided into different shapes by partitioning vertically at each point in the set, resulting in rectangles, triangles, and trapezoids. The centre of gravity (moment) and area of each subdivision is calculated using the appropriate formulas for each shape. The first moment of area of the whole set is then:
      sum of ( moment(i) * area(i) )          <-- top
      ------------------------------
          sum of (area(i))                    <-- bottom
  
If the total area is 0 then throw an exception since the moment is not defined.

Returns:
the floating value that is the first moment of the fuzzy set
Throws:
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).

centerOfAreaDefuzzify

public double centerOfAreaDefuzzify()
                             throws InvalidDefuzzifyException,
                                    XValuesOutOfOrderException
Center of Area (COA) defuzzification defuzzifies a fuzzy set returning a floating point (double value) that represents the fuzzy set. It calculates the x value that spilts the fuzzy set so that there is an equal area on either side of the x value. The set is subdivided into different shapes by partitioning vertically at each point in the set, resulting in rectangles, triangles, and trapezoids.
If the total area is 0 then throw an exception since the center of area is not defined.

Returns:
the floating value that is the center of area (COA) of the fuzzy set
Throws:
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.

weightedAverageDefuzzify

public double weightedAverageDefuzzify()
                                throws XValuesOutOfOrderException,
                                       InvalidDefuzzifyException
Finds the weighted average of the values of a fuzzy set as the defuzzification value. This is slightly different than the maximumDefuzzify since tha maximumDefuzzify uses only points that have the same membership value (the one that is the maximum in the set of points). The weightedAverageDefuzzify uses all of the points with non-zero membership values and calculates the average of the x values using the membership values as weights in this average. NOTE: This doesn't always work well because there can be x ranges where the y value is constant at the max value and other places where the max is only reached for a single x value. When this happens the single value gets too much of a say in the defuzzified value. So use moment defuzzify in cases like this.
             /------\                   /\
            /        \                 /  \
         --/          \---------------/    \-------------
                 ^       ^
                 |       |
                 |       | 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.57

 
Centre of gravity (moment) defuzzify is likely more useful most of the time.

Returns:
the floating value that is the weighted average of the fuzzy set
Throws:
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).

maximumDefuzzify

public double maximumDefuzzify()
                        throws XValuesOutOfOrderException,
                               InvalidDefuzzifyException
Finds the mean of maxima of a fuzzy set as the defuzzification value. NOTE: This doesn't always work well because there can be x ranges where the y value is constant at the max value and other places where the max is only reached for a single x value. When this happens the single value gets too much of a say in the defuzzified value. So use moment defuzzify in cases like this.
             /------\                   /\
            /        \                 /  \
         --/          \---------------/    \-------------
                 ^       ^
                 |       |
                 |       | gives this as the mean of maximum
                 | this is more reasonable???

 
Centre of gravity (moment) defuzzify is likely more useful most of the time.

Returns:
the floating value that is the mean of the maximum values of the fuzzy set
Throws:
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).

fuzzyMatch

public boolean fuzzyMatch(java.lang.String linguisticExpression)
                   throws InvalidLinguisticExpressionException,
                          IncompatibleFuzzyValuesException
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by the FuzzyValue class variable matchThreshold.

Parameters:
linguisticExpression - a linguistic expression that defines the other fuzzyValue to be compared to this FuzzyValue
Returns:
true if the fuzy values overlap else false
Throws:
InvalidLinguisticExpressionException - if the linguistic expression is not valid
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

fuzzyMatch

public boolean fuzzyMatch(java.lang.String linguisticExpression,
                          double threshold)
                   throws InvalidLinguisticExpressionException,
                          IncompatibleFuzzyValuesException
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by parameter 'threshold'. The threshold is restricted to a value between 0 and 1.

Parameters:
threshold - determines the value above which a match is considered to be true, over-riding the class variable matchThreshold value.
Returns:
true if the fuzy values overlap else false
Throws:
InvalidLinguisticExpressionException - if the linguistic expression is not valid
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

fuzzyMatch

public boolean fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue)
                   throws IncompatibleFuzzyValuesException
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by the FuzzyValue class variable matchThreshold. The threshold is restricted to a value between 0 and 1.

Parameters:
otherValue - the 2nd FuzzyValue for the operation
Returns:
true if the fuzy values overlap else false
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

fuzzyMatch

public boolean fuzzyMatch(nrc.fuzzy.FuzzyValue otherValue,
                          double threshold)
                   throws IncompatibleFuzzyValuesException
Determine if 2 FuzzyValues 'match' or intersect with a membership of at least that specified by parameter threshold. The threshold is restricted to a value between 0 and 1.

Parameters:
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.
Returns:
true if the fuzy values overlap else false
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done

similarity

public double similarity(nrc.fuzzy.FuzzyValue fv)
                  throws IncompatibleFuzzyValuesException
SIMILARITY: calculates a similarity measure between two fuzzy values using the default similarity operator. The original default similarity operator is the SimilarityByPossibilityOperator. This can be changed using the setDefaultSimilarityOperator method of the FuzzyValue class.

Note: the 2 fuzzy values must have the same Fuzzy variable

Parameters:
fv - the fuzzy value with which this fuzzy value is compared
Returns:
The similarity value for the 2 fuzzy values
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done
See Also:
SimilarityByAreaOperator, SimilarityByPossibilityOperator

similarity

public double similarity(nrc.fuzzy.FuzzyValue fv,
                         nrc.fuzzy.SimilarityOperator simOp)
                  throws IncompatibleFuzzyValuesException
SIMILARITY: calculates a similarity measure between two fuzzy values using a specified similarity operator.

Note: the 2 fuzzy values must have the same Fuzzy variable

Parameters:
fv - the fuzzy value with which this fuzzy value is compared
simOp - the SimilarityOperator to use to calculate the similarity
Returns:
The similarity value for the 2 fuzzy values
Throws:
IncompatibleFuzzyValuesException - if the fuzzy values do not have identical fuzzy variables the operation cannot be done
See Also:
SimilarityByAreaOperator, SimilarityByPossibilityOperator

setDefaultSimilarityOperator

public static void setDefaultSimilarityOperator(nrc.fuzzy.SimilarityOperator simOp)
Set the default similarity operator that will be used by the FuzzyValue similarity method.

Parameters:
simOp - is the similarity operator to be used when the FuzzyValue method similarity is called.

getDefaultSimilarityOperator

public static nrc.fuzzy.SimilarityOperator getDefaultSimilarityOperator()
Get the default similarity operator that is used by the FuzzyValue similarity method.


setConfineFuzzySetsToUOD

public 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. Normally this is false.

Parameters:
b - true if f FuzzySets will be confined to lie within the UOD when constructing FuzzyValues.

isConfineFuzzySetsToUOD

public static boolean isConfineFuzzySetsToUOD()
Returns true if FuzzySets will be confined to lie within the Universe of Discourse (UOD) when FuzzyValues are constructed. Normally this is false.

Returns:
true if f FuzzySets will be confined to lie within the UOD when constructing FuzzyValues.

isEmpty

public 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.

Returns:
true if this FuzzyValue is empty

isConvex

public boolean isConvex()
Returns true if this FuzzyValue is convex. The definition of convex is that the membership function of a convex FuzzyValue (FuzzySet) does not go "up-and-down" more than once.

Returns:
true if this FuzzyValue is convex

isNormal

public boolean isNormal()
Returns true if this FuzzyValue is normal. The definition of normal is that there is at least one point in the universe of discourse where the membership function reaches unity (in terms of this fuzzy package, unity is equal to 1.0).

Returns:
true if this FuzzyValue is normal

size

public int size()
Returns the size of the FuzzyValue; in other words, the number of points contained in the FuzzySet.

Returns:
the int value specifying the size of the FuzzyValue, or the number of points contained in the FuzzyValue.

getX

public double getX(int index)
Returns the x value of the point in the FuzzyValue at the specified index. As usual, the indices begin at 0, so the x value of the first point in the FuzzyValue can be accessed with the following method call: fuzzyValueInstanceName.getX(0)

Parameters:
index - the 0 based index into the fuzzy set points of the fuzzy value.
Returns:
the double x value of the point in the FuzzyValue at the specified index.

getY

public double getY(int index)
Returns the y value of the point in the FuzzyValue at the specified index. As usual, the indices begin at 0, so the y value of the first point in the FuzzyValue can be accessed with the following method call: fuzzyValueInstanceName.getY(0)

Parameters:
index - the 0 based index into the fuzzy set points of the fuzzy value.
Returns:
the double y value of the point in the FuzzyValue at the specified index.

getMaxY

public double getMaxY()
Returns the maximum membership value of the FuzzySet.

Returns:
the double value representing the maximum membership value of the FuzzySet

getMinY

public double getMinY()
Returns the minimum membership value of the FuzzySet.

Returns:
the double value representing the minimum membership value of the FuzzySet

toString

public java.lang.String toString()
Returns the String representation of the FuzzyValue.

For example:

 FuzzyVariable         -> TEMPERATURE [0, 60] Degree Celsius
 Linguistic Expression -> HOT 
 FuzzySet              -> { 0/30 1/45 0/60}
 

Overrides:
toString in class java.lang.Object
Returns:
the String representation of the FuzzyValue

getFuzzyVariable

public nrc.fuzzy.FuzzyVariable getFuzzyVariable()
Returns the FuzzyVariable to which this FuzzyValue belongs.

Returns:
the FuzzyVariable to which this FuzzyValue belongs, and within whose whose definition the FuzzyValue has meaning.

getFuzzySet

public nrc.fuzzy.FuzzySet getFuzzySet()
Returns the FuzzySet that is contained within this FuzzyValue.

Returns:
the FuzzySet belonging to this FuzzyValue

getUnits

public java.lang.String getUnits()
Returns the units of the FuzzyVariable to which this FuzzyValue belongs, and therefore the units of this FuzzyValue.

Returns:
the String value that represents the units of this FuzzyValue.

getMinUOD

public 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.


getMaxUOD

public 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.


setLinguisticExpression

public void setLinguisticExpression(java.lang.String lexpr)
Sets the String which represents the linguistic expression of this FuzzyValue. Note: be careful when using this since the expression should be a true representation for the FuzzyValue. A common place to use this might be if a FuzzyValue is created with no linguistic expression (using a specified Fuzzyset for example) and the user wanted to add one for that FuzzySet.

Parameters:
lexpr - the linguistic expression to replace the current one

getLinguisticExpression

public java.lang.String getLinguisticExpression()
Returns the String which represents the linguistic expression of this FuzzyValue.

Returns:
the String which represents the linguistic expression of this FuzzyValue.

isAnyXValueOutsideUOD

public 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.

Parameters:
fs - the fuzzy set to be checked
fvar - the fuzzy variable with the UOD definition
Returns:
true if any X value is outside of the UOD range.

isXValueOutsideUOD

public 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.

Parameters:
x - the x value being tested to be within the range of the UOD
fvar - the fuzzy variable that defines the UOD
Returns:
true if the x value argument passed is outside of the Universe of Discourse.

getMatchThreshold

public static double getMatchThreshold()
Returns the current matchThreshold which is used when comparing fuzzy values with the fuzzyMatch method.

Returns:
the matchThreshold.

setMatchThreshold

public static void setMatchThreshold(double value)
Sets the current default matchThreshold which is used when comparing fuzzy values with the fuzzyMatch method.

Parameters:
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.

plotFuzzyValue

public 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. The string must be displayed using a non-proportional spaced font. Consider the following example:

   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


plotFuzzyValue

public java.lang.String plotFuzzyValue(java.lang.String plotChar)
Plots the fuzzy value in an ascii format producing a String that can be displayed. The string must be displayed using a non-proportional spaced font. The low X and high X values of the plot are upper and lower values of the universe of discourse for the FuzzyValue.

See plotFuzzyValue( String plotChars, double lowX, double highX ) for an example.


plotFuzzyValues

public 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. The string must be displayed using a non-proportional spaced font. The low X and high X values of the plot are upper and lower values of the universe of discourse for the FuzzyValues. The string of plotting characters are used in sequence to plot the corresponding fuzzy value. If the string is empty the character '*' is used. If the string has fewer characters than fuzzy values, the last character is reused. All FuzzyValues must be from the same FuzzyVariable.

See plotFuzzyValues( String plotChars, double lowX, double highX, FuzzyValue fvals[]) for an example.

Parameters:
plotChars - characters to use for plotting (normally *, +, ., etc)

plotFuzzyValues

public 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. The string must be displayed using a non-proportional spaced font. The string of plotting characters are used in sequence to plot the corresponding fuzzy value. If the string is empty the character '*' is used. If the string has fewer characters than fuzzy values, the last character is reused. All FuzzyValues must be from the same FuzzyVariable. Consider the following example:

   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 
 

Parameters:
plotChars - characters to use for plotting (normally *, +, ., etc)