The Fuzzy Logic classes (see FuzzyLogic and IFuzzyLogic units) provide a full-featured syntax for creating fuzzy expressions or calculations. Fuzzy expressions create fuzzy sets, which are created by defining the XY value singletons that specify the shape of the fuzzy set, by functions that return a fuzzy singletons shape, or by modifying other fuzzy sets through operations and hedges. Note that fuzzy sets are also called fuzzy terms or fuzzy values in the IECS.
The IECS and fuzzy logic library allow you to define or modify fuzzy sets or values in the following ways:
•Define Fuzzy Sets using Singletons
•Define Fuzzy Sets using Scalars or Functions
•Modify Fuzzy Sets using Hedges
•Define Fuzzy Sets using other Fuzzy Sets and Operations
For our discussion, we are going to assume that a fuzzy variable, temperature, has been defined like so:
> (ppdeftype temperature)
(deftype temperature extends (type FUZZY)
(range 0.0000 100.0000)
(values
(term low ((0.0000 1.0000) (100.0000 0.0000) ))
(term medium (tri 0.0000 50.0000 100.0000))
(term high ((0.0000 0.0000) (100.0000 1.0000) ))
))
which, when graphed, looks like so:
> (plot-fuzzy-value t *+- n n temperature)
Fuzzy Variable: temperature
Fuzzy Values: medium(*) high(+) low(-)
1.0000-- * +
0.9500 -- * * ++
0.9000 --- ** ** +++
0.8500 -- * * ++
0.8000 --- * * +++
0.7500 -- * * ++
0.7000 ---** **+++
0.6500 *-- ++*
0.6000 * --- +++ *
0.5500 * -- ++ *
0.5000 ** --- **
0.4500 * ++ -- *
0.4000 * +++ --- *
0.3500 * ++ -- *
0.3000 ** +++ --- **
0.2500 * ++ -- *
0.2000 * +++ --- *
0.1500 * ++ -- *
0.1000 **+++ ---**
0.0500 *++ --*
0.0000++ -
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
The most simplistic way to define fuzzy sets is to define a singletons vector of XY value pairs. The singletons vector defines a vector of XY value pairs that control the shape of the fuzzy set. The syntax for a singletons vector is:
((x0 y0) (x1 y1)... (xN yN))
For example:
(plot-fuzzy-value t * n n
(create-fuzzy-value temperature ((20.0000 0.0000) (30.0000 0.2222) (40.0000 0.7778) (50.0000 1.0000) (60.0000 0.7778) (70.0000 0.2222) (80.0000 0.0000) )))
Fuzzy Variable: temperature
Fuzzy Values: ((20.0000 0.0000) (30.0000 0.2222) (40.0000 0.7778) (50.0000 1.0000) (60.0000 0.7778) (70.0000 0.2222) (80.0000 0.0000) )(*)
1.0000 *
0.9500 * *
0.9000 * *
0.8500 * *
0.8000 ** **
0.7500
0.7000
0.6500 * *
0.6000
0.5500 * *
0.5000
0.4500 * *
0.4000
0.3500 * *
0.3000
0.2500
0.2000 ** **
0.1500 * *
0.1000 * *
0.0500 * *
0.0000*********** **********
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
Using singletons gives you the most control over the shape of your fuzzy set, but it is easily the hardest method to define a fuzzy shape. You must laboriously define every point of the fuzzy shape. Which brings us to the next means of defining a fuzzy set shape...
Scalars (numbers) and Functions are the easiest means of defining a fuzzy set shape.
Scalars define one point in the range of the fuzzy variable where the fuzzy set is true, everywhere else the fuzzy set is false.
> (plot-fuzzy-value t * n n (create-fuzzy-value temperature 50))
Fuzzy Variable: temperature
Fuzzy Values: 50(*)
1.0000 *
0.9500
0.9000
0.8500
0.8000
0.7500
0.7000
0.6500
0.6000
0.5500
0.5000
0.4500
0.4000
0.3500
0.3000
0.2500
0.2000
0.1500
0.1000
0.0500
0.0000************************* ************************
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
There are some very special hedges, discussed below, which are specifically intended to modify scalar fuzzy sets to "broaden" their truth membership range.
Functions may also be defined to return fuzzy sets or singletons. You can use a function to mathematically define the shape of the fuzzy set curve. For example, the singletons defined above could have also been created using the pi function:
> (plot-fuzzy-value t * n n (create-fuzzy-value temperature (pi 50 30)))
Fuzzy Variable: temperature
Fuzzy Values: (pi 50 30)(*)
1.0000 *
0.9500 * *
0.9000 * *
0.8500 * *
0.8000 ** **
0.7500
0.7000
0.6500 * *
0.6000
0.5500 * *
0.5000
0.4500 * *
0.4000
0.3500 * *
0.3000
0.2500
0.2000 ** **
0.1500 * *
0.1000 * *
0.0500 * *
0.0000*********** **********
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
The pi function creates a singletons vector which defines a bell shaped curve based on its inputs. In the above example, the first argument specifies the middle of the bell shape, its high point, and the other argument specifies the spread of the curve from the middle point. The IECS currently has 4 functions which return fuzzy shape singletons:
•s (Returns a fuzzy value using a growth curve function, i.e., the probability increases from 0 to 1 between the arguments)
•z (Returns a fuzzy value using a decline curve function, i.e., the probability decreases from 0 to 1 between the arguments)
•pi (Returns a typical bell curve fuzzy value, e.g., the probablities increase as the X value gets closer to the middle point)
•beta (Another bell curve function, Returns a fuzzy value with a beta bell curve shape, e.g., the probablities increase as the X value gets closer to the middle point)
The IECS provides an important class of fuzzy modifiers called hedges. Hedges modify the shape of a fuzzy set in predictable ways. For example, the very hedge modifies a fuzzy set by pushing all values less than one towards zero. This has the effect of shrinking the boundary, the fuzzy portion, of the set closer to the area that is completely in the set:
> (plot-fuzzy-value t *+ n n (create-fuzzy-value temperature (pi 50 30)) (create-fuzzy-value temperature very (pi 50 30)))
Fuzzy Variable: temperature
Fuzzy Values: (pi 50 30)(*) very [(pi 50 30)](+)
1.0000 +
0.9500 * *
0.9000 *+ +*
0.8500 *+ +*
0.8000 ** **
0.7500 + +
0.7000 + +
0.6500 * *
0.6000 + +
0.5500 * *
0.5000 + +
0.4500 * *
0.4000 + +
0.3500 * *
0.3000
0.2500 + +
0.2000 ** **
0.1500 * + + *
0.1000 * *
0.0500 * +++ +++ *
0.0000+++++++++++++ ++++++++++++
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
The curve defined by the plus signs in the graph above defines the fuzzy set value, very (pi 50 30). Hedges are very powerful because they are predictable as well as intuitive. Intuitively, if we imagine that (pi 50 30) shape defines the fuzzy set term, warm (e.g., it is definitely warm at 50, as the temperature decreases it gets less warm and more cold, as the temperature increases, it gets more hot), then when we think of a very warm temperature, we want the value to be the proto-typical value of warm, closer to warm. A temperature of 40 is certainly a member of warm, but it should definitely be less of a member of very warm, which is what occurs.
The hedges in the IECS/FLCL come as unary operators, such as very warm or not warm, and as operands, such as warm + 0.5 or cold - 0.3. The following hedges are available in the IECS/FLCL:
•Add - Adds value to X or Y of the shape (+ (modifies Y component) +X (modifies X component)): low + 0.5, low +X 30
•Subtract - Subtracts value from X or Y of the shape (- (modifies Y component) -X (modifies X component)): low - 0.5, low -X 30
•Multiply - Multiplies value with X or Y of the shape (* (modifies Y component) *X (modifies X component)): low * 0.5, low *X 5
•Divide - Divides X or Y of the shape by value (/ (modifies Y component) /X (modifies X component)): low / 0.5, low /X 30
•Power - Raises X or Y of the shape to the power of value (^ (modifies Y component) ^X (modifies X component)): low ^ 0.5, low ^X 2
•CutLess - X or Y shape values less than value are set equal to value (< (modifies Y component) <X (modifies X component)): low < 0.5, low <X 30
•CutLessEq - X or Y shape values less than or equal to value are set equal to value (<= (modifies Y component) <=X (modifies X component)): low <= 0.5, low <=X 30
•CutGreater - X or Y shape values greater than value are set equal to value (> (modifies Y component) >X (modifies X component)): low > 0.5, low >X 30
•CutGreaterEq - X or Y shape values greater than or equal to value are set equal to value (>= (modifies Y component) >=X (modifies X component)): low >= 0.5, low >=X 30
•Not - Inverts fuzzy shape (not): not low
•Somewhat, MoreOrLess, Greatly, Plus, Very, Extremely - Intensifies fuzzy shape by different amounts (somewhat, moreorless, greatly, plus, very, extremely): somewhat medium
•Above - Invert truth membership above (to the right) the high point of the fuzzy shape, works best with fuzzy shapes that have one maximum (above): above medium
•Below - Invert truth membership below (to the left) the high point of the fuzzy shape, works best with fuzzy shapes that have one maximum (below): below medium
•Slightly - Increases truth membership at borders of fuzzy shape, decreases everywhere else (slightly): slightly medium
•Normalize - Normalizes the fuzzy shape, stretches the fuzzy shape so that the maximum Y value equals 1 and everything else scales proportionately (normalize): normalize [low > 0.3]
•About, VicinityOf, Close, Near, Neighboring - Approximation Hedges (about, vicinity, close, near, neighboring): about 50
•Positively, Absolutely, Definitely - Contrast Intensification Hedges (positively, absolutely, definitely): absolutely medium
•Generally - Diffusion (reduces contrast or wildly varying values) Hedge (generally): generally low
Note that the hedges about, vicinity (of), close, near, and neighboring are called approximation hedges. They are excellent hedges for modify scalar values, e.g., about 50 degrees. The hedges positively, absolutely, and definitely are called contrast intensification hedges as they intensify the contrast; all Y values are pushed closer to 0 or 1. The Generally hedge is the oppositie, it is a constrast diffusion hedge. Please see the following Examples.
As we mentioned, the approximation hedges are particularly good at modifying scalars, e.g., about 50:
> (plot-fuzzy-value t *+ n n (create-fuzzy-value temperature about 50))
Fuzzy Variable: temperature
Fuzzy Values: about 50(*)
1.0000 *
0.9500
0.9000 * *
0.8500
0.8000
0.7500
0.7000
0.6500 * *
0.6000
0.5500
0.5000
0.4500 * *
0.4000
0.3500
0.3000 * *
0.2500
0.2000 * *
0.1500 * *
0.1000 *** ***
0.0500 ****** ******
0.0000********** *********
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
The final way to make fuzzy sets/values/terms is to create the fuzzy set by combining other fuzzy sets. The simplest operations are and and or. What does it mean to make fuzzy expressions using and and or? Lofti Zadeh (father of fuzzy logic) defined the AND operator for fuzzy sets to mean taking the intersection of the two sets, or the minimum values in the sets. The OR operator is the opposite, taking the union of the two sets, or the maximum values in the sets. The following example helps make it clear. When we talk about whether a value is high OR low, we can see it is very likely that a value could be high or could be low, where only in the mid range between the two concepts does the likelihood decrease. The maximum of the two sets captures this meaning perfectly:
> (plot-fuzzy-value t *+ n n (create-fuzzy-value temperature high or low))
Fuzzy Variable: temperature
Fuzzy Values: high or low(*)
1.0000** *
0.9500 ** **
0.9000 *** ***
0.8500 ** **
0.8000 *** ***
0.7500 ** **
0.7000 *** ***
0.6500 ** **
0.6000 *** ***
0.5500 ** **
0.5000 ***
0.4500
0.4000
0.3500
0.3000
0.2500
0.2000
0.1500
0.1000
0.0500
0.0000
|----|----|----|----|----|----|----|----|----|----|
0.00 20.00 40.00 60.00 80.00 100.00
Universe of Discourse: From 0.00 to 100.00
Besides Zadeh's methods, the IECS/FLCL supports other operations for intersection and union
|
Intersection |
Keyword |
Union |
Keyword |
foZadeh |
MinValue([Y1,Y2]) |
and |
MaxValue([Y1,Y2]) |
or |
foMean |
(Y1+Y2)/2 |
and-mean |
(2*MinValue([Y1,Y2])+4*MaxValue([Y1, Y2]))/6 |
or-mean |
foMeanSqr |
Sqr((Y1+Y2)/2) |
and-meansqr |
Sqr((Y1+Y2)/2) |
or-meansqr |
foMeanSqrt |
Sqrt((Y1+Y2)/2) |
and-meansqrt |
Sqrt((Y1+Y2)/2) |
or-meansqrt |
foProduct |
y1*y2 |
and-product |
(y1+y2)-y1*y2 |
or-product |
foBoundedSum |
MaxValue([0,y1+y2-1]) |
and-boundedsum |
MinValue([1,y1+y2]) |
or-boundedsum |
foSum |
NA |
and-sum |
y1+y2 |
or-sum |
You can create fuzzy expressions combining the operations, hedges, and singletons in as elaborate ways as you wish. The bracket characters, [ and ], enable you to define the precedence of operations, e.g., very [warm or hot] or [very warm] or hot.