Fuzzy Compiler Demo

This demonstration of Fuzzy Logic was developed using the FuzzyJ Toolkit that was originally created at the National Research Council of Canada. The code for this demo is entirely Java(tm) code, although there is a capability to create more sophisticated rule based expert systems in concert with Jess (Expert System Shell) from Sandia National Laboratories (see the associated demo of the hybrid Java/Jess Fuzzy Shower).

This example, entitled FuzzyCompiler, takes a simple set of 9 fuzzy rules that control a throttle setting based on the current temperature and pressure of the system. When the Start Button is pressed the rules are applied to a large number of temperature and pressure inputs. This results in an array that in effect holds the compiled results of the rule firings. Using these results one could then determine the output (throttle setting) of the fuzzy rules, given an input temperature and pressure by simply doing a table lookup. In this case one would get the system inputs, find the area in the table in which the inputs lie and interpolate using the 4 surrounding values. This could provide extremely fast results since the rule behaviour is compiled into the output table.

In this example we have 2 antecedent fuzzy variables and 1 conclusion fuzzy variable. They are:

Antecedent Fuzzy Variables:

temperature 0 to100 degrees C              pressure 0 to 500 kPa
   terms: low, medium, high                         terms: low, medium, high

Conclusion Fuzzy Variable:

throttle 0 1 units
   terms: verylow, low, midlow, medium, midhigh, high

The 9 rules can be written as:
 

if  temperature is low
and pressure is low
then set throttle to high

if  temperature is low
and pressure is medium
then set throttle to medium

if  temperature is low
and pressure is high
then set throttle to midlow

if  temperature is medium
and pressure is low
then set throttle to midhigh

if  temperature is medium
and pressure is medium
then set throttle to midlow

if  temperature is medium
and pressure is high
then set throttle to low

if  temperature is high
and pressure is low
then set throttle to midlow

if  temperature is high
and pressure is medium
then set throttle to low

if  temperature is high
and pressure is high
then set throttle to verylow

On startup the main routine defines the fuzzy variables and the rules. There are 3 pairs of radio buttons that allow the table to be created using various options of the FuzzyJ Toolkit. The first (leftmost) pair of radio buttons allows one to choose one of two fuzzy inferencing methods:

Mamdani minimum inference relation with max-min composition
       or
Larsen product inference relation with max-min composition

The second (middle) pair determines how the matching of antecedents and inputs are combined in a rule. For example, in this set of rules there are two antecedents: one for temperature and one for pressure. Each of these will be matched against a corresponding input value and will generate a match score. To determine the rule’s overall score these two match scores are combined, by taking the minimum value or by calculating the product of the two values. Suppose that the match score for temperature was 0.5 and for pressure it was 0.4. The minimum of the two values is 0.4 and the product is 0.2.

The third (rightmost) pair of radio buttons allows us to determine how we will combine the fuzzy outputs from the separate rules. This global contribution can be the union of the outputs or the sum of the outputs.

When the Start button is pressed the rules are fired for a set of input values for temperature (from 5 to 95 by 5) and pressure (from 10 to 490 by 10). Each pair of input values is fuzzified and the 9 rules are considered for firing. Those rules that do fire have their fuzzy value outputs combined (union or sum). This final fuzzy output is defuzzified (in this example using the momentDefuzzify operation) and the value is stored in the table. After all input pairs have been dealt with the table is displayed in the text area. In this example there are 8379 rules considered for firing in the pattern matching phase and 1525 rules actually fire.

Questions etc. can be sent to: bob.orchard@nrc-cnrc.gc.ca

To start the demo press the button below and a separate window will appear.

Sorry, No Java appears to be available for the browser!!!