Xfuzzy User Guide

FUZZY LOGIC DESIGN TOOLS

Xfuzzy User Guide


Español

Starting with Xfuzzy

Xfuzzy is an environment composed by a set of tools which help the design, verification and synthesis of fuzzy systems. It provides a graphical user interface based on the Athena-3D toolkit running under X-window. All the tools included in the Xfuzzy environment can also be executed independently. This way, the user is able to use the tools interactively from the shell command line, call them from any script or integrate them with other development environments. Command options for these tools are described in the XFL-based Tools man pages.

To run Xfuzzy the user only needs include the path of the Xfuzzy executable files inside his/her environment path variable. For example, in csh:

set path = ($path:$XFUZZY/bin)

Now Xfuzzy can be executed by simply typing:

xfuzzy &

The Xfuzzy main window will appear on the screen. Next figure shows the window appearance where three areas can be distinguished from top to bottom: a button area, a selectable list, and a text area.

When the user clicks on a button in the top area, a menu pops pup. There are six different menus for files manipulation, system design, system verification, system synthesis, fuzzy operations definition, and the setup of the environment. The available specifications list displays the files loaded into the system. The bottom area (log area) is used to display messages from the Xfuzzy environment. At startup, it shows the current Xfuzzy version and information relative to operations performed from command line options.

The user can also get help by clicking on the help button. Xfuzzy help is based on HTML files, so it will start a Web browser.

File management

The file menu leads to a list of items that perform different operations on files. These file operations are related to XFL specification files: load, save, rename, copy, close a specification file and quit from Xfuzzy. Loading an XFL specification file can be done by selecting one existing file (load items) or creating a new file (new item). If the user chooses to load a pre-existing specification a file select window will pop-up showing the files in the current working directory. To save a specification to a file the user can specify a new name (save as... item) or not (save item).

Once an XFL specification file is loaded its internal name (derived from the source file name) will appear on the available specifications list and a message will be written to the log area.

The user can load at startup any number of XFL specifications, simply by giving their names as parameters to the command when calling the program. The list of specification file names to be loaded at startup must be the last parameter used when invoking Xfuzzy.

Setup menu

The setup menu allows to perform three basic operations: the navigation through directories, the manipulation of log information and the specification of fuzzy logic operations. The working directory item will pop-up a file selection window so the user can move through the directory tree and select the default working directory. This working directory will be the default source and target for all files used or produced by Xfuzzy.

The log manipulation items permit permit the user either to clear the log area or to manipulate a log file. This log file will save the information displayed on the log area.

Fuzzy operations

The fuzzy operations menu allows the selection of the fuzzy operations used by the different tools in the Xfuzzy environment. At startup, Xfuzzy will try to load operation definitions for C and Java from:

If none of them are found, the environment provides a minimal set of default operations.

Using the operation definition window the user can view the operations currently defined into the environment, modify them by editing the definitions file or load a new one. See the Defining fuzzy operations section in the XFL Guide for more information on how fuzzy operations are defined into Xfuzzy.

Design Tools

The description of a fuzzy system in XFL consists essentially of three parts:

For each of these parts, the Xfuzzy environment offers graphical editors to ease the definition of the system. The user can also access directly the XFL source by using a conventional text editor by selecting the "Edit XFL file" item.

To perform any design operation the user must have selected an available XFL specification by clicking on it. Xfuzzy provides a mechanism to avoid interferences when using different editors on the same specification: When an editor has been started on an specification, the rest of editors will be started on it in read-only mode, i.e., the user will be able to view definitions but not to save changes.

Operations Editor

Fuzzy operations can be selected from a list of those defined in that moment inside the environment. In parallel, it is possible to view current operation definitions or to include new ones (see the fuzzy operations menu and the Defining fuzzy operations section in the XFL Guide).

The window lists the operations currently assigned into the selected specification. The value <None> indicates that system defaults are going to be used. To change any of these operations, select it by clicking on the corresponding button. A list of the currently available definitions will pop-up to select the desired one.

Types Editor

The Types item in the Design menu provides a specific editor to perform graphically the usual operations of creation and modification on the XFL types.

Before defining the membership functions the user must select or create the type which will contain them. Commands related to type definition are: new (create a new type), remove (delete the selected type), rename (change the name of the selected type), and inherit (copy all the selected type definitions to a new one).

The definition of membership functions (Mf) requires a previous selection of the type. The commands related to Mf definitions are: new (create a new Mf), remove (delete the selected Mf), rename (change the name of the selected Mf), copy (copy the selected Mf), and antonym (flip the selected Mf about a vertical axis located in the center of its universe of discourse).

The user can also modify an existing Mf. Once an Mf is selected the user can displace it entirely by pushing the center button of the mouse, or move the points that define the Mf with the left button of the mouse. This way, the user can change both the position of the function and its shape. Points can also be moved by providing their values through the text areas at the right bottom of the editor window. If the button labelled Adjust to cardinality is pressed, a grid corresponding to the type cardinality will be shown and function or point movements will snap to the nearest line of the grid.

In functions defined in terms of linear piece-wise approximations (functions of class points in XFL), points can be added or deleted clicking inside the graphic window with the buttons Add point or Delete point previously selected.

Modules Editor

The current version of the Modules item in the Design menu provides a set of windows to edit and modify the rulebase of the system. These windows offer facilities for adding, changing and removing system variables, and for writing syntactically correct rules as well.

The version of the modules editor that is currently in process of integration into Xfuzzy will provide a more unified access to the system rulebase.

In addition, a graphical editor for multimodule specifications will be included in next versions, since the current implementation does not support this kind of specification.

Verification Tools

System verification is usually an iterative process that can be performed in Xfuzzy using two different, but not incompatible, strategies: simulating system behavior within its operational context and tuning its parameters using a set of training data.

XFSIM: Simulating XFL-based Systems

The simulation module xfsim allows the integration of one or more XFL-based specifications in a closed-loop system simulating the global behavior of the fuzzy element(s) and their operational context. This simulation module offers an interface to specify:

From these definitions, xfsim produces an executable file that can be initialized by the user and that runs under the control of the Xfuzzy environment. Once the simulation has finished, results are shown by starting different output viewers.

The simulation main function performs the following steps:

The interface of the simulation window offers direct control over all the simulation definition options which describe the behavior of the simulation. The different areas of the window correspond to the different sections in the definition file. See the xfsim man page for more details.

The buttons at the bottom of the simulation window allow to perform different operations on the simulation definitions: clear existing definitions (New), load a file containing simulation definitions (Load), save current definitions to a file (Save), build the simulation executable (Make) or run it (building is performed if needed, with Run). When a simulation is going to be run, the user has to provide the initial values for the system variables. Once the execution of the simulation has started, a window showing the current state of the simulation pops-up. This window includes a button to abort the simulation run.

XFBPA: Tuning XFL-based Systems

The module xfbpa tunes the parameters of an XFL-based fuzzy system by using supervised learning algorithms that employ the value of an error function defined for the system:

where r is the number of training data, n the number of outputs from the system, wj the weight for the output variable j in the error function (1/n by default), yji the actual output value j produced by the system for the input i, Yji the ideal value for output j when input is i, and rangej the range of output j. This error function represents the pondered mean square deviation for the outputs with respect to their valid ranges and always takes values between 0 and 1.

The learning module allows the user to fit the error function, giving more weight to those output variables considered as more significant in system deviation. Furthermore, it can apply a rule pruning algorithm, deleting those rules whose activation grade is below a (user configurable) threshold. If during the learning process rule pruning has been performed, a new learning loop is initiated upon completion of the original one, since the modification of the rulebase can interfere the learning results.

The user may specify one of four possible end conditions:

The learning process stops when one of these limits is reached.

The user can select the algorithm to be applied among:

Calculation of the partial derivatives used by the learning algorithms are performed at runtime by the module.

Specific learning is also implemented since the user can select those variables, membership functions or parameters to be tuned. This way, different learning strategies can be employed, selecting the more adequate one for each particular problem. Special directives are included to ensure that the learning procedure does not break the constraints required by some Xfuzzy synthesis tools (distribution and overlapping of MFs on their universes of discourse).

The interface of the learning window offers direct control over all the xfbpa options which describe the behavior of the learning process. The different areas of the window correspond to the different options of the tool. See the xfbpa man page for more details. The user interface permits to configure and execute the learning process (Run button), as well as to change dynamically its configuration (Stop and Restart buttons) and to survey its evolution. Monitoring facilities include a real time graphical representation of the system (mean and maximum) deviation.

XFPLOT: Surface Plot

xfplot is an utility that permits the representation of surfaces involving fuzzy system variables by means of gnuplot. For system inputs, the user has three options: put it on the X axis, put in on the Y axis, or set a Fixed (constant) value for it. One of the system outputs must be selected to put it on the Z axis. See the xfplot man page for more details.

The next figure shows an example of the output of xfplot:

Synthesis Tools

The Xfuzzy environment includes facilities for fuzzy system synthesis into software and hardware. The choice of the approach depends on both the complexity of the problem and its timing constraints. Software solutions offer great flexibility for defining the knowledge base, selecting fuzzy operators and adopting inference mechanisms. On the other hand, hardware solutions are required when problems demand high operational speed.

Software Synthesis

XFC: XFL to C Compiler

The obvious solution for software synthesis is the use of a standard and widely employed language like C. This allows software implementations produced by Xfuzzy to virtually run on all intended target architectures, from general purpose computers to microcontrollers.

xfc takes an XFL file and produces a C source file which implements the fuzzy inference engine defined in XFL as a C function. This file can be freely combined with any other modules to produce applications containing fuzzy logic capabilities. The interaction between the fuzzy inference engine and the calling module is performed through the parameters corresponding to the input/output variables of the fuzzy system. These parameters belong to an specific C type (FUZZY), defined by means of a typedef construct in the output file. Any C type able to hold a numeric value can be used. Parameters are passed to the fuzzy inference engine function by reference (type FUZZY *).

xfc works with a set of predefined fuzzy operations, which it applies when the specification does not explicitly define one. These operations (which can also be explicitly referenced) are:

The T-norm _sd_min (minimum).
The T-conorm _sd_max (maximum).
The negation _sd_not (complement to 1).
The implication function _sd_min (minimum, again).
The defuzzification method _sd_CoA (center of Area).

The C synthesis window offers an interface to define the basic C type for fuzzy variables (the target of "typedef FUZZY"), the name of the function implementing the inference engine and the prefix used for building the output file name. See the xfc man page for more details.

XFJ: XFL to Java Compiler

The XFL to Java compiler, xfj, is able to produce a set of Java source files that implement the types and rule base defined for a fuzzy system in an XFL file. The special characteristics of the target language make possible a more direct mapping from the XFL structure into the generated files. The result of executing xfj are several Java files, each for one of the classes that constitutes the compiler output. These Java classes implement the XFL types (a different class is generated for each type) and the behavior defined for the system: an additional class implements the rule base specification.

In contrast with xfc, xfj does not allow the selection of the arithmetic used for performing calculations on the fuzzy variables. Since Java guarantees full portability of numerical representations among platforms, all calculations are performed using double precission, by means of the Java native type double. However, as in the case of xfc, the processing for the different XFL base types varies: the rounding operations applied to types with integer base are not applied in the case of types with real base.

xfj allows the use of the autodocumentation facilities of the Java language (offered through the javadoc tool) for adding descriptive comments to the classes it produces. As with the C compiler, xfj must have access to a specification of the implementation it has to apply for fuzzy operations. If the source XFL file does not contain directives that select specific operations, a set of predefined operations is used, with the same identifiers and semantics of those used by xfc. In fact, since C and Java have very similar syntaxes, their definitions are almost the same in both cases.

The Java synthesis window contains fields similar to those in the C synthesis window for defining a common prefix for output files (Output file prefix), the name of the class implementing the inference engine (IE class name), and the package declaration for the classes produced by the compiler. There are two additional control buttons: one for specifying the classes to be generated, and the other for controlling the inclusion of javadoc comments. See the xfj manual page for more details.

Hardware Synthesis

Hardware realizations of fuzzy systems using the Xfuzzy environment can be accomplished following two strategies. In the first one, output values are precomputed off-line for all the possible input combinations and the inference process is carried out by a look-up table. Even though this approach allows a complete flexibility in the definition of the fuzzy system, its main drawback is the exponential growth of the required hardware resources when the number of inputs or the number of elements in the universe of discourse increase. To eliminate this handicap, the second approach included in Xfuzzy follows an on-line strategy where dedicated hardware is implemented to evaluate the inference process concurrently with the input changes.

Xfuzzy modules for hardware synthesis support two different implementation techniques. The use of FPGAs provides a fast prototyping capability. Besides, systems built with FPGAs exhibit intrinsic programmability, thus providing a simple mechanism to change or adjust their functionality. On the other hand, implementations as ASICs are more efficient in terms of silicon area and inference speed when the number of units to be fabricated is high.

XFTL: Look-up Table Synthesis

xftl receives as input the XFL description and translates it to an input-output table with Berkeley's PLA format. The PLA obtained can be minimized and the boolean equations can be extracted by using any compatible logic synthesis tool. If Synopsys and Xilinx synthesis tools are available, (and the resource xfuzzyHasSynopsys has been set to True) the minimization and FPGA implementation processes can also be accomplished.

The table look-up synthesis window offers an interface to control the different functions of xftl. See the xftl man page for more details. Since the actual generation of the table is performed by a separate program generated by xftl, the window provides options to just build the executable, to build and run it to produce the table definition, and to minimize and implement the table according to the selected synthesis options and target FPGA. In the two last cases, a window pops-up showing the evolution of the process and allowing the user to stop it.

XFVHDL: Dedicated Hardware Synthesis

xfvhdl reads an XFL specification and generates a synthesizable VHDL description based on a specific architecture for fuzzy systems (see Related Papers for a detailed description of this architecture). Architectural options and the number of bits of precision are defined by the user when xfvhdl is run.

xfvhdl uses a cell library containing the parameterized VHDL description of the basic building blocks that make up the fuzzy system. The code used in this library is compatible with the restricted VHDL implementations of the Synopsys and Mentor Graphics tools.

According to cost or timing constraints the user can choose to build the system as an ASIC or on an FPGA. In the last case xfvhdl also generates script files to drive the Synopsys and Xilinx synthesis processes.

The execution of this tool produces as output the following files describing the system:

The VHDL synthesis window offers an interface to define the options used in the synthesis process. See the xfvhdl man page for more details.

[Xfuzzy Home Page]

xfuzzy-team@imse.cnm.es

©IMSE-CNM 1997-2001
Last update: Thu Oct 18 17:55:56 2001