The Xfuzzy 3 development environment

The C++ code generation tool - Xfcpp

The tool xfcpp generates a C++ representation of the fuzzy system. The tool can be executed from the command line, with the expression "xfcpp file.xfl [out_dir]" or from the Synthesis menu in the main window of the environment. This tool neither has a specificgraphical user interface because the generation of the C++ representation does not need any additional information. Only a window will appear that allows selecting the directory in which the generated files will be stored.

Given the specification of a fuzzy system in the XFL3 format, systemname.xfl, the tool generates four files: xfuzzy.hpp, xfuzzy.cpp, systemname.hpp, and systemname.cpp. The files xfuzzy.hpp and xfuzzy.cpp contain the description of the C++ classes that are common to all fuzzy systems. The files systemname.hpp and systemname.cpp contain the description of the specific classes of the system. The files with '.hpp' extension are header files that define the class structures, while the files with '.cpp' extension contain the body of the functions of each class. All the files are generated in the output_dir directory, indicated when the tool is executed (by default, the same where the systemname.xfl file resides).

The C++ code generated by xfcpp develops a fuzzy inference engine that can be used with crisp values and fuzzy values. A fuzzy value is encapsulated into a MembershipFunction class object.

class MembershipFunction {
 enum Type { GENERAL, CRISP, INNER };
 virtual enum Type getType() { return GENERAL; }
 virtual double getValue() { return 0; }
 virtual double compute(double x) = 0;
 virtual ~MembershipFunction() {}

The class describing the fuzzy system is an extension of the abstract class FuzzyInferenceEngine. This class, defined in xfuzzy.hpp, contains four methods that implement the fuzzy inference process.

class FuzzyInferenceEngine {
 virtual double* crispInference(double* input) = 0;
 virtual double* crispInference(MembershipFunction* &input) = 0;
 virtual MembershipFunction** fuzzyInference(double* input) = 0;
 virtual MembershipFunction** fuzzyInference(MembershipFunction* &input) = 0;

The file systemname.cpp contains the description of the systemname class, which implements the fuzzy inference process for the system. Besides describing the four methods of the FuzzyInferenceEngine class, the system class contains a method, called inference, which develops the inference process with variables instead of arrays of variables. For a fuzzy system with global input variables i0, i1, ..., and global output variables o0, o1, ..., the inference function is:

void inference(double i0, double i1, ..., double *o0, double *o1, ...);

For comments, patches, bug reports, etc contact us at:

©IMSE-CNM 2018