|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nrc.fuzzy.ModifierFunction
The abstract ModifierFunction
class along with the concrete
implementations of this class encapsulate the set of Modifiers (or Hedges)
available to operate on fuzzy values or fuzzy sets. Each concrete
modifier function class provides two 'call' methods that
accept as a parameter either a FuzzyValue or a FuzzySet. The method
creates a new FuzzyValue or FuzzySet who's value represents the application of the
linguistic modifier to the fuzzy set.
Many of the modifiers are applied by raising the membership values of the
fuzzy set points to a certain exponent. For example, the modifier very
is implemented in this manner using the exponent 2. However, consider
the case where the fuzzy set being modified consists of
{0.0/1 1.0/2 0.0/3}. In this case, the membership values, at x=1, x=2 and x=3, do
not change, regardless of the value of the exponent.
However, if an additional point is inserted in this fuzzy set so that it now
consists of {0.0/1 0.5/2.5 1.0/2 0.0/3}, and the modifier very
is
applied, the point that was originally 0.5/2.5 will now become 0.25/2.5. If we
insert other additional points at arbitrary x values along the FuzzyValue, it will
be found that unless the membership value of these arbitrary points is 1.0 or 0.0, the
membership value will change as a result of the application of the exponent.
Because the representation of the membership function is a set of points that are joined by straight lines, it may be necessary to add additional points to the fuzzy set to enhance the precision to the resulting fuzzy set.
The points added to the fuzzy set before the application of an exponential modifier, and hence the precision of the result, can be controlled by the user in three different ways. The user can specify:
setDeltaXPrecision
method. For example, if the user specifies
a delta x precision of 0.1, a new point will be added at approximately
every 0.1 x value increment between existing points.
setDeltaYPrecision
method. Similar to delta x, a new
point will be added per specified y increment.
setNumberOfPointsPrecision
method.
It is interesting to note that these precisions are, in fact, imprecise themselves. To accomodate each individual FuzzyValue and try to add points with as even a spacing as possible, a specified delta x of 0.1 might be functionally applied as 0.9555, or a specified 20 additional points to add might be changed to 22 by the program.
Although the methods setDeltaXPrecision
, setDeltaYPrecision
,
and setNumberOfPointsPrecision
determine the spacing for each of
the 3 possible fuzzy expanding techniques, only one of them is used at any time.
Which of these techniques is used is controlled by the method
setPrecisionControlType
. It takes as an argument one of the following
constant values: DELTA_X, DELTA_Y, or NUMBER_OF_POINTS.
The following is a visual guide to the built-in (system supplied)
modifiers available to users.
Modifiers | Visual Representation |
---|---|
Unmodified:
|
|
Not:
|
|
Norm:
|
|
More_Or_Less:
|
|
Somewhat:
|
|
Plus:
|
|
Very:
|
|
Extremely:
|
|
Slightly:
|
|
Consider the partial breakdown, shown below, of this
example. On the left, directly below, is shown this
FuzzyValue after applying the plus modifier.
On the right is this FuzzyValue after applying both the
not and the very modifiers.
Below these is depicted plus FuzzyValue AND not
very FuzzyValue , showing the portion of the FuzzyValue
that is selected which intuitively matches our linguistic
understanding of the word "slightly".
|
|
PLUS | NOT VERY |
Now, put them together.
PLUS FuzzyValue AND NOT VERY FuzzyValue |
|
Intensify:
|
|
Above:
|
|
Below:
|
Each individual fuzzy modifier is created as a subclass of the ModifierFunction class. If created according to the instructions provided these fuzzy modifer classes when Constructed will automatically call the Modifiers.add method to add themselves to the list of available modifiers. So the preferred way to add new modifiers is:
public class VeryModifier extends ModifierFunction
{
public VeryModifier() // use a default name for the modifier
{
// required to set the name of the modifier
// and add to list in Modifiers class
super( "very" );
}
public VeryModifier(String s) // use a supplied name for the modifier
{
// required to set the name of the modifier
// and add to list in Modifiers class
super( s );
}
public FuzzyValue call(FuzzyValue fv)
{
FuzzyValue fvNew = null;
// executes the 'call' method below for FuzzySet to do the modifier function
FuzzySet fs = call(fv.getFuzzySet());
try {
fvNew = new FuzzyValue(fv.getFuzzyVariable(), fs);
}
catch (XValueOutsideUODException e)
{ // we know that the modifers like 'very' do not expand the x value range
// of the fuzzy set so if get this exception there must be an internal error
System.err.println("Internal error in Modifier function '"+getName()+
"': " + e);
System.exit(100);
}
// must do this to set the linguistic expression for the new fuzzy value
fvNew.unaryModifyLinguisticExpression(getName(), fv.getLinguisticExpression());
return(fvNew);
}
public FuzzySet call(FuzzySet fs)
{ // the real work is done here -- on the fuzzy set
return(concentrateDilute(fs, 2.0));
}
}
myVeryMod = new VeryModifier("very");
...
aModifiedFuzzyValue = myVeryMod.call(aFuzzyValue);
OR
String mod = "very";
...
aModifiedFuzzyValue = Modifers.call(mod, aFuzzyValue);
The second form uses the Modifiers class to perform a 'variable' modifier method and
is used internally by the fuzzy package when creating fuzzy values or
fuzzy terms using 'linguistic expressions'.
For convenience an instance of each of the built-in (system supplied) modifiers is created in the Modifiers class and a method is created for each one allowing them to be accessed in a simpler fashion:
aModifiedFuzzyValue = Modifers.very(aFuzzyValue);
NOTE: all modifier names are case insensitive ('very' is the same as 'VERY')
Modifiers
,
Serialized FormField Summary | |
static int |
DELTA_X
A constant used in setting the precisionControlType so that delta x spacing will be used when expanding fuzzy sets |
static int |
DELTA_Y
A constant used in setting the precisionControlType so that delta y spacing will be used when expanding fuzzy sets |
protected static double |
deltaX
This class variable represents a delta x spacing to be used in the expansion of the FuzzyValue/FuzzySet as required by certain fuzzy modifier functions. |
protected static double |
deltaY
This class variable represents a delta y spacing to be used in the expansion of the FuzzyValue/FuzzySet as required by certain fuzzy modifier functions. |
static int |
NUMBER_OF_POINTS
A constant used in setting the precisionControlType so that number of points setting will be used when expanding fuzzy sets |
protected static int |
numberOfPoints
This class variable represents the number of points to be used in the expansion of the FuzzyValue/FuzzySet as required by certain fuzzy modifier functions. |
protected static int |
precisionControlType
This class variable designates the type of precision control to be used in the expansion of fuzzy sets. |
Constructor Summary | |
ModifierFunction(java.lang.String name)
All Modifier Functions must have a String name that they are known by so they can be used in linguistic expressions such as "very cold". |
Method Summary | |
abstract nrc.fuzzy.FuzzySet |
call(nrc.fuzzy.FuzzySet fs)
A concrete implementation of a Modifier Function will need to supply this method, since it will be called to perform the modifier operation on the Fuzzy Set. |
abstract nrc.fuzzy.FuzzyValue |
call(nrc.fuzzy.FuzzyValue fv)
A concrete implementation of a Modifier Function will need to supply this method, since it will be called to perform the modifier operation on the Fuzzy Value. |
static nrc.fuzzy.FuzzySet |
concentrateDilute(nrc.fuzzy.FuzzySet a,
double power)
Returns a new FuzzySet object which represents the expansion of the FuzzySet argument, with all the membership values raised to the specified power. |
static nrc.fuzzy.FuzzySet |
expandSet(nrc.fuzzy.FuzzySet a)
This method expands a fuzzy set to (possibly) include more points as required for the implementation of certain fuzzy modifier functions. |
java.lang.String |
getName()
Retrieves the string name of the ModifierFunction. |
static void |
setDeltaXPrecision(double precision)
Sets the delta x precision value used for fuzzy set expansion. |
static void |
setDeltaYPrecision(double precision)
Sets the delta y precision value for fuzzy set expansion. |
static void |
setNumberOfPointsPrecision(int numPoints)
Sets the number of points used for FuzzyValue/FuzzySet expansion. |
static void |
setPrecisionControlType(int type)
Sets the type of precision control that will be used by the expandSet method that expands the number of points in a fuzzy set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static double deltaX
expandSet(nrc.fuzzy.FuzzySet)
,
precisionControlType
,
Modifiers
protected static double deltaY
expandSet(nrc.fuzzy.FuzzySet)
,
precisionControlType
,
Modifiers
protected static int numberOfPoints
expandSet(nrc.fuzzy.FuzzySet)
,
precisionControlType
,
Modifiers
protected static int precisionControlType
expandSet(nrc.fuzzy.FuzzySet)
,
Modifiers
public static final int DELTA_X
precisionControlType
,
Constant Field Valuespublic static final int DELTA_Y
precisionControlType
,
Constant Field Valuespublic static final int NUMBER_OF_POINTS
precisionControlType
,
Constant Field ValuesConstructor Detail |
public ModifierFunction(java.lang.String name)
VeryModifier( String s ) { super(s); }
(/pre> The super constructor will take care of recording the string name of the modifier in the class and will also add the modifier to the list (hash table) of modifiers in the Modifiers class.
Modifiers
Method Detail |
public static void setDeltaXPrecision(double precision)
setPrecisionControlType
method must also
be used.
precision
- the value of the desired precision for expanding FuzzyValues/FuzzySets.
For example, if this argument has the value
0.1, additional points will be added to the FuzzyValue at
x increments of approximately 0.1.expandSet(nrc.fuzzy.FuzzySet)
,
Modifiers
,
precisionControlType
public static void setDeltaYPrecision(double precision)
setPrecisionControlType
method should
be used.
precision
- the value of the desired precision for expanding FuzzyValues/FuzzySets.
For example, if this argument has the value
0.1, additional points will be added to the FuzzyValue/FuzzySet at
y increments of approximately 0.1.expandSet(nrc.fuzzy.FuzzySet)
,
Modifiers
,
precisionControlType
public static void setNumberOfPointsPrecision(int numPoints)
setPrecisionControlType
method must also
be used.
numPoints
- the desired integer number of points to be added to each
FuzzyValue. Must be > 4.expandSet(nrc.fuzzy.FuzzySet)
,
Modifiers
,
precisionControlType
public static void setPrecisionControlType(int type)
Note that setting the individual precisions does not affect which precision is used in expansion calculations. Only this method designates which type of precision control will be used.
type
- the precision control type desired for the expansion of the
FuzzyValue, if expansion is required. This argument must
be one of the following constants: DELTA_X, DELTA_Y,
NUMBER_OF_POINTS.expandSet(nrc.fuzzy.FuzzySet)
,
Modifiers
,
precisionControlType
public final java.lang.String getName()
public abstract nrc.fuzzy.FuzzyValue call(nrc.fuzzy.FuzzyValue fv)
fv
- the fuzzy value to be modifiedpublic abstract nrc.fuzzy.FuzzySet call(nrc.fuzzy.FuzzySet fs)
fs
- the fuzzy set to be modifiedpublic static nrc.fuzzy.FuzzySet expandSet(nrc.fuzzy.FuzzySet a)
a
- the fuzzy set to be expanded.
Modifiers
,
precisionControlType
,
setPrecisionControlType(int)
public static nrc.fuzzy.FuzzySet concentrateDilute(nrc.fuzzy.FuzzySet a, double power)
a
- the FuzzySet to expand and either concentrate or dilute
via exponential methodspower
- the power (exponent) to which the membership values are raised
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |