C++ Neural Networks and Fuzzy Logic C++ Neural Networks and Fuzzy Logic
by Valluru B. Rao
M&T Books, IDG Books Worldwide, Inc.
ISBN: 1558515526   Pub Date: 06/01/95
  

Previous Table of Contents Next


Step Three: Set Up Fuzzy Membership Functions for the Output(s)

In our example, we have just one output, which is the HeatKnob. We need to assign fuzzy memberships to this variable just as we did for the inputs. This is shown in Table 16.14 and Figure 16.5. We use different variable names to make the example clearer later on.

Table 16.14 Fuzzy Variable Ranges for HeatKnob

Crisp Input Range Fuzzy Variable
0–2 VeryLittle
1.5–4 ALittle
3–7 AGoodAmount
6–8.5 ALot
7.5–10 AWholeLot


Figure 16.5  Fuzzy membership functions for the output HeatKnob.

Step Four: Create a Fuzzy Rule Base

Now that you have the inputs and the output defined in terms of fuzzy variables, you need only specify what actions to take under what conditions; that is, you need to construct a set of rules that describe the operation of the FLC. These rules usually take the form of IF–THEN rules and can be obtained from a human expert (heuristics), or can be supplied from a neural network that infers the rules from behavior of the system. We mentioned this idea in Chapter 3.

Let us construct a rule base for our design example. For the two inputs, we define the matrix shown in Table 16.15. Our heuristic guidelines in determining this matrix are the following statements and their converses:

1.  When the temperature is low, the HeatKnob should be set higher than when the temperature is high.
2.  When the volume of water is low, the HeatKnob does not need to be as high as when the volume of water is high.


NOTE:  In FLCs, we do not need to specify all the boxes in the matrix. That is perfectly fine. No entry signifies that no action is taken, for example, in the column for SenseTemp=XL, no action is required since the temperature is already at or above the target temperature.
Table 16.15 Fuzzy Rule Base for the Example Design, Output HeatKnob

SenseTemp-> Sense Level XS S M L XL
\/
XS AGoodAmount ALittle VeryLittle
S ALot AGoodAmount VeryLittle VeryLittle
M AWholeLot ALot AGoodAmount VeryLittle
L AWholeLot ALot ALot ALittle
XL AWholeLot ALot ALot AGoodAmount

Let us examine a couple of typical entries in the table: For SenseLevel = Medium (M) and SenseTemp = XSmall (XS), the output is HeatKnob = AWholeLot. Now for the same temperature, as the water level rises, the setting on HeatKnob also should rise to compensate for the added volume of water. You can see that for SenseLevel = Large(L), and SenseTemp = XSmall(XS), the output is HeatKnob = AWholeLot. You can verify that the rest of the table is created by similar reasoning.

Creating IF–THEN Rules

We can now translate the table entries into IF - THEN rules. We take these directly from Table 16.15:

1.  IF SenseTemp IS XSmall AND SenseLevel IS XSmall THEN SET HeatKnob TO AGoodAmount
2.  IF SenseTemp IS XSmall AND SenseLevel IS Small THEN SET HeatKnob TO ALot
3.  IF SenseTemp IS XSmall AND SenseLevel IS Medium THEN SET HeatKnob TO AWholeLot
4.  IF SenseTemp IS XSmall AND SenseLevel IS Large THEN SET HeatKnob TO AWholeLot
5.  IF SenseTemp IS XSmall AND SenseLevel IS XLarge THEN SET HeatKnob TO AWholeLot
6.  IF SenseTemp IS Small AND SenseLevel IS XSmall THEN SET HeatKnob TO ALittle
7.  IF SenseTemp IS Small AND SenseLevel IS Small THEN SET HeatKnob TO AGoodAmount
8.  IF SenseTemp IS Small AND SenseLevel IS Medium THEN SET HeatKnob TO ALot
9.  IF SenseTemp IS Small AND SenseLevel IS Large THEN SET HeatKnob TO ALot
10.  IF SenseTemp IS Small AND SenseLevel IS XLarge THEN SET HeatKnob TO ALot
11.  IF SenseTemp IS Medium AND SenseLevel IS XSmall THEN SET HeatKnob TO VeryLittle
12.  IF SenseTemp IS Medium AND SenseLevel IS Small THEN SET HeatKnob TO VeryLittle
13.  IF SenseTemp IS Medium AND SenseLevel IS Medium THEN SET HeatKnob TO AGoodAmount
14.  IF SenseTemp IS Medium AND SenseLevel IS Large THEN SET HeatKnob TO ALot
15.  IF SenseTemp IS Medium AND SenseLevel IS XLarge THEN SET HeatKnob TO ALot
16.  IF SenseTemp IS Large AND SenseLevel IS Small THEN SET HeatKnob TO VeryLittle
17.  IF SenseTemp IS Large AND SenseLevel IS Medium THEN SET HeatKnob TO VeryLittle
18.  IF SenseTemp IS Large AND SenseLevel IS Large THEN SET HeatKnob TO ALittle
19.  IF SenseTemp IS Large AND SenseLevel IS XLarge THEN SET HeatKnob TO AGoodAmount

Remember that the output and inputs to the fuzzy rule base are fuzzy variables. For any given crisp input value, there may be fuzzy membership in several fuzzy input variables (determined by the fuzzification step). And each of these fuzzy input variable activations will cause different fuzzy output cells to fire, or be activated. This brings us to the final step, defuzzification of the output into a crisp value.

Step Five: Defuzzify the Outputs

In order to control the HeatKnob, we need to obtain a crisp dial setting. So far, we have several of the IF–THEN rules of the fuzzy rule base firing at once, because the inputs have been fuzzified. How do we arrive at a single crisp output number ? There are actually several different strategies for this; we will consider two of the most common, the center of area (COA) or centroid method, and the fuzzy Or method. The easiest way to understand the process is with an example.


Previous Table of Contents Next

Copyright © IDG Books Worldwide, Inc.