This document is not an “API” description per se for the various calls but it should describe fairly well how easy it is to use it. The following model description will therefore be a step by step “how-to” guide on producing an operational FLC, introducing objects and classes as we go along.
I believe this model is the simplest possible object oriented FL model. The purpose indeed was to create a granular FL object which could be easily interconnected into a network of FLC. Such network can then be optimised externally with genetic algorithms.
This document is specific to this “Simple FLC v3” set of classes. It assumes some basic knowledge of the jargon commonly used in Fuzzy Logic. Some reading references are available on the Fuzzy Logic page on the ForeTrade site, including the following resources:
FLC, as its name implies, is the Fuzzy Logic Controller itself. In order to work, the FLC will need to be created, and have its 3 major components defined: FS (Fuzzy Sets), VS (Variable Sets) and RS (Rule Set). For simplicity and compactness, the FLC uses dynamic arrays in the form of pointers. The array sizes are also defined.
CFuzzySet* FS; // Fuzzy Sets
CFLVariable* FLV; // Variable Set
CFLRule* FLRS; // Rule Set
int m_nNumFS; // Number of Fuzzy Sets
int m_nNumVars; // Number of Variables
int m_nNumRules; // Number of Rules
Without going into details a fuzzy set represents an object’s or variable’s attribute (e.g. Size) itself made a set of several fuzzy states, like “High, Average, and Low”. A FLC can hold many different fuzzy sets for different variables in different contexts or situations. In order to simplify the setup of a FLC, a number of predefined Fuzzy Sets are included. They can obviously be edited to suit particular requirements.
Click Here for more info on Fuzzy Sets
A variable set represents a collection of variables to be used in the FLC. In many cases, the FLC will only have 2 inputs and 1 output, but the model can handle more inputs (MISO). The design allows for that already even if we will only describe the most common 2-input model here. One could obviously envisage implementations of more complex controllers with multiple outputs (MIMO), but it should hopefully not be necessary for a FuSM.
When a variable is created either as an input or an output, it originally has no fuzzy set attached. It is therefore interesting to create many fuzzy sets, try associating a fuzzy set with a variable, then another until one finds the one most appropriate for the problem at hand.
We already have a view of our approach, i.e. after creating an empty FLC (step 1), then creating a number of fuzzy sets (step 2), as well as a variable set (step 3), we associate a fuzzy set to each variable (step 4). This last operation can be done over and over, i.e. we can associate then dissociate fuzzy sets to variable set, allowing testing different configurations very easily.
A rule set represents the collection of rules in the FLC. A rule follows the same format as in crisp logic, i.e. IF Premise THEN Consequent, with Premise being made of logical assertions associated by Boolean operators. In this implementation, each component (Antecedent) is called a Premise, and the Consequent can only be attached to the Output variable. This makes our rules look like:
IF Var_1 IS High AND Var_2 IS Low THEN Output IS Average
The 1st premise (Var_1 IS High) obviously requires a Variable and its associated Fuzzy Set. This is why the FLC will have to be defined in a specific order: FS -> VS -> RS. To be exact, the RS actually requires the VS and the FS attached (i.e. contained) to each Variable.
In order to facilitate the building of a FLC, a number of predefined rule sets are included in the design. Those default rule sets make up complete rule bases. They can obviously be edited to suit particular requirements.
It must be noted that even if any logical rule can be created, it is always recommended to have a complete “AND” rule set in order to occupy the input space completely.
Click Here for more info on Rule Sets
We’ve approached the subject already. The current example implies instantiating a new FLC along with the dialog application itself. It first has no FS, no VS and no RS. Any such FLC object can obviously be created and destroyed at will, providing possible existing FS, VS or RS have also been deleted.
In this client application (dialog based), the object is created on the heap, along with the dialog:
FLC = new CFLC; // instantiate a new FL 'empty' controller
A default name is generated internally when instantiating a new FLC (“FLC_nn” where nn is the FLC number). The maximum number of FL controllers is set in the DLL according to users’ rights (2 for the downloadable demo version). The FLC name can be edited.
The FLC object is here destroyed in the dialog destructor:
In case the FLC already has its FS, VS or RS created, it should be reset prior to being destroyed.
Page last modified:
May 08, 2008