**3. Fuzzy logic controller**

From the concepts of fuzzy logic, which include fuzzification, defuzzification, inference system and compositional rules, it was possible to build a fuzzy logic controller, where control actions are generated from a set of linguistic knowledge. In general, the FLC is conceptually easy to understand. Despite its easy understanding, its design requires a greater amount of parameterization than normal in other controllers [8].

Several previous works attest that the application of FLC can overcome the effectiveness of traditional controllers in several tasks. In fact, the FLC works perfectly in a dynamic control environment, its steps can be similar to other controllers. In the fuzzification stage, the signals from the plant's sensors and any other information that is declared important are mapped to the pertinence functions and appropriate truth values. Then, the processing step makes use of each appropriate rule, thereby generating a particular result individually and then combines the results of those rules. Finally, the result of the operation in the previous stage is then converted into the defuzzification to an output value according to the system in which the FLC is inserted [9, 10].

Regarding the FLC memberships functions (MFs), it should be noted that the most applicable functions are the triangular, trapezoidal and Gaussian MFs type. This is due to the fact that. In the FLC project there is no exact number of how many curves, or what types of curves must be inserted in order to improve the FLCs performance, this work is part of the specialist's commitment.

A fuzzy controller can contain dozens of pertinent functions and associated rules. The rules have an empirical character, since they are elaborated from the knowledge of a process specialist. This fact is especially important and makes the FLC different and advantageous compared to other controller architectures. The reason for this is that empirical rules are especially useful in plants that contain complex processes or even with insufficient information that would decrease the effectiveness of more conventional control techniques.

### **3.1 FLC designer**

Similar to what happens in fuzzy logic applications in other areas, the FLC project requires several operational requirements that must be adequately dimensioned for the correct functioning of this type of control. An important choice as to how the final control signal will take place is the decision between the TSK or Mamdani FLC. The general rule model is given as:

$$\textbf{IF} \, x \,\text{is} \, A \, \textbf{AND} \, y \,\text{is} \, B \, \textbf{THEN} \, u \,\text{is} \, \textbf{C}, \tag{3}$$

where, A is a fuzzy set of X, B is one of the fuzzy set of Y and C is fuzzy set U (signal of controller).

In the case of the FLC of the Mamdani type, each rule is a conditional fuzzy proposition, and different fuzzy relationships in A x B x C can be derived from it. The implementation of each rule is done by defining operators to process the rule's antecedent and the implication function that will define its consequent. In this case, the action of the FLC is defined based on the aggregation of rules that make up the algorithm. This aggregation results in the fuzzy set C, which defines the output of controller C. The effective output of the controller is then obtained through a defuzing process applied to set C.

The TSK FLC is a simplified model of the Mamdani controller, where the consequent of each rule is defined as a function of the linguistic input variables.

Each rule results in no longer a numerical value but a fuzzy set. The weight assumes the pertinence value resulting from processing the rule's antecedent. The value of **u** can be defined as a constant (single value with relevance equal to one) **singleton**. From a singleton it is possible define rules with output values that represent a classification of the controller response, without changing the simplified way of determining the final controller response.

In many practical situations of real controllers trapezoidal MFs are used for the function inputs. The reason is that several sensors installed in the system can present different noise in the measurement and as a consequence change some conditional rule in the operation of the FLC.

Regarding the design of the basic FLC rules, the expert needs to decide the total number of rules and how these operational conditions are related.

#### **3.2 FLC optimization**

The central idea of using metaheuristics in the pursuit of optimizing FLC performance is in the design characteristic of this controller. The various parameters and variables that are necessary for the good functioning of the FLC do not present general rules, making the role of the operator essential in the analysis and dimensioning of these terms [11].

Despite the specialist's knowledge, the resulting FLC may not perform as optimally. Metaheuristics, on the other hand, can function as an intelligent search engine for the various possible architectures for the FLC, without the need for the exhaustive work of trial and error on the part of an expert control engineer [11–13].

The use of a metaheuristic for the optimization of the FLC needs to be correctly dimensioned for its proper and effective functioning. There are different architectures to be explored when using these techniques despite an FLC [13]. **Figure 1** presents an FLC architecture using metaheuristics for its optimization.

From the observation of **Figure 1**, it is possible to notice that metaheuristics can help in the solutions of different areas of the FLC. There are several options for the parametric optimization of the FLC, therefore, the designer needs to define what one wants to obtain or which are the important parameters to be defined in his control project.

#### *3.2.1 FLC membership function optimization*

An application of FLC parametric optimization with metaheuristics is based on determining the positions and characteristics of MFs. In this case, algorithm

**Figure 1.** *FLC optimization scheme.*

#### *Fuzzy Logic Control with PSO Tuning DOI: http://dx.doi.org/10.5772/intechopen.96297*

objective is to find the values of each MF individually that allows to obtain a better performance of this controller [14].

Assume that you have determined a set of rules and chosen all the MFs in your project. A common application of a metaheuristic algorithm in this case is to determine the ideal positioning of the MFs. In this particular context, the MF designer is a time-consuming exercise and it is usually possible to achieve good results. For this reason, some techniques offer benefits to develop such functions. In this case, it is necessary to turn the positions of each MF into optimization variables of the algorithm. **Figure 2** presents a representation of this application.

**Figure 2** presents a possible model for the application of metaheuristic optimization of MFs. From a set of previously selected MFs, it is assumed that the positions of these functions are the variables (*xi*) of the optimization problem. In this way, the algorithm seeks to select such parameters, increasing or decreasing the space of each one in the possible set. The position and size of each MF is important since this has a direct influence on the output of the FLC system.

In this FLC optimization application, it is necessary to define which MFs are involved and the respective definition limits. In practice, it is necessary to limit the range of values for each variable (*xi*), thus avoiding that the optimization does not result in inadequate results.

#### *3.2.2 FLC rules optimization*

The optimization of the FLC rules is also an interesting application on this topic. Determining the rules of an FLC is naturally an empirical process, since trial and error are very necessary in order to be successful in these rules [15].

The application of metaheuristics in this case is configured to determine the best rules that, when combined in the logic of the FLC, optimize its operation. The variables in this situation are the defining set of MFs and can be combined in different ways to compose the rules. In this case, based on a previous set of information, it is possible to determine which variables will be part of a given rule and even how many rules should drive the FLC. **Figure 3** shows a metaheuristic scheme for the determination of a specific rule of the **IF-THEN** type.

**Figure 3** shows an optimization of rules based on IF - THEN. From the set of MFs (NB, NS, NM, Z, PS, PM, PB), the subsequent terms *y*1ð Þ*i* (*de/dt*) and *y*2ð Þ*j* (*e*), as well as the consequent term *z k*ð Þ can be defined appropriately for the formation of FLC rules. In this example, i = 7 and j = 7, totaling 49 possible rules to be determined by metaheuristic optimization.

**Figure 2.** *MF optimization scheme.*

#### **Figure 3.**

*Optimization scheme for fuzzy rule conditionals.*

Metaheuristic algorithm tests all possible combinations of the IF-THEN condition simultaneously, thus allowing to speed up this process of determining the FLC rules.

In fact, there are several possibilities for the elaboration of FLC rules, which makes this problem complex for the use of traditional optimization methods.

#### **4. Fitness function modeling**

One or more performance requirements can be used to compose the performance index of the system, which will serve as the objective function (fitness) of the optimization problem used to obtain the tuning of the controller. The performance and robustness requirements act as restrictions on the tuning of the controller, that is, they allow imposing limits on the behavior of the control loop. The performance index to be useful to the problem must be composed of system parameters, in addition to that, it must be computed with some ease, analytically or experimentally [16].

In order to make the optimization functional, the definition of a fitness function is extremely necessary. This function aims to assess the quality and behavior of the control system, allowing the designer to check how well his project is performing. In general, dynamic performance quality indices are adopted as variables of an objective function in control systems.

The composition of the objective function is based on the dynamic characteristics that the operator wants the FLC to achieve in the optimization. This definition happens empirically based on the observation of the system and execution tests.

If the designer wishes the controller response to have a low overshooot value, this variable should be added with some gain in the composition of the fitness function. This gain depends on how much this variable is intended to influence the optimization goal. Moreover, if there is a desire to minimize some error rate in general, ITAE, ISE or IAE can be adopted in the function.

In such cases, the goal of metaheuristics is to minimize the objective function and, since this function is directly associated with a specific parameter, the specific objective can be achieved.

In order to demonstrate the construction of the objective function, consider the following general formulation

$$J = \mathbf{C}\_1 \mathbf{X}\_1 + \mathbf{C}\_2 \mathbf{X}\_2 + \dots + \mathbf{C}\_n \mathbf{X}\_n,\tag{4}$$

where *Ci* represents the constants that are associated with the variables of interest *Xi*. The designer must determine how many variables one wishes to compose the function such that it achieves its final FLC performance objective. However, some variables in the function can be redundant and not affect the overall performance of the optimization. In this way, the designer's expertise is essential to obtain a function that allows an effective optimization of the FLC.
