A Visual Guide To Modifiers
Creating User-defined Modifiers
Linguistic Expression Grammar
Examples in Java code
Adding User Defined Modifiers
A modifier may be used to further enhance the ability to describe our fuzzy concepts. Modifiers (very, slightly, etc.) used in phrases such as very hot or slightly cold change (modify) the shape of a fuzzy set in a way that suits the meaning of the word used. These modifiers are commonly referred to as hedges. The Fuzzy Toolkit has a set of predefined modifiers that can be used at any time to describe fuzzy concepts when defining fuzzy terms in fuzzy variables and in the creation fuzzy values. For complete details of modifiers see the class description for ModifierFunction and the individual class descriptions for each modifier in the API documentation.
These modifiers change the shape of a fuzzy set using mathematical operations on each point of the set. Note that when a modifier is used it is not case sensitive so it can be used in upper or lower case (NOT or not) or even a mix of cases (NoT).
Unmodified Fuzzy Set
This FuzzyValue has not yet been modified. It will be the
FuzzyValue to which the modifiers are applied for all of the following examples
except 'norm'.
Not
The NOT modifier returns the complement of the FuzzyValue passed as its
argument: y(x) = 1 - y(x)
Norm
The NORM modifier returns the normalized FuzzyValue. Normalizing the FuzzyValue
refers to scaling it so that at least one point on the FuzzyValue has a
membership value of 1.0.
Before Normalization After Normalization
More_Or_Less
The MORE_OR_LESS modifier returns the expanded FuzzyValue passed as its
argument, having raised all the membership values of the FuzzyValue by a factor
of 1/3.
Somewhat
The SOMEWHAT modifier returns the expanded FuzzyValue passed as its argument,
having raised all the membership values of the FuzzyValue by a factor of 1/2.
Plus
The PLUS modifier returns the expanded FuzzyValue passed as its argument,
having raised all the membership values of the FuzzyValue by a factor of 1.25.
Very
The VERY modifier returns the expanded FuzzyValue passed as its argument,
having raised all the membership values of the FuzzyValue by a factor of 2.
Extremely
The EXTREMELY modifier returns the expanded FuzzyValue passed as its argument, having raised all the membership values of the FuzzyValue by a factor of 3.
Slightly
The SLIGHTLY modifier returns the expanded FuzzyValue A passed as its argument,
having performed the following modifications on it:
intensify [ norm
(plus A AND not very A) ]
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. Intensify( PLUS FuzzyValue AND NOT VERY FuzzyValue )
Intensify
The INTENSIFY modifier returns the expanded FuzzyValue passed as its argument,
having having performed the following modifications on it:
if (0.0 <= y <= 0.5), y = 2*y2
if (0.5 < y <= 1.0), y = 1 - 2*(1-y)2
This has the effect of emphasizing the sections of the FuzzyValue that have a membership value greater than 0.5, and understating any sections of the FuzzyValue with a membership value less than or equal to 0.5.
Above
The ABOVE modifier identifies the first x value at which the maximum value is
reached. All membership values below this point are set to zero and all
membership values above this value are set to 1-y. For convex fuzzy sets this
gives an intuitive result.
Below
The BELOW modifier identifies the first x value at which the maximum value is
reached. All membership values above this point are set to zero and all
membership values below this value are set to 1-y. For convex fuzzy sets this
gives an intuitive result.
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
described in the API
documentation for the class ModifierFunction.
The BNF description of the syntax of linguistic expressions can be written as:
<LExpr>
::= <LTerm> | <LExpr> OR <LTerm>
<LTerm>
::= <modExpr> | <LTerm> AND <modExpr>
<modExpr>
::= MODIFIER <modExpr> | <element>
<element>
::= PRIMARY-TERM | ( <LExpr> )
where
MODIFIER is a valid system supplied or user defined modifier (not,
very, etc. as described above)
PRIMARY-TERM is a term defined in the fuzzy variable
Note that this gives and higher precedence than or and that modifiers are basically unary operators with the highest precedence. One can control the order of the expression evaluation through the use of parenthesis ( and ). Also note that linguistic expressions are case insensitive, that is to say that modifiers and terms are all coverted to upper case and the operators OR and AND can be in upper, lower or mixed case.
This allows one to write expressions such as:
very hot OR slightly cold
cold and warm or very hot
Below are some examples extracted from Java and Jess code showing the use of modifiers and linguistic expressions.
// creation of fuzzy values
fval2 = new FuzzyValue(temp, "not hot");
fval2 = new FuzzyValue( pressure, "low or medium");
// fuzzy values for antecedents and conclusions of rules
FuzzyRule hotLow = new FuzzyRule();
hotLow.addAntecedent(new FuzzyValue(outTemp,"hot"));
hotLow.addAntecedent(new FuzzyValue(outFlow,"low"));
hotLow.addConclusion(new FuzzyValue(hotValveChange,"Z"));
hotLow.addConclusion(new FuzzyValue(coldValveChange,"PB"));
;;
in Jess rules, pattern matching and asserting facts with FuzzyValues
(defrule cold_low
(temp
?t&:(fuzzy-match ?t "cold"))
(flow
?f&:(fuzzy-match ?f "low"))
=>
(assert
(change_hv (new nrc.fuzzy.FuzzyValue ?*hotValveChangeFvar* "PB"))
(change_cv (new nrc.fuzzy.FuzzyValue ?*coldValveChangeFvar* "Z"))
)
)
There are a large number of system supplied modifiers but it
is possible that users will find a need to define some special modifier in their
work. The techniques to do this are covered in the Fuzzy Toolkit API
documentation under the ModifierFunction
class.