Fuzzy Variables

Example
Fuzzy Sets, Fuzzy Values and Fuzzy Variables

A fuzzy variable defines the language that will be used to discuss a fuzzy concept such as temperature, pressure, age, or height. The class FuzzyVariable is used to create instances of a fuzzy variable, providing a name (for example, temperature), the units of the variable if required (for example, degrees C), the universe of discourse for the variable (for example a range from 0 to 100), and a set of primary fuzzy terms (like hot, cold and warm) that will be used when describing the specific fuzzy concepts associated with the fuzzy variable.

The name and units are strings that are mainly used for textual display in a program.

The universe of discourse defines a set of upper and lower bounds for the values of the fuzzy sets used to describe the concepts of the fuzzy variable.

The fuzzy terms are described using a term name such as hot, along with a fuzzy set that represents that term. The fuzzy variable terms along with a set of system supplied and user defined fuzzy modifiers, as well as the operators 'and' and 'or' (fuzzy set intersection and union respectively) and the left and right parentheses provide the basis for a grammar that allows one to write fuzzy linguistic expressions that describe fuzzy concepts in an english-like manner. For example, the expression

     (very hot or warm) and slightly cold

consists of the terms hot, warm and cold, along with the fuzzy modifiers very and slightly. These expressions are used when defining fuzzy values, the specific fuzzy concepts that are appropriate for the problem at hand. A fuzzy value associates a fuzzy set with a fuzzy variable to describe the fuzzy concept. The fuzzy sets can be described using the linguistic expressions definable for the fuzzy variable and restricted by the universe of discourse for the variable. The fuzzy sets can also be described using an instance of a FuzzySet object or by sets of (x, y) pairs.

The BNF description of the syntax of such 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, slightly, etc.)
 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.

Example

The following code shows a simple example of creating a FuzzyVariable and a FuzzyValue:

    // There are many ways to define the terms for the fuzzy variable
    // Here we use 2 of those methods:
    //   1. using arrays of x and y values to define the shape of the fuzzy set
    //   2. using already defined terms of the fuzzy variable and linguistic
    //      expressions
    double xHot[] = {25, 35};
    double yHot[] = {0, 1};
    double xCold[] = {5, 15};
    double yCold[] = {1, 0};
    FuzzyValue fval = null;
    ...
    // Create new fuzzy variable for temperature with Universe of discourse
    // from 0 to 100 and units "C".
    FuzzyVariable temp = new FuzzyVariable("temperature", 0, 100, "C");
    ...
    // Add three terms hot, cold and medium
    temp.addTerm("hot", xHot, yHot, 2);
    temp.addTerm("cold", xCold, yCold, 2);
    // Note: once a term is added it can be used to define other terms
    temp.addTerm("medium", "not hot and not cold");
    ...
    // Now we can define fuzzy values using the terms in the fuzzy variable.
    // Note: fuzzy values can also be created using fuzzy sets, etc. and not
    //       just with linguistic expressions.
    fval = new FuzzyValue(temp, "very hot or cold");
    System.out.println(fval);

The output from this would be:

 FuzzyVariable         -> temperature [ 0.0, 100.0 ] C
 Linguistic Expression -> very hot or cold
 FuzzySet              -> { 1/5 0/15 0/25 0.01/26 0.04/27 0.09/28 0.16/29 0.25/30
                            0.36/31 0.49/32 0.64/33 0.81/34 1/35  }

After this has been done we will have defined a fuzzy variable that has the 3 terms hot, cold and medium defined and shown below graphically.

The fuzzy value that we created, temperature is very hot or cold, will have a graphical depiction as follows:

Other sections will provide more information about modifiers, fuzzy sets and fuzzy values.

Fuzzy Sets, Fuzzy Values and Fuzzy Variables

Something that can be confusing initially is the relationship between fuzzy variables, fuzzy sets and fuzzy values. This will likely take some time to grasp and hopefully the examples will assist in showing the differences. In brief, let's try to get a basic understanding of the differences (complete details are found in each of the associated sections). A FuzzySet is used to define a set of x and y values that determine the shape of that fuzzy set. It has no meaning attached to it. That is, it is not tied to any specific concept such as temperature. It is simply an object for representing and storing the shape of a fuzzy set. A FuzzyValue associates a fuzzy set with a fuzzy variable. That is it provides some meaning to a fuzzy set. The fuzzy set will be restricted so that its range of points lies within the universe of discourse for the fuzzy variable (the x values now mean something). The fuzzy value will generally (but not always) provide a linguistic expression that provides a human understandable form to the shape of the fuzzy set. So it is the fuzzy value that defines the specific fuzzy concepts that we are working with. The FuzzyVariable defines the generic concept that we want to reason about, the range of allowed values and a set of linguistic terms that can be used when describing the specific concepts as fuzzy values. Internally the terms are stored as fuzzy values (with the fuzzy set that describes the shape and an association to this fuzzy variable in which they are defined).

 

CUP Parser copyright notice, permission notice and warranty disclaimer

FuzzyJ uses the CUP Parser Generator for Java to generate a parser for handling the linguistic expressions. In compliance with the terms for using the software we include the following notice.

 

CUP Parser Generator Copyright Notice, License, and Disclaimer

Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the names of the authors or their employers not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission.

 

The authors and their employers disclaim all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the authors or their employers be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software.

 

 

Back to Table of Contents