|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nrc.fuzzy.FuzzyValueVector
The FuzzyValueVector
class implements a growable array
of FuzzyValues. Like an array, the values can be accessed using an
integer index. However, the size of a FuzzyValueVector can
grow as needed to accommodate the addition of Intervals after the
FuzzyValueVector has been created.
A FuzzyValueVector is the used within the fuzzy package to store the
antecedents and conclusions of in a FuzzyRule.
Field Summary | |
protected nrc.fuzzy.FuzzyValue[] |
fuzzyValues
The array of FuzzyValue values. |
protected int |
increment
The increment amount by which the FuzzyValueVector expands when it reaches capacity and has to insert another FuzzyValue. |
protected int |
index
The current number of FuzzyValues in the array, and the index of the array at which the next FuzzyValue should be inserted. |
protected static int |
INITIAL_CAPACITY
The default initial capacity of the FuzzyValueVector. |
Constructor Summary | |
FuzzyValueVector()
Creates an empty FuzzyValueVector with the default initial capacity and increment values. |
|
FuzzyValueVector(nrc.fuzzy.FuzzyValue[] FuzzyValueArray,
int length)
Creates a FuzzyValueVector with the length specified in the parameters, and initialized for the full length of the FuzzyValueVector from the FuzzyValue values contained in the passed array. |
|
FuzzyValueVector(int initialCapacity)
Creates an empty FuzzyValueVector with the specified initial capacity and the default increment value. |
|
FuzzyValueVector(int initialCapacity,
int increment)
Creates an empty FuzzyValueVector with the specified initial capacity and increment value. |
Method Summary | |
void |
addFuzzyValue(nrc.fuzzy.FuzzyValue fuzzyValue)
Adds a FuzzyValue to the end of the FuzzyValueVector, increasing its size by one. |
double |
centerOfAreaDefuzzify()
Center of Area (COA) defuzzification defuzzifies a FuzzyVector of fuzzy sets returning a floating point (double value) that represents crips value of these fuzzy sets. |
void |
concat(nrc.fuzzy.FuzzyValueVector other)
Concatenates the FuzzyValueVector argument with this FuzzyValueVector. |
nrc.fuzzy.FuzzyValue |
fuzzyIntersection()
Returns a FuzzyValue that is the intersection of all of the FuzzyValues that this FuzzyValueVector contains. |
nrc.fuzzy.FuzzyValue |
fuzzyUnion()
Returns a FuzzyValue that is the union of all of the FuzzyValues that this FuzzyValueVector contains. |
nrc.fuzzy.FuzzyValue |
fuzzyValueAt(int i)
Returns the FuzzyValue at the specified index. |
void |
insertFuzzyValueAt(nrc.fuzzy.FuzzyValue fuzzyValue,
int i)
Inserts the FuzzyValue argument into the FuzzyValueVector at the specified index. |
boolean |
isEmpty()
Tests whether or not the FuzzyValueVector is empty, ie. |
double |
maximumDefuzzify()
Finds the mean of maxima of the x-values in all of the FuzzySets in the FuzzyValues of the FuzzyValueVector. |
double |
momentDefuzzify()
Moment defuzzification defuzzifies a FuzzyVector of FuzzySets returning a floating point (double value) that represents the moment of these FuzzySets. |
void |
removeFuzzyValueAt(int i)
Removes the FuzzyValue from the FuzzyValueVector at the specified index. |
void |
setFuzzyValueAt(nrc.fuzzy.FuzzyValue fuzzyValue,
int i)
Sets the FuzzyValue in the FuzzyValueVector at the specified index. |
int |
size()
Returns the size of the FuzzyValueVector, or the number of FuzzyValues in the FuzzyValueVector. |
nrc.fuzzy.FuzzyValue[] |
toFuzzyValueArray()
Returns the array of FuzzyValues, trimmed to size, that this FuzzyValueVector contains. |
java.lang.String |
toString()
|
void |
trimToSize()
Trims the capacity of this FuzzyValueVector to be the FuzzyValueVector's current size. |
double |
weightedAverageDefuzzify()
Finds the weighted average of the x-values in all of the FuzzySets in the FuzzyValues of the FuzzyValueVector. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final int INITIAL_CAPACITY
protected int increment
protected nrc.fuzzy.FuzzyValue[] fuzzyValues
protected int index
Constructor Detail |
public FuzzyValueVector()
public FuzzyValueVector(int initialCapacity)
initialCapacity
- the int which specifies the desired initial capacity of
the FuzzyValueVector. This is best used when it is known that
the FuzzyValueVector will be quite large so as to avoid multiple
expansions of the FuzzyValueVector, which is inefficient.public FuzzyValueVector(int initialCapacity, int increment)
initialCapacity
- the int to specify the desired initial capacity of
the FuzzyValueVector. This is best used when it is known that
the FuzzyValueVector will be quite large so as to avoid multiple
expansions of the FuzzyValueVector, which is inefficient.increment
- the int to specify the desired increment of the FuzzyValueVectorpublic FuzzyValueVector(nrc.fuzzy.FuzzyValue[] FuzzyValueArray, int length)
FuzzyValueArray
- the array of FuzzyValues which contains the FuzzyValues
with which to initialize the FuzzyValueVector.length
- this parameter is basically equivalent to the initial
capacity parameter in the other constructors. However,
it has one additional implication. It is expected
that length
is less than or equal to the length of
FuzzyValueArray
.
java.lang.ArrayIndexOutOfBoundsException
- if the length
parameter is
greater than the length of FuzzyValueArray
.Method Detail |
public void addFuzzyValue(nrc.fuzzy.FuzzyValue fuzzyValue)
public void concat(nrc.fuzzy.FuzzyValueVector other)
other
- the FuzzyValueVector to concatenate onto the end of
this FuzzyValueVectorpublic nrc.fuzzy.FuzzyValue fuzzyValueAt(int i)
i
- the index in the FuzzyValueVector of the desired
FuzzyValue
public void setFuzzyValueAt(nrc.fuzzy.FuzzyValue fuzzyValue, int i)
i
- the index in the FuzzyValueVector of the FuzzyValue position
that is desired to be setpublic void removeFuzzyValueAt(int i)
i
- the position of the FuzzyValue to removepublic void insertFuzzyValueAt(nrc.fuzzy.FuzzyValue fuzzyValue, int i)
i
- the index position of the FuzzyValueVector into which the
FuzzyValue argument is to be insertedpublic void trimToSize()
public int size()
public boolean isEmpty()
true
if the FuzzyValueVector is empty, if
it contains zero FuzzyValuespublic nrc.fuzzy.FuzzyValue[] toFuzzyValueArray()
public java.lang.String toString()
toString
in class java.lang.Object
public nrc.fuzzy.FuzzyValue fuzzyUnion() throws XValueOutsideUODException, IncompatibleFuzzyValuesException
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 fuzzyIntersection() throws XValueOutsideUODException, IncompatibleFuzzyValuesException
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 weightedAverageDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException, IncompatibleFuzzyValuesException
/------\ /\ / \ / \ --/ \---------------/ \------------- ^ ^ | | | | 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(s)
XValuesOutOfOrderException
- occurs when the MinUOD is
greater than or equal to the MaxUOD parameter (this
should never happen).
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables or there are no FuzzyValues
in the FuzzyValueVector the operation cannot be donepublic double maximumDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException, IncompatibleFuzzyValuesException
/------\ /\ / \ / \ --/ \---------------/ \------------- ^ ^ | | | | gives this as the mean of maximum | this is more reasonable???
InvalidDefuzzifyException
- there are no points in the FuzzySet
XValuesOutOfOrderException
- occurs when the xMin parameter is
greater than or equal to the xMax parameter.
IncompatibleFuzzyValuesException
- if the fuzzy values do not have
identical fuzzy variables or there are no FuzzyValues
in the FuzzyValueVector the operation cannot be donepublic double momentDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException, IncompatibleFuzzyValuesException
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 xMin parameter is
greater than or equal to the xMax parameter.
IncompatibleFuzzyValuesException
public double centerOfAreaDefuzzify() throws XValuesOutOfOrderException, InvalidDefuzzifyException, IncompatibleFuzzyValuesException, XValueOutsideUODException
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.
IncompatibleFuzzyValuesException
XValueOutsideUODException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |