# 7.2.12 Constructions for Fuzzy Computation

A detailed description for fuzzy computation and fuzzy constraints is given in Chapter 7.5. In this introductional part we will just give a short example for fuzzy computation in order to get the reader familiar with fuzzy computation objects.

/* Import RuleSet with rules and ParameterSets */

IMPORT RULESET MyRules.RuleSet

/* table of correspondings for rule generation */

TABLE Fuzzy.Table

/* declare fuzzy variables with the associated */

/* ParameterSet, its lower and upper support */

/* end, median, distribution, dilatation, etc. */

FUZZYVAR f_in1 fuzzy_in

FUZZYVAR f_in2 fuzzy_in

FUZZYVAR f_out fuzzy_out

FUZZYVAR f_comp fuzzy_out

/* set f_in1 to crisp value 10 */

SET f_in1 = 10

/* set f_in2 to crisp value 80 */

SET f_in2 = 80

/* f_comp is a fuzzy comparison of f_in1 < 20 */

FUZZYCOMPARE f_comp IS f_in1 < 20

/* f_out is fuzzy result of f_comp AND f_in2, */

/* where AND is a fuzzy conjunctor */

FUZZYCONCAT f_out IS f_comp AND f_in2

/* evaluate f_out according to the RuleSet */

EVAL f_out

/* display defuzzified value for f_out */

PRINT f_out

/* export modified RuleSet */

EXPORT RULESET MyRules.RuleSet

In contrast to crisp variables, all fuzzy variables have to be declared before use by the assignment of a ParameterSet that describes the linguistic variables, distribution, dilatation, lower and upper support end of the variable, median and importance.

The evaluation EVAL f_out happens according to the rules in the RuleSet.

In our example such rules could be of the form:

IF f_comp IS negative AND f_in2 IS negative THEN f_out IS bad WITH CERTAINTY 1.

...

IF f_comp IS zero AND f_in2 IS zero THEN f_out IS neutral WITH CERTAINTY 1.

...

IF f_comp IS positive AND f_in2 IS positive THEN f_out IS good WITH CERTAINTY 1.

The single statements and keywords are treated in detail in section 7.5, but anyone familiar with fuzzy set theory should get an idea of what is going on in this brief example.

The more general notation of these rules is of the format:

IF <termlist> THEN <term> WITH CERTAINTY c.

where

termlist = term | termlist ("AND" | "OR") term

term = Ident

Ident = (letter | digit) (letter | digit)*

Number = digit+ | digit+ "." digit+

digit = 0..9

letter = printable ascii characters

c = Number