# SEDFLC Toolbox¶

**Last News**:

Version SEDFLC_toolbox_v1.1 is available. *August, 2020*.

**This toolbox contains the proposed methodology to self-evolve an online fuzzy logic controller** published in:

Jérôme Mendes, Francisco Souza and Rui Araújo.

**Online Evolving Fuzzy Control Design: An Application to a CSTR Plant**.*In Proc. IEEE 15th International Conference on Industrial Informatics (INDIN 2017)*, pages 1-8, Emden, Germany, July 24 - July 17. IEEE. [doi].

**Abstract:** A methodology to self-evolve an online fuzzy logic controller (FLC) is proposed. The proposed methodology does not require any initialization at all, it can start with an
empty set of fuzzy control rules or with a simple collection of fuzzy control rules obtained from an expert operator. The FLC design is online, using only the input/output data obtained during the normal operation of the system while it is being controlled. The FLC is composed of a simple structure, where each input variable has its own set of fuzzy control rules, and is evaluated individually by the proposed methodology avoiding the high increase in the number of fuzzy control rules. From the results, the proposed methodology has the capability of designing the FLC in order to successfully controlling the system by evolving/modifying the FLC structure when unknown regions of operation are reached (unknown for the controller).

**Software source code:** SEDFLC Toolbox (Matlab implementation)

## How to Run¶

For use with Matlab:
- **Main.m** – Just run the Main file.

## Main Functions¶

**Main.m**– This is the main function.**EvolveFLC.m**- This function is the core function to self-evolve the fuzzy controller.**Initialization.m**- This function initializes the struct x, i.e. the initial parameters (Algorithm 2 Step 2).**UpdateAntecedent.m**- This function updates the antecedent parameters (Algorithm 2 Step 3.a).**UpdateConsequent.m**- This function updates the consequent parameters (Algorithm 2 Step 3.b).**FuzzyController_EstimationError.m**– This function obtains the estimated control error (equation (19), see Section III-C).**LocateMF_Gravity.m**- This function obtains the position/center of the new (candidate) membership function for variable j (Equation (22)).**AddMF_ErrorAVG.m**- In this function, if the Criterion 2 is met, a new membership function is added on input variable j.**AddNewConsequent.m**- This function obtains the consequent parameters of the new fuzzy rule (Equation (23)).**FuzzyController.m**- This function obtains the fuzzy control signal - equation 8.**Psi.m**– This function obtains the variable \(\Psi\) (equation (11)).**trifp.m**– This function obtains the fuzzy degree of a triangular MF for a given data.**update_window.m**- This function updates the temporal sliding window.**Plot_Evolve_Parameterts.m**– This function does plots of some important parameters on the evolving stage.**PlotMFs.m**- This function presents the plots of the membership functions of all input variables.

## Main Configuration Files¶

**ParametersConfig.m**– This file contains the main variables of the algorithm to defined:universe_x - Minimum and maximum values of the inputs variables.

eta_aux - parameters to define the minimal distance between MFs

Rules_ini - Initial number of fuzzy rules (the same of initial MFs).

control_min_max - Universe of discourse of the control variable [min max].

window_size - temporal sliding windows size.

beta - Learning gain \(\beta\) (antecedents).

C - Learning gain C (consequents).

delta - threshold \(\delta\).

**reference.m**– Definition of the reference and plant variables.

## Definition of the Struct x¶

x is a struct, in which, contains all parameters of the fuzzy controller.

**Elements of struct x, Rows:** contain all parameters of the fuzzy control rules for each input variable, e.g.:

**row 1**contains the parameters of the fuzzy control rules for the input variable \(x_1\)**row j**contains the parameters of the fuzzy control rules for the input variable \(x_j\)Figure 1 contains the parameters of the 2 input variables of the CSTR plant example.

**Elements of struct x, Columns:**

**First column:**contains the limits of the universe of discourse of the respective input variable.**Second column:**contain the initial number of fuzzy control rules of the respective input variable.**Third column:**contain the matrix rules of the respective input variable (Figure 2):**Rows:**each row represents a fuzzy controlrule;**1º column:**represents parameter \(a_{j,i}\) (lower limit of the respective membership function);**2º column:**represents parameter \(b_{j,i}\) (center value of the respective membership function);**3º column:**represents parameter \(c_{j,i}\) (upper limit of the respective membership function);**4º column:**represents the consequent parameter of the respective rule, \(q^{i_j}_j\).