2D

FLIP++ library description

FLIP++ modules

With the use of these four object oriented modules the developer is provided with a tool to develop his/her own fuzzy logic inference processor.

Important notions

Some helpful remarks...

Throughout the description the terms method and attributes are applied to describe a class. The notion method corresponds to the more C++ like term membership function, the attribute notion should be quite clear. There is also a distinction between a class and an object, where class refers to the abstract declaration and definition while object means the instance of a class.

Furthermore, we assume that the reader is familiar with the basics of objecto riented programming, which might help understanding the description and source code as well. It is highly recommended for the reader to go through the following description and reading the source code simultaneously switching back and forth between the description and the source code.

flippara.h / flippara.cpp

This module provides the developer with the most basic functions in order to handle the 'administrative chores' necessary for the definition of linguistic variables. Among these chores are creating, initializing, adding, removing parameter sets and, furthermore, basic functions for input/output. The most important concept of this module is the list. Each new basic class introduced in the module is strongly related to another class which is a simple linear list of objects of that basic class. The list below shows the basic classes/list classes contained in this module. Then a detailed description of the functionality of each class is given.

Name

This class looks quite general and is used to represent the name of a linguistic term, made explicit in the attribute nam, whose type is a type defined string allowing a maximum of 40 characters to be used in a string. As already mentioned above each basic class is used in a list class, which is why there is the next attribute that is the pointer to the next Name object in the list.

The class has constructors either with or without parameter. Using the former a default name is attached to the attribute nam, in the latter case the attribute nam is initialized with the value of the parameter. The method show is used to write the current value of nam to the standard output device. The methods read and write handle input and output to files. The method copy sets nam to the nam value of another Name object. Simple access methods for the attributes round up the class. It is important to note the difference between name and Name, the former is a type -defined string with a maximum of 40 characters used for the nam attribute, whereas the latter is the class described here.

NList

This class is a linear list of objects of the Name class. It is used to represent all the different linguistic terms that can be assigned to a specific linguistic variable . In the following description the Name objects are referred to as elements of the list. NList has three attributes first, last and number, where first is a pointer to the first element in the list, last is a pointer to the last element in the list, and number stores the number of elements currently contained in the list.

Again, there are two constructors, one without parameter that provides an empty list and one with an integer parameter creating a list with as many elements as the value of the parameter specifies. For values within the range of 2 to 9 there are default names which are attached to the Name objects. These names can be found and changed in the NList constructor in the flippara.h / flippara.cpp file. The destructor deletes the elements of the list according to a clean memory management. The method show is a simple extension of the show method of the Name object and writes the values of the entire list, i.e. the value of each element in the list, to the standard output device. The methods read and write handle input and output to files by reading/writing the number of elements and each element itself from/to a file. The method add adds an element to the list. The method find accesses an element with a certain index and returns a pointer to that element, whereas find_n accesses an element with a certain index and returns a pointer to the attribute nam of that element, the same effect can be attained by using the array-operator []. The method copy is used to copy the elements from another NList object by adding new elements to the end of the list using the add method. The method remove_all deletes all elements of the list and hence supplies an empty list. Furthermore, there are simple methods to set and get the values of the three attributes. In order to avoid any name conflicts, especially when multiple inheritance is used, all the methods of the Name class come in duplicate declaration: with one name as mentioned above, and the other by putting the method name and the name of its class together seperated by an underscore. This practice makes the names of methods globally distinct and is used throughout the whole system. (e.g. show and show_NList are virtually the same methods)

Colour

This class stores the colour value of another object. It is mainly used for the graphical representation of linguistic terms and linguistic variables respectively. The attributes of the class are colour, which stores the value of the colour and is of an enumeration type (colourtype), and next, which is used to implement the already familiar list concept.

There are two constructors, the default constructor initializes the attribute colour with a specifically fixed colour (white), the alternative constructor uses a parameter for the colour to be attached to the object's attribute colour. You can look up the list of possible colours in the constructor in flippara.h / flippara.cpp file or, of course, in the declaration of the enumeration type colourtype in the flippara.h / flippara.cpp file. Again, there is a method show that writes the current value of the attribute colour to the standard output device, the methods read and write handle input and output to files. The copy method copies the colour attribute value of another Colour object to the current one. Simple procedures to set the values of the attribute colour and to get the values of the attributes colour and next round up the methods of the class.

CList

This class is a linear list of objects of the Colour class. It can be viewed as a list of the various colour values of a linguistic variable's linguistic terms. In the following description the Colour objects of the list are referred to as elements of the list. The three attributes are represented as first and last, which are pointers to an object of the type Colour, and number, an integer variable, giving the number of elements currently contained in the list.

The default constructor without parameters initializes the object with an empty list, whereas the constructor with the integer parameter number creates an object that has as many elements in the list as the value of number indicates. Similar to the NList class, for values between 2 and 9 there are default colours that are attached to the Colour objects of the CList during initialization. These colours can be seen in the constructor in the flippara.h / flippara.cpp file.The method show writes the value of each element in the list to the standard output device. The methods read and write handle input and output to files by reading/writing the number of elements and each element of the list from/to the file. The add method adds a new Colour object as an element to the list, by default the colour attribute of the object is white. The copy method copies a complete set of elements from an existing CList object into the current CList object, the elements are copied by the add method. The method remove_all deletes all elements of the list. The find method is used to access an element in the CList object by its index. A modification of the method find is the method find_ct where instead of a pointer to an element with a specific index a pointer to the element's attribute colour is returned, the same effect can be attained by using the array-operator []. Furthermore, there are trivial methods to set and get the values of the CList's attributes. Among them are the methods to set and get the first and last element of the list and the number of elements.

ParameterSetBase

This class is a composition of all parameters that are needed to describe a linguistic variable among them are the range with its lower and upper end, the median, the distribution, the dilatation, and the importance. The attributes of the object are the parameters, called range_lower_end, range_upper_end, median, distribution, dilatation, and importance. All these attributes are simple float values. Note that the distribution must have a value between 0.1 and 1, while dilatation and importance must be in the interval [0,1].

As usual, there are two constructors. The default constructor initializes all the parameters mentioned above with default values, which can be seen in the flippara.h / flippara.cpp file. The alternative constructor takes the values of all the parameters as input and initializes the object correspondingly. If there are any inconsistencies in the parameters, the constructor tries to eliminate them. For example, if the range_lower_end is not a smaller value than the range_upper_end parameter, the two values are swapped. If the median is not within the range, which is the interval defined by the boundaries range_lower_end and range_upper_end, then the median will be set to the mid of the range. Furthermore, the boundaries of the parameters distribution, dilataton, and importance are the utmost values that can be reached and cannot be exceeded on either side. The method show writes the values of the parameters to the standard output device. The methods read and write do the same, except they read from/write to files instead of standard output. The copy method copies the parameters of an existing ParameterSetBase object to the current object. Apart from these methods, there are the trivial set and get methods enabling us to make changes to the value of a specific parameter.

ParameterSet

This class is an aggregation of the three basic classes NList, CList and ParameterSetBase, or expressed more technically, it is derived from these three classes by multiple inheritance. Hence it combines the descriptions of the linguistic terms, i.e. names and colours, the parameters of a linguistic variable. Again this class is defined as an element of a list, called PSList and will be described in the next class. The attributes of the ParameterSet are ps_name containing the name of the ParameterSet and next referencing another ParameterSet object as used in PSList. Of course, ParameterSet knows all the attributes from which the classes are derived from.

The default constructor initializes an empty ParameterSet consisting of a default name, a next pointer to the next ParameterSet, a default ParameterSetBase object, and the list of objects NList and CList, which are both empty. The alternative constructor initializes a ParameterSet object with the values of its input parameters. These parameters are the same as with the ParameterSetBase object plus two pointers that are the reference to an existing NList and CList object and the name of the ParameterSet. The method show writes the complete ParameterSet to the standard output device, i.e. all the values of its attributes. Similarly the methods read and write handle input and output to files. The copy methods takes a pointer to an existing ParameterSet as input and copies all its attributes to the current one. There are also simple get methods to obtain the values of the attributes, among them are get methods for the attributes name and next, and get methods to extract the whole ParameterSetBase object, NList object or CList object encapsulated in the object. Moreover, there is a method to set the name of the ParameterSet.

PSList

The class introduces a now already familiar concept of the list class. It represents a linear list of ParameterSet objects, which can be viewed as an aggregation of ParameterSets of several linguistic variables. The attributes of this class are first and last, which are pointers to ParameterSet objects, and number, which is an integer storing the number of elements in the list.

The constructor initializes an object as an empty list. The destructor deletes all elements of the list according to a clean memory management. The method show simply writes all significant attributes of the elements to the standard output device. The same procedure is followed by the methods read and write by reading/writing the number of elements and each element of the list from/to files. The add method without parameter adds an empty ParameterSet to the list, whereas the add method with a pointer to a ParameterSet as an argument adds a copy of this ParameterSet to the list. The add method with a PSList reference as an argument copies the elements of the complete PSList into the current one. The method remove_all deletes all elements of the list. The method find is used to access an element by its index. The remove method deletes the element with the index specified in the argument. The values of the attributes can be retrieved by simple get methods.

flipcvar.h / flipcvar.cpp

This module focuses on the particulars of a linguistic variable. First, the classes FuzzySetBase, PlimFuzzySet and PlimList define the characteristic s of linguistic terms, especially the handling of membership functions and their instances. Then the classes CombinedVariable and CVList aggregate linguistic terms (PlimList) and linguistic variable parameters (ParameterSetBase). Below you can see a list of the classes contained in this module. After that, a detailed description of each class is provided.

FloatValue

This represents a float value, which is used as an element of a linear list provided by the FList class. The attribute value is a float variable, whereas the attribute next is a reference to another FloatValue object which is needed to build a linear list of FloatValue objects as used in the FList class. This technique is the same as the one applied with the following objects Name, Colour, ParameterSet, NList, CList, and PSList respectively in the flippara.h / flippara.cpp module.

The constructor initializes the object with a float value. Furthermore, there are simple set and get methods for the values of the attributes value and next.

FList

This class is a linear list of FloatValue objects.The set of attributes consists of first and last, which are pointers to the first and last FloatValue objects contained in the list, and number, which is an integer variable that stores the numbers of elements contained in the list.

An empty object of this class is initialized by the constructor. According to a clean memory management the destructor deletes all elements of the list. The method add adds a new FloatValue object to the list initialized with the value of its float parameter. The find method accesses an element of the list by its index. It is a modified version of the find method since it does not return a reference to the found element object but returns the value of this object which is a float value. As an alternative the array-operator [] can be used instead of the find_v method. The remove method deletes an element of the list specified by its index. The remove_all method deletes all elements of the list. Apart from these methods, there are simple methods to obtain the values of the attributes.

Point

This class represents a Point of a membership function, which generally consists of several points describing its shape. The attributes of the class are x_value and y_value - simple float values that represent the coordinates of the Point - and the next attribute, which is a reference to another Point object as needed by the list object PList, an already familiar technique for the attentive reader of the previous sections.

The default constructors initialize the object with a default Point (0, -1). The alternative constructor initializes the object with the Point specified by the parameters for the x and y-coordinates. The show method writes the values of the coordinates to the standard output device. The methods read and write handle input/output on files. Simple get and set methods round up the class.

PList

This class is the representation of a linear list of Point objects. The attributes are first and last, which are pointers to Point objects, and number, which is an integer and stores the number of elements of the list.

The constructor creates an empty list, whereas the destructor deletes all elements of the list according to a clean memory management. The method show writes the values of all elements to the standard output device. The methods read and write handle input and output to files by reading/writing the number of elements of the list and their values to files. The add method adds a new element to the list, it needs the values of the x- and y-coordinates of the Point object as input, after that the Point object is created and appended to the list. The method find accesses an element of the list by its index and returns a pointer to the found Point object. There are two modifications of this find method: find_x and find_y. They also access an element of the list by a specified index and then return its x-coordinate or y-coordinate respectively. Furthermore, the method find can be called with an x- and y-coordinate as input, this returns the index of the first Point with these coordinates or the value -1 indicating that no such Point is in the list. Another possibility is to call the find method with a reference to a Point as input, then the same procedure is applied as in the previous variant with the coordinates retrieved from the Point object parameter. As an alternative to the find method with the index parameter the array-operator [] can be used. The method insert can either be used with a Point object as a parameter or with coordinates as parameters. The effect is the same, a new element with the values of the parameters is inserted into the list, the insertion is made in a way that the elements are kept in order with ascending x-coordinates, and in a second order with ascending y-coordinates if x-coordinates are the same. Furthermore the insertion procedure ensures that the same element cannot be contained in the list twice. The method remove deletes an element of the list specified by its index. The method remove_all initializes the list by deleting all its elements. The copy method adds all elements of an existing PList object to the current PList object. Furthermore, there are again simple methods to obtain the values of the attributes.

FuzzySetBase

This class contains some basic parameters of a linguistic term, which are its name, lower_support_end, upper_support_end, and its colour. The attributes of the object corresponding to the parameters of the FuzzySetBase, namely linguistic_term of the type Name, lower_support_end and upper_support_end of the type float, and fs_colour of the object type Colour.

The default constructor initializes the parameters mentioned above with default values, which can be seen in the flipcvar.h / flipcvar.cpp file. The alternative parameter needs the values of all these parameters as input and sets them accordingly. The method show writes the values of the parameters to the standard output device, whereas the methods read and write do the same, except to a file instead of standard output. The copy method copies the parameters of an existing FuzzySetBase object to the parameters of the current object. Furthermore, there are trivial methods to get and set the values of the parameters.

PlimFuzzySet

This class is derived from FuzzySetBase, as an extension it contains the default and instantiated membership function of a linguistic term. The attributes of the class are the two PList objects msf and imsf for the membership function and instantiated membership function, the match_value, which is a float value, the function, which is the name of membership function and a Name object, and the next pointer to another PlimFuzzySet.

The default constructor initializes the object, which is the same procedure as with the FuzzySetBase object. Additionally, the attributes match_value, function and next are initialized. Match_value represents the value of intersection between the crisp value of a linguistic variable and the membership function of a specific linguistic term. With the alternative constructor it is possible to specify the parameters of the FuzzySetBase. The method show writes the underlying FuzzySetBase, the match value and the Points of the default and instantiated membership function to the standard output device. The same procedure is applied in the read and write method, except they handle input and output to files instead of standard output. The method calculate_match_value calculates the match_value of the membership function for a specific crisp value, which is the parameter of the method. The calculation is a simple intersection between the vertical line defined by the crisp value and the polygon defined by the Points of the membership function. The match value (the y-coordinate of the intersection Point) indicates the satisfaction of the linguistic term achieved by a crisp value. The method build_imsf simply calculates the instantiated membership function according to the current match value. The procedure builds a Point list from the default membership function where only those parts of the polygon below the match value are of interest, so everything above the match value in the default membership function is cut off by a horizontal line. The add_msf_point method adds a new Point to the membership function, the Point is specified by its coordinates and appended to the list through the insert method of the PList class. The delete_msf_Point method removes a Point from the membership function, the Point is specified by its index and removed by the remove method of the PList class. The methods get_msf_Point_number and get_imsf_Point_number return the number of Points contained in the membership function and instantiated membership function polygons. The copy method copies all the contents from an existing PlimFuzzySet object into the current object. The get_FSB method returns a FuzzySetBase object containing the same parameters as the current PlimFuzzySet object. Apart from these methods, there are simple methods to set and get coordinates of the membership function's Points, and to get coordinates of the instantiated membership function Points. Besides, a get and set method for the match_value, the name of the membership function and a get method for the next pointer, which is a reference to an other PlimFuzzySet used by the PlimList object, are availabe. Furthermore, references to the membership function and the instantiated membership function can be retrieved as pointers to a PList object by get methods.

PlimList

This class is used to create a linear list containing PlimFuzzySet objects. This can be viewed as a linguistic variable consisting of various linguistic terms. The three additional attributes apart from the inherited ones are first and last, the pointers to the first and last element in the list, and number, which stores the number of elements contained in the list.

Its constructor builds an empty list, it has no parameters. The destructor deletes all elements of the list according to a clean memory management. The method show writes all the characteristic parameters of each element of the list to the standard output device by simply calling the show method of the PlimFuzzySet objects. The read and write methods handle input and output to files by reading/writing the number of elements and their contents from/to files. The method add appends a new element to the end of the list. Without parameters a default PlimFuzzySet is added to the list, whereas with parameters it is possible to specify the FuzzySetBase parameters of the new PlimFuzzySet object as well as the dilatation length from both the lower and the upper end, this has an influence on the shape of the membership function. The find method accesses an element of the list by its index, alternatively the array-operator [] can be used. The method get_fs_index accesses an element of the list by the name of the linguistic term and returns its index in case of existence. The method get_membership returns the y-coordinate of a membership function's Point specified by its x-coordinate, the element, whose membership function is used, is specified by its index. The method get_names_of_vars returns an NList object containing the names of all linguistic terms of the elements in the list. The check_match method checks whether the linguistic variable, i.e. the linguistic terms in the linear list, has already instantiated membership functions, which in turn means that the linguistic variable has been instantiated and the match values are greater than or equal to zero. The method set_all_mvs sets the match values of all elements, i.e. all linguistic terms, to a specific value, which is the parameter of the method, and, after that, it builds for each element the instantiated membership function. The method add_msf_Point adds a new Point to the membership function of the element specified by its index, whereas the method delete_msf_Point removes a Point specified by its index from the membership function of an element also specified by its index. There is a restriction that a membership function must have at least three Points. The copy method appends all elements of an existing PlimList object to the current object. The method remove_all deletes all elements of the list. The method put_imsf_into_cover is used to build the cover of the instantiated membership functions of all linguistic terms, generally speaking, the cover is the contour of the instantiated linguistic variable which consists of al l the instantiated membership functions of linguistic terms. The function creates a union list of the existing cover and the instantiated membership function to be added, furthermore a cross list containing all intersection Points between the cover and the instantiated membership function is created. Then all Points that are of no interest to the creation of the new cover are systematically removed, among them are the Points of the cover that are below the instantiated membership function and the Points of the instantiated membership function that are below the cover. After that, the cross list and the union list are put together and all redundant Points, i.e. three Points on a straight line, are removed with the new cover as the result of the operation. The methods above and picture are needed for the calculation of the relative position of a Point and a line, the method crossPoint simply calculates the Point of intersection between two lines. Furthermore, there are simple methods to access the attributes of the object. Their implementation is rather straightforward and they are generally augmented methods of the class PlimFuzzySet by the possibility to access the elements of the list by their index.

CombinedVariable

Its origin is derived from the ParameterSetBase class and the PlimList class where it is a representation of a linguistic variable consisting of various linguistic terms with their own parameters, membership functions and instantiated membership functions. The attributes of the linguistic variable are the cv_name (of type Name), the crisp_value (of type float), and next - which refers to the next linguistic variable in the list.

The default constructor initializes the linguistic variable with a default (empty) PSList, a default ParameterSetBase and a default linguistic variable name, the attributes next and crisp_value are also initialized. The alternative constructor has two parameters, an existing ParameterSet and a name for the linguistic variable. It initializes the ParameterSetBasewith the values of the ParameterSet and the PlimList is cons tructed with as many elements as contained in the ParameterSet objects CListXS and NList respectively. Each element of the PlimList object is initialized with attributes derived from the ParameterSet values, this refers to the name, colour, support and dilatation length of the element. The method show writes the values of the parameters of the linguistic variable to the standard output device, this includes the name, crisp_value, all parameters of the ParameterSetBase object, and all parameters of the PlimList and its elements. The same procedure is applied in the methods read and write, except that they are reading/writing from/to files. The method set_value sets a new crisp value, and then starts for each linguistic term of the linguistic variable, i.e. each element of the PlimList, the calculation of the match value and instantiated membership function. The method copy copies an existing linguistic variable to the current object, i.e. all the parameters of the ParameterSetBase, the whole PlimList, the linguistic variable name, and the crisp value are copied. This can be achieved by applying the following two methods. The method get_PSB returns a ParameterSetBase object identical to the one contained in the current linguistic variable object. The method copy_PlimList copies all the elements of an existing PlimList to the actual linguistic variable object. Furthermore, there are simple methods to get and set the values of the name and the crisp value, and to get a reference to the next linguistic variable, since the linguistic variable object can be an element of a linear list, the CVList object.

CVList

This class puts together various linguistic variables in a linear list. The attributes of the list are first and last, which reference linguistic variables, and number, which stores the number of elements in the list.

The constructor initializes an empty list, whereas the destructors deletes all elements of the list according to a clean memory management. The method show writes the contents of all elements of the list to the standard output device, whereas the method read and write handle input/output to files. The method add without parameters adds a default linguistic variable to the CVList object, i.e. a linguistic variable initialized with its default constructor containing an empty PlimList and a default ParameterSetBase. The copy method copies all elements of an existing CVList to the current one. The method add with a CombinedVariable reference as a parameter adds this linguistic variable to the CVList object. The add method with a CVList as a parameter adds only those elements of this list that are not already contained in the current object. The method find accesses a linguistic variable in the list by its index. As an alternative to the find method the array operator [] can be used. The method find_cv accesses a linguistic variable in the list by its name. The methods find_cv_by_pointer and find_cv_by_name are the reverse of the previous find methods, they have a linguistic variable reference as parameter and return the index of this linguistic variable in case it exists. The method remove deletes the element of the list specified by its index. The method remove_all deletes all elements of the list.

flipoper.h / flipoper.cpp

This module provides all the necessary classes and methods used for fuzzy operators. Below you can see a list of classes contained in this module. A detailed description of the classes can be found further down.

global functions

FuzzyOperator

This is a simple class that represents the type of a FuzzyOperator, which is used for the connection of terms, generally the operators can be interpreted as 'and' and 'or' relations. Of course, the more fuzzy an operator is, the more the otherwise clear difference between 'and' and 'or' begins to blur. The only attribute of the class is the operator type oper, which is of the enumeration type fuzzy_operator. The enumeration type declaration at the beginning of the file flipoper.h / flipoper.cpp shows the operators currently supported by FLIP++.

The default constructor initializes an object with the attribute value no_fop. The alternative constructor takes the type of operator as input. The method show writes the type of the operator to the standard output device. The methods read and write do the same as show using files instead of standard output. The simple methods get_oper and set_oper are used to set a new operator and get the current operator type.

DeFuzzyOperator

This class represents the type of a DeFuzzyOperator, which is used to retrieve a defuzzified, i.e. a crisp value from the fuzzy result of the inference process. The only attribute of the class is the operator type oper, which is of the enumeration type defuzzification_operator. The enumeration type declaration at the beginning of the file flipoper.h / flipoper.cpp shows the operators currently supported by FLIP++.

The default constructor initializes the object with the attribute value no_dfop. The alternative constructor takes the type of operator as input. The method show writes the type of the operator to the standard output device. The methods read and write do the same as show using files instead of standard output. The methods get_oper and set_oper are used to set and get the type of the operator.

ConcatOperator

This class is the representation of a ConcatOperator, which is used to concatenate several Terms. The only attribute of the class is the operator type oper, which is of the enumeration type concat_operator. The enumeration type declaration at the beginning of the flipoper.h / flipoper.cpp file shows the operators currently supported by FLIP.

The default constructor initializes the object with the attribute value no_cop. The alternative constructor takes the type of operator as input. The method show writes the type of the operator to standard output. The methods read and write do the same as show using files instead of standard output.

TNorm

This class has no attributes and provides methods to apply a minimum operator by using a T-Norm calculation. The method min with a reference to an FList object as parameter simply calculates the minimum of the float values contained in the FList . The method min with the parameters overall match value and certification value calculates the minimum of these two values. The method min with the parameters overall certified match value and a reference to a PlimFuzzySet object calculates the minimum of the overall certified match value and the match value of the PlimFuzzySet object, in case the PlimFuzzySet object does not already have an instantiated membership function, the result is the overall certified match value. Hereafter the instantiated membership function of the PlimFuzzySet object is calculated by setting the match value to the result of the previous computation and calling the build_imsf method of the PlimFuzzySet object.

TCoNorm

This class has no attributes and provides methods to apply a maximum operator by using a T-Conorm calculation. The method max with a reference to an FList object as a parameter simply calculates the maximum of the float values contained in the FList . The method max with the parameters overall match value and certification value calculates the maximum of these two values. The method max with the parameters overall, certified, match, value, and a reference to PlimFuzzySet object calculates a new match value and then instantiates a membership function for the PlimFuzzySet object, referenced by applying the T-CoNorm operator.

CompOp

This class is a set of compensatory operators. Similar to the TNorm and TCoNorm each of the operators comes with three variants of a method, the first one with a reference to an FList object as a parameter, the second one with the parameters overall, match, value and certification value, and the third variant has the overall certified match value and a reference to a PlimFuzzySet object as parameters. The ass_comp_and and the ass_comp_or operators are based on the tangent function, and provide associative and compensatory operators. In order to get a grip on the operator's functionality have a look at the picture below.


Associative compensatory operator
f(x)=arctan(tan(x*pi/2)*tan(y*pi/2))/pi*2

The fuzzy_and and the fuzzy_or operators are implemented by the use of the so-called Gamma operator, therefore it is necessary to add a further argument to the parameters mentioned above, namely the gamma value. This value provides the opportunity to modify the extent of compensation and determine how fuzzy the operator should be.

DefOp

This class has no attributes and provides methods to apply the defuzzification operator. The procedure used to achieve this is the center of gravity method. The method cog therefore generates the cover of the CombinedVariable referenced in the parameter and then integrates the cover via the method integrate. This method is reponsible for the calculation of the center of gravity and returns a float value, that is the crisp value - which is the defuzzified value of the linguistic variable.

OperatorSet

This class aggregates the operators and methods necessary for FLIP++ to do calculations with a linguistic variable. There are four important steps to achieve results from a rulebase: These are aggregation, certification, inference and accumulation. According to these four steps there are four functions aggregate, certify, inference and accumulate. The attributes of the OperatorSet are the FuzzyOperators - and_operator, or_operator, certainty_operator, inference_operator, accumulate_operator, importance_operator -, the DeFuzzyOperator defuzzy_operator, and the integers accuracy and gamma.

The default constructor initializes all the operators of the object and sets the accuracy and gamma to a default value. The method copy relocates all the parameters from an OperatorSet object into the current one. The method show writes all the parameters of the OperatorSet object to the standard output device. The methods read and write handle input/output to files. Moreover, there are simple methods to set and get the values of all the attributes of the OperatorSet.

join_mv_with_importance

This function combines a match value and an importance with the importance operator of an OperatorSet object.

aggregate

This function aggregates the match values of all instantiated membership functions stored in an FList object to an overall match value by applying the concat operator type specified by the parameter through the operators of the referenced OperatorSet object.

certify

This function calculates the overall certified match value by applying the certainty operator of the OperatorSet object referenced to the overall match value and the certainty value.

inference

This function calculates a new match value by applying the inference operator to the overall certified match value and the old match value of the PlimFuzzySet referenced.

accumulate

This function accumulates the value of a linguistic variable by calculating its crisp value through the defuzzification process (center of gravity).

fliprule.h / fliprule.cpp

Term

This class represents a term consisting of a linguistic variable and an associated linguistic term, for example, 'TEMPERATURE is HIGH'. This class also represents the already familiar list concept of FLIP++, it is the element class that is aggregated in a linear list in the TList class. The attributes of the object are a reference to a CombinedVariable object cv, a string lt for the linguistic term (of type Name), and a reference to another Term which is used in the TList class.

The default constructor initializes an empty object referencing no linguistic variable and a default linguistic term. The destructor empties the object by dissolving any references to a CombinedVariable object and to another Term. The method show writes the term in a format identical to the above example to the standard output device. The same is done by the methods read and write, except they read from and write to files, the method read also checks whether the read term is formed with a valid linguistic variable given a list of linguistic variables. The method copy copies an existing term to the current term, i.e. its linguistic variable reference and the linguistic term. Furthermore, there are simple methods to get and set the attributes of the class.

TList

This class is a linear list of Term objects. The attributes of the list are the references to the first and last Term object in the list, while number indicates the number of elements contained in the list.

The default constructor creates an object as an empty list. The destructor empties the list by deleting all its elements according to a clean memory management. The method show without parameters displays all terms contained in the list via the standard output device. Alternatively, the show method has a ConcatOperator as parameter and concats all terms of the list with this parameter for output. The method write does the same as the latter show method, but instead of standard output it uses a file for output. The read method reads a complete list of terms from a file. The add method adds a new term to the list by taking its linguistic variable and linguistic term as parameters. The add method without parameters adds an empty (default) term to the list. The method find accesses a term by its index in the list. Furthermore it is possible to retrieve the index of an element containing the linguistic variable specified by the parameter. As an alternative to the former method the array operator [] can be used. Apart from these find methods, there are also two other find methods find_cv and find_lt that return references to the CombinedVariable and linguistic term of the element specified by its index respectively. The copy method copies the element of an existing TList object to the current object. The method remove removes the element specified by its index, whereas remove_all deletes all elements of the list. Again, there are simple methods to access the attributes of the class and to set the linguistic variable and linguistic term of an element specified by its index.

Rule

This class represents a rule consisting of a list of terms on the left side and a term on the right side. The left side terms are aggregated by a concat operator, additionally, every rule has a certainty attached to it. Again, several rules are combined in a list of rules, see the class RuleBlock for further details. Hence it is also necessary to have a reference to another rule. The format of a rule is: IF Term-List THEN Term WITH CERTAINTY c. Among the attributes are the left side terms stored in a TList object called ls_t_list, the right side y, the certainty (a float value), the ConcatOperator aggregate_operator for aggregation of the left side terms, and next - the reference to another rule.

The constructor initializes an empty object. The destructor deletes all terms referenced by the rule and initializes the other attributes. The method show writes the rule in the format introduced above to the standard output device. In the same way the method write handles output to files, and the method read input from files. The copy method copies an existing rule to the current rule object. Moreover, simple access methods render it possible to retrieve or manipulate the parameters of a rule, in particular, its left side linguistic variables and linguistic terms, the right side linguistic variable and linguistic term, the certainty, the number of left side terms, and the concat operator. Furthermore, the attributes of the rule can be retrieved and set.

RuleBlock

This class is the aggregation of several rules to a ruleblock, which is normally used to put all rules with the same right side linguistic variable together. In the next class RuleSet various RuleBlock objects are combined in a linear list. The attributes of the class are the references first and last to the first and last rule of the list with number indicating the number of rules contained in the RuleBlock, and next - referencing another RuleBlock.

The constructor creates an object containing an empty list. The destructor deletes all rules contained in the list according to a clean memory management. The method show displays all rules of the RuleBlock on standard output by calling the underlying show method of each rule. The methods read and write do the same, except they read/write to files instead of standard output. The method add has two variants: when it comes without a parameter it adds an empty rule to the RuleBlock while with a parameter it adds the rule specified in the parameter to the RuleBlock object. The find method accesses an element of the list by its index, whereas the find_cv method returns a reference to the linguistic variable of the right side term of the rule specified by its index in the list, and the find_lt method returns a reference to the linguistic term of the right side term of the rule specified by its index in the list. Alternatively the array operator [] can be used. The copy method copies the contents of an existing RuleBlock object to the curent RuleBlock object. The method remove deletes an existing element from the list of rules. Remove_all deletes all elements of the list. Furthermore, there are simple methods to get and set all the significant parameters of a rule described above in the rule class. Also, the attributes of the class can be set and retrieved by simple methods.

RuleSet

This class finally aggregrates all the different RuleBlocks into one linear list, called RuleSet, which includes additional parameters. Among them are a list of linguistic variables contained in the RuleSet, a list of ParameterSets and an OperatorSet, so this class combines all of the functionality contained in FLIP++. The attributes of this class - apart from the inherited ones - are rs_name, the name of the RuleSet of Name type, ps_list, the linear list of parameter sets, cv_list, a linguistic variable list, operator_set, the aggregation of all operators needed, and the attributes for the linear list of RuleSet first, last, and number.

The default constructor initializes a RuleSet object with a default (empty) PSList object, a default CVList object, a default OperatorSet, and no RuleBlocks. The alternative constructor takes a PSList, CVList, and OperatorSet object reference as input and initializes an empty (without RuleBlocks) RuleSet accordingly. The destructor deletes all RuleBlocks, the PSList, the CVList and the OperatorSet of the RuleSet according to a clean memory management. The method show displays all elements of the RuleBlock list on standard output. The methods read and write do the same as show except they read from/write to files instead of standard output. The add method adds a copy of an existing RuleBlock to the RuleSet. The add_all_RuleBlocks method adds a copy of a list of RuleBlocks, which of course is a RuleSet of its own, to the current RuleSet object. The method add_Rule adds a single rule consisting of a left-side term list, a right-side term, a concat_operator, and a certainty value to the RuleBlock of the RuleSet containing rules with the same right side linguistic variable as the rule to be added, or, if such a RuleBlock does not exist, to a new RuleBlock. Moreover, it is necessary to check whether this rule puts a new linguistic variable into the RuleSet which makes it necessary to update the list of linguistic variables. It is to be noted that a rule must not contain its right side linguistic variable in its left side. Furthermore, the method add_BasicRule makes it possible to add a BasicRule consisting of one left-side term (linguistic variable plus linguistic term), one right-side term (linguistic variable plus linguistic term), a nd a certainty to the RuleSet. The method add_ComplexRule is similar to the add_BasicRule method, the difference is that it adds a more complex rule consisting of two left-side terms instead of one to the RuleSet. Both add_BasicRule and add_ComplexRule use the generic method add_Rule to add the rule specified by the parameters to the RuleSet. The find method accesses a RuleBlock of the RuleSet by its index. As a modification to the find method the find_cv method returns a reference to the linguistic variable by which the rules were put together to a RuleBlock, it takes also the RuleBlock's index as an argument. An alternative to the former find method, the array operator [] can be used. The method search returns the index of the RuleBlock in the RuleSet that contains the linguistic variable specified in the parameter in its right side term(s). The method remove deletes the RuleBlock specified by its index. Alternatively, the method remove can be called with a linguistic variable as parameter which removes the RuleBlock containing this linguistic variable among its right side terms. The method remove_each_app_of_cv_in_rs_and_cvl removes all appearance of a linguistic variable in the RuleSet, i.e. each rule where the linguistic variable appears in the left side and the RuleBlock that aggregates all rules containing the linguistic variable in the right side, and CVList. The method remove_all deletes all RuleBlocks contained in the RuleSet.

The method evaluate starts the inference process for a specific linguistic variable by calling the internal_evaluate method. The process starts with checking whether all the left side linguistic variables in the RuleBlock of the linguistic variable to be evaluated are already instantiated or in turn appear on the left side of a rule, which makes it necessary to evaluate them first. Then each term on the left side of a rule is weighted with an importance through the importance operator, after that all match values of the left side terms of a rule are aggregated to an overall match value by the use of the aggregation operator. This overall match value is linked with the certainty of the rule to obtain the overall certified match value. Finally, the overall certified match value and the old match value of the linguistic term (Fuzzy Set) of the right side term are linked with the inference operator to produce the new match value of the right side linguistic term of the linguistic variable to be evaluated. When the inference process has finished the crisp value of the linguistic variable is calculated through the accumulate method (see flipoper.h / flipoper.cpp) and attached to the crisp value attribute of the linguistic variable. Apart from these complex methods, there are simple methods that enable setting and getting the values of the attributes, and also of those inherited from the parent classes.



Back to DocuFLIP++ overview StarFLIP home page.

(c)1996 Andreas Raggl, Mazen Younes, Markus Bonner, Wolfgang Slany

Last modified: Tue Jun 24 15:40:29 MET-DST 1997 by StarFLIP Team