Creation of a new Learning Environment
This document is an Online User's Guide to the neuro-fuzzy model NEFCON implementation under MATLAB/SIMULINK. It can be used as an introduction to system creation and as a reference guide during system modification.
The first section describes how to build up easily a learning environment for a dynamic system. The following sections describe all parts of the application in detail. Besides hints for optimal system usage are given.
If you use the MATLAB HTML-Browser HTHELP you will be able to start the GUI-Tools directly out of this documentation. Moreover, if you are using the GUI-Tools, you will be able to 'jump' into any part of this documentation by pressing the '?' or 'HELP' button. If you are using a standard HTML-Browser, screenshots of the GUI-Tools will be embedded into this document.
About the NEFCON-Model
The NEFCON-Model was originally developed by the research group Fuzzy Systems at the Technical University of Braunschweig, Department of Computer Science, Germany.
It is a neuro-fuzzy controller based on a generic fuzzy-perceptron. It is able to learn fuzzy sets and rules by a reinforcement learning algorithm.
A detailed description of the learning process and parameter modification is described in Section 'Learning Algorithm'. Hints for manual definition of the rulebase are described in 'Setting up a Rulebase'.
A sample of a created learning environment is shown below.
Start SIMULINK sample: sample1b.m.
Start GUI-Tool: nefgui.m.
You can change to basic parts of the NEFCON-System by pressing one of the four big buttons:
The Error Definition
The Fuzzy Controller
Besides, the actual simulation status of the system is shown and can be controlled. To control execution use the Simulate/Continue and Stop buttons. You can also skip or repeat learning steps using the buttons '<<' and '>>' (use careful). In particular you can speed up optimizing by switching between control and optimize in ‘good’ and ‘bad’ control periods. Learning steps can be disabled with the checkboxes in the bottom row.
To create a new learning environment press the Create button. See 'Creation of a new Learning Environment' for details.
The actual settings are automatically loaded, and saved in a file named name.NEF, where name is the name of your current SIMULINK system file. If you do not want to save the current settings double click on the Window GUI-Close, do not use the Close button or the menu Close item. (Due to a system bug its not possible to start a dialog box after pressing a button.)
The entries in the File menu can be used to load/save a fismatrix or the complete NEFCON settings (including fismatrix). Also, you can have a look at old simulation results using Show Loops.
The learning algorithm can be separated into the two main parts rule learning and optimization. The options for this parts are described in the Sections 'Rule Learning Options' and 'Optimization Options'.
By pressing any of the four buttons in the upper right corner you can view or edit the current fismatrix. This can be done even during simulation.
Generate Noise during Rule Learning
If NEFCON-Signal-Generators are used this option enables 40% noise during rule learning.
This will enforce optimal rule setting (neural connections generation) and coverage of system states.
The global boolean variable NEFCON_NOISE will be used to turn noise generation on and off.
So you will be able to use the variable in your own noise generation tools.
Learning Rate
If you are using the bottom-up learning algorithm, you can enter the learning rate in this field.
Normally you should use a rate between 0.5 and 2.
If you use the NEFCON learning algorithm, the rate define the relative size of an interval [-d,d] for the error signal. Rules causing an error in this range are no deleted during phase 1.
Normally you should use a rate between 0.05 and 0.3.
Delete rules used less than ... percent
Rules, which will be used less than X percent, will be removed after rule learning phase 2.
In the box below you can enter the duration of rule learning phase 1 and 2.
Add Rules during Optimization
This option must be used if you use the bottom-up rule learning algorithm and the system space is not covered during rule learning.
This is critical for systems which should be controlled by a PID-controller (integral part),
because zero output will be forced for undefined conditions.
In the box below you can enter the duration of optimizing.
The fuzzy error can be defined by using a fismatrix, input1 or a MATLAB function. The name of the external resource can be typed below. The resource can be edited by pressing the Edit Err button.
Using a FISMATRIX
You use a fismatrix, if you want to define the error by a fuzzy inference system.
Using Input1 as Error
You can use a input1 for error definition. Usually input1 is the difference between value and current response.
Bounded error calculation
You use the bounds of the NEFCON bounded signal generator to calculate the error. Input1 must be the difference between value and current response.
Using a MATLAB Function
You can use a m-function with the following parameters for error definition:
function ferr = FNAME(input, bounds)
Input will be the vector of input signals.
If you use the bounded signal generator, bounds will be a vector containing the bounds and the original signal.
The function must return the error signal in [-1,1]. Sample function included: syserr.m.
The following settings can be changed in this dialog:
Number of inputs:
The number of input signals to the NEFCON-System.
For every input you can change the following settings by selecting the number of input:
Upper/lower limit: The interval to be used for controlling.
Gain: The gain to be used for controlling.
For output only the gain can be modified.
Hints for Selecting Input Signals
The difference between optimal value and current response of the system always must be used as an
input signal.
In most cases you also have to use the derivative (also for error calculation), because
fuzzy controllers only use static information.
If the system has to get different control signals for the same difference signal
(e.g. difference is zero but the system needs a bias value to stay at 1 and no bias to stay at zero)
then you must use the current value, response or an integral part as input too.
Create Settings
The settings used for system creation can be changed in this dialog box.
Start GUI-Tool: nefgui_c.m.
Using this GUI-Tool you can select the signal generator. See NEFCON Signal Generators for details. Also, you can select to create an environment using the NEFCON learning algorithm or a standard fuzzy controller. Besides, you can change the number of inputs of the selected system.
See 'Fuzzy Controller' for details.
Start GUI-Tool: fuzzy.m.
See printed documentation for details or use the fuzzy.m online documentation.
Hint: The methods for and, or, implication, aggregation and defuzzification shouldn't be modified. Different methods can be used, but you should be familiar with the theory of the NEFCON-model, if you change the default settings.
This tool is the modified version of the error definition tool used in the MATLAB NCD Tool-box. It was originally written by A. Potwin, ‘The Mathworks’.
You can move the bounds and the signal by dragging it with your mouse. The signal range can be changed by entering the new interval and pressing the set button.
You can split the bars for error definition by selecting them and pressing the split button.
By pressing the New Signal button the old signal will be erased with the default signal. Besides, the time range will be changed to your actual SIMULINK settings.
The signal generator support noise generation.
NEFCON signal generator
If you use the NEFCON signal generator, a block containing the SIMULINK SigGen will be used.
The signal generator support noise generation.
To conveniently enter the rules and fuzzy sets use the fuzzy.m GUI-Tool of the Fuzzy Logic Toolbox.