Abstract
The fuzzy control uses qualitative knowledge with linguistics descriptions about the operation of any process. Furthermore, Fuzzy Controller (FC) has several parameters which can be adjusted to change the performance. If this adjust is done through a “trial and error” procedure, then it will be very time-consuming and difficult to reach a good performance. Frequently, the tuning of the Membership Functions (MFs) have the most influence to improve the performance of a FC. Therefore, in this study we tune the MFs of a FC using optimization by Direct Search (DS) method, specifically the pattern search. In this sense, our goal is to improve the performance of the system to satisfy certain conditions and propose optimization method to tune the MFs. The methodology of the optimization is simulation-based. The Objective Function (OF) is the squared error between the set point and the output of the system. The evaluation of the OF and the implementation of the fuzzy control system were performed by simulations. An explanation of the algorithmic method based on the pattern search algorithm is shown. The method proposed in this paper is illustrated with examples for the non-linear systems. The results are compared and discussed with other controllers.
Introduction
Most of the processes in our real world have inaccuracies, uncertainties and subjective situations, whereby, the fuzzy control is a practical alternative of conventional methods to resolve control problems in the industrial processes [17, 22]. Fuzzy control has had an important success in many applications from its beginning. In the engineering field, several industrial applications have achieved good results in performance control [4, 23].
Generally, a FC is designed with information, human knowledge and experience that an expert has on some process to be controlled [22]. The expert of a system may be able to design a FC for the system, due to his knowledge about the relations between inputs and outputs of the system.
The fuzzy control uses a qualitative knowledge with linguistic descriptions about the operation of the process [32]. Furthermore, FC has several parameters that should be adjusted and this procedure is obtained through a trial and error process [31]. This procedure is time-consuming and is typically characterized by poor performance, especially when dealing with complex systems [10]. The design of a fuzzy control includes the rule base, and the MFs [24].
Frequently, the tuning of the parameters as the MF and/or the rule base (knowledge base), have influence to improve the performance of a FC [30]. Some studies have shown that fuzzy control system performance is more dependent on MF design than rule base design [24]. Most researchers concentrated on tuning the membership sets, [12] produce a set of optimal MFs, [1] presented a method for optimizing a fuzzy system by adjusting the MFs, and [20] presented a method for systematic approach for determining the grades of membership of fuzzy sets. Since MFs of the controller has important impact on fuzzy control system performance, in this paper, we argue to the tuning of MFs.
Researchers have used many different methods to adjust the MFs [26]. The methods can be widely divided into two types: those that explicitly use the derivatives of the fuzzy control systems performance with respect to the fuzzy parameters, and those that use derivative-free methods instead. The derivative-free methods include genetic algorithms [19, 29], neural networks [2, 9], evolutionary programming [11], simplex method [8, 13], derivative-based methods include gradient descent [7], Kalman filtering [25], and other numerical techniques [21].
Some researchers avoid to use the classical optimization methods as compared to techniques such as neural networks, genetic algorithms, particle swarm optimization, simulated annealing, tabu search, etc., [30]. In [12] used simulated annealing to produce a set of MFs. [20] presented a method for systematic approach for determining the grades of membership of fuzzy sets using the simplex optimization method.
Derivative-free methods or non-gradient search methods can be desirable due that they do not require the explicit derivatives of the OF with respect to the fuzzy parameters. These methods have the advantage of not calculating the gradient, when searching for an optimal solution of a function whose gradient can be only calculated using numerical differentiation [30]. The derivative-free methods are robust with respect to finding a global minimum and with respect to their applicability to a wide range of objective functions. The derivative-based methods dependence on analytical derivatives, thus, they are limited to specific objective functions [26]. The derivative-free method has the benefit that it can easily escape from a local minimum [24]. However, they typically tend to converge more slowly than derivative-based methods which have the advantage of fast convergence but they tend to converge to local minimum. The selection of derivative-based or derivative-free method must be based on compromises between a wide range of issues, including the initial condition guess, computational effort, the OF (the controller performance index) which usually may be non-differentiable [30], and flexibility with respect to MF types [24].
In the present paper, we propose an optimization methodology to tuning the MFs based on non-linear programming techniques with a pattern search method, which is part of family of the DS method [16]. Our main contributions are: a) the tuning of MFs with a derivative-free optimization method, which is simple, easy and fast to implement, and b) to share all the necessary and sufficient restrictions that MFs must have, when the optimization method is applied.
DS methods were applied to optimize a FC. In [1, 20] a simplex method based on [27] with constraints and penalty was used to optimize a fuzzy control systems by adjusting the MFs. An algorithm based on modification of the Hooke-Jeeves optimization method for optimization the MF was presented in [30]. In this case, the algorithm looks like pattern search method.
DS optimization based on methods that does not use the derivatives to find global o local optimal, and cha-racterized by decision making according to the values taken at the OF. These methods often have developed on the heuristic and fairly simple to implement [3].
This paper presents: a) a novel methodology for tuning the MFs with a DS optimization method, in particular, the pattern search optimization method, b) an original approach of the restrictions of the MFs, and c) applying the pattern search algorithm to the constrained optimization problem.
The paper is organized as follows: in the section II includes a brief description of pattern search optimization method. Section III presents the optimization procedure that is used to tune the MFs. Section IV shows examples of the non-linear physical systems, and the results and comparison. The first example is a water tank level control system, and the second is inverted pendulum system. It gives the ideas how to be applied to the problem of designing the FC and how can be used the pattern search algorithm to the problem. Finally, section V outlines the conclusions.
Brief description of pattern search optimization method
The pattern search method consists of establishing a pattern with a geometric configuration and a step length around an initial point which will be the center of the pattern. At the pattern’s extremes there are test points to be evaluated in the OF to know which is the best point, after that, the pattern will move to that point. The pattern’s extremes points generate a search direction, moving the pattern towards the optimum point. When the extreme points are no better than the center point of the pattern, the size of the pattern shrinks reducing the step length of the pattern. Searching will be terminated when the step length falls below a specific tolerance. This method was first proposed in the DS paper by Hooke and Jeeves in 1961 [16].
Exploratory movements examine the local behavior of the OF and help locate any existing slope in the area. Fig. 1 illustrates the pattern search in two-dimensional. We can see the pattern with its initial point guessed indicates as black circle and around the test points placed East, West, North, and South. Also, we can observe the optimum point (x*) and the movement of the first five iterations. Note, that close to optimum point the step length is reduced.

Graphical representation of the pattern search method in two-dimension with five interaction.
The initialization of the algorithm of the pattern search includes an x0 denoting the initial point guessed, an initial step length (Δ0), and a set of vectors d
i
called patterns which indicate the directions of the coordinates. The set of vectors (d
i
) can be formed as a matrix, denoted as
The method is an iterative process, where f (x
k
+ Δ
k
d
i
) is calculated in the kth iteration for all 2n vectors of
Let
Let Δ tol > 0 be the tolerance used to test convergence.
Let Δ0 > Δ tol be the initial value of the step-length control parameter of the algorithm.
Let
The majority of the computational cost occurs in Step 2, in the evaluation of the OF at test points. Although, there would be an option that is to evaluate each test point in sequence but stop at the first one, if any, that satisfies f (x k + Δ k d i ) < f (x k ). With this condition satisfied, a direction is found and the iterate is successful [16]. After any unsuccessful iteration (where Δ k is reduced), Δ k is compared to the preset stopping tolerance Δ tol to test for convergence. Once the step-length drops below Δ tol , the search finishes with x* = xk+1. Note that Δ k is only shortened after unsuccessful steps; so the search will not stop after a successful step.
We study the tuning of the trapezoidal MFs is des-cribed using four parameters which are the values in the Universe of Discourse (UD), see Fig. 2. The four values

Trapezoidal MF showing 4 points.
The equation of the trapezoidal MF is,
The values in the UD of a MF are subject to the following constraints,
This constraint is necessary to ensure the grade of membership of any linguistic term is unique. Fig. 3 shows cases when the constraint Equation (4) was not imposed. The values

Cases when the constraint Equation (4) is not considered.
MF of each linguistic term is subject of constraints based on Equations (4), (5), and (6). Additional constraints should be added to describe a fuzzy system. The overlapping is a very desirable property of the input MFs.
An input linguistic variable can have several linguistic terms. In this case, depending on the rule base we should consider an important restriction, which is the overlap of the antecedent MFs. On a fuzzy system, must satisfy at least a fuzzy rule otherwise the result would be undetermined and the system could be unstable. Hence, to satisfy a rule, an element of the UD of the input linguistic variable have to belong to any fuzzy set. In other words, a value of the input linguistic variable into the UD must have a grade of membership on any linguistic term. Fig. 4 shows the case that must be avoided. We see the x a point which does not have membership on any fuzzy set, in this case between the linguistic term denoted with j and j + 1.

Location not allowed of the input MFs.
In order to satisfy the proposed consideration, it is necessary that the MFs are positioned as indicated in Fig. 5. This leads to the constraint where the endpoints of each MF comply with the following:

Location allowed of the input MFs.

(a) Interpretability, simple overlapping. (b) Non interpretability, multiple overlapping.
The constraint, Equation (7), guarantees the overlap of the input MFs. Another consideration that we must take is the occurrence of the multiple overlapping MFs, which is perceived as a critical issue named “model interpretability” in fuzzy modeling as noticed in [6, 15]. Interpretability has earned special attention when the linguistic fuzzy modeling generates systems for which the language is easily interpretable by human beings [6]. This issue is important when the fuzzy control is designed with linguistic descriptions about the operations of the process, moreover the multiple overlapping is critical in feedback control system due the system might be unstable. The interpretability is used to indicate how easily a fuzzy description can be understood by human beings [14]. Fig. 6 shows interpretability in the fuzzy sets.
To resolve this problem we avoid that the maximum value of x right trapezoid is greater than the maximum value of x left trapezoid of the next trapezoidal MFs. In the other words, between the linguistic term denoted by j and j + 1 the maximum value of x right is less than the maximum value of x left. Hence, we defined the following constraint
There are cases where the MFs are symmetrically placed around a value of each variable. Overall, the MFs are placed around the zero value. As an example, the problem of guiding a car to control the navigation is necessary to ensure that no preference to the left or right steering occurs; all MFs are defined in a symmetry around the zero value. Fig. 7 illustrates the MFs around the x = 0.
The symmetrical condition leads to a reduction of the points to be adjusted. These conditions are,
Define the fuzzy control system and the OF, where the decision variables are the values of the vertexes in the UD of the MFs. We state a constrained optimization problem as follows:
The OF is the squared error between the set point and the output of the system, that is,
The methodology of tuning is based on the pattern search optimization algorithm and it is performed by simulation. The evaluation of the OF depends on the simulation at every instant and FC can be evaluated according to the values taken by the vertices in the UD of the MFs. The pattern search algorithm with restriction can be described using the following steps:
Let
Let
Let Δ tol > 0 be the tolerance used to test convergence.
Let Δ > Δ tol be the initial value of the step-length control parameter of the algorithm.
Let β where 0 ≤ β < 1. It is the control parameter of the constraint.
Let
a) x p = x p + Δd k .
b) Verify constraints (4), (5), (6), (7), and (8). If any constraint is not satisfy then do the following:
b1) β′ = β.
b2) x p = x p + β′Δd k .
b3) Verify constraints (4), (5), (6), (7), and (8). If any constraint is not satisfy then β′ = β′/2 and go to b2.
c) Test simulation.
d) f1 = f (x p ). If f1 < f, then do the following:
d1) x p = x p + Δd k . (move the pattern and no change to the step-length)
d2) Verify constraints (4), (5), (6), (7), and (8). If any constraint is not satisfy then do following:
d2.1) β′ = β.
d2.2) x p = x p + β′Δd k .
d2.3) Verify constraints (4), (5), (6), (7), and (8). If any constraint is not satisfy then β′ = β′/2 and go to d2.2.
d3) Test simulation.
d4) f = f (x p ).
d5)
The method proposed can be used with the same technique and approach for any non-linear system, for example: a water tank level control system, an inverted pendulum system, the ball and beam system, and the navigation of an autonomous vehicle, among others. As follows, we illustrate two examples of non-linear physical systems in order to apply the methodology presented and how to design the fuzzy control strategy. One example is the water tank level control system, and the other one is an inverted pendulum system. For both cases, the control system was implemented in Simulink and the FC was designed with the Fuzzy Logic Toolbox of MATLAB®.
A water tank system
The water tank system is shown in Fig. 8. Water flows into the top of an open tank with a flow rate. Using the conservation of mass principle for a control volume, the dynamic equation of water tank system can be expressed as [5]:

Trapezoidal MFs placed symmetrical around the x = 0.

A water tank system.
The controller for the water level in the tank needs the information of the actual water level and it has to be able to set the valve. Our controller’s inputs will be the water level error (“levelerror”) (desired water level minus current water level) which is the number one (i = 1) input, the change rate of the water tank level (“rate”) which is the number two (i = 2) input, and its output will be the rate at which the valve is opening or closing (“valve”). The FC has two inputs and one output. The block diagram for the water tank system is shown in Fig. 9, where, the input variable of the system is the desired water level and the output variable of the system is the current water level.

Block diagram for the water tank system.
The initial MFs of the inputs “levelerror” and “rate” are shown in Fig. 10 and Fig. 11, respectively. We use the Equation (3) for the trapezoidal MF. The MF of the output “valve” is shown in Fig. 12. The fuzzy linguistic terms and linguistic numeric value of the variables are indicated in Figures 10, 11, and 12 over each MF. The control rules used in the FC are: IF (levelerror is high) THEN (valve is close_fast). IF (levelerror is okay) THEN (valve is no_change). IF (levelerror is low) THEN (valve is open_fast). IF (levelerror is okay) and (rate is negative) THEN (valve is open_slow). IF (levelerror is okay) and (rate is positive) THEN (valve is close_slow).

Initial MF of the input “levelerror”.

Initial MF of the input “rate”.

MF of the output “Valve”.
The FC is a Mamdani fuzzy system. The operator to represent the “and” in the premise and the implication is the min operator. The composition of the rules is the max operator. The centroid method is used in defuzzification. Figure 13 shows the corresponding initial rule surface of the FC which is a non-linear system. The input MFs are symmetrically placed, see Fig. 10 and Fig. 11; therefore, we used the symmetrical condition (indicated in section III) and the values of the vertexes in the UD of each MFs will be the decision variables for the optimization problem which are:

Initial rule surface of the water tank system.

Initial response of the water tank system.
With restrictions given in section III, the optimization problem is a constrained optimization.
The initial performance of the controller is not satisfactory as seen in Fig. 14. The level does not reach the desired value for either of the two levels (high and low) obtaining an approximate steady state error of 0.1. It is not possible determine a rise time or settling time, due the actual value does not reach the desired value. The simulation is carried out over a period of 100s with a square wave which the first half period is the high level desired and the second half period is the desired low level. Each half cycle represents a step input to fuzzy control system.
After completion of the tuning with the pattern search algorithm using restrictions, the MFs have been modified and are depicted in Fig. 15. The final rule surface is shown in Fig. 16, we can see that the non-linearity of the FC is maintained, unlike of Fig. 13 it can be seen that certain zones have been adjusted in the optimization process.

The tuned MFs of the FC water tank.

Final rule surface of the water tank system.
The response of the tuned FC is in Fig. 17. It can be observed that an improvement has been obtained by the tuning process of the MFs. In the high level response has a rise time equal 24.5s, a settling time greater than 40s and a steady state error equal -0.02. In the low level response has a rise time and a settling time equal 30s, and a steady state error equal 0.012. Resulting in an acceptable performance and better than the initial performance of the controller.

Response of the water tank system with tuned MFs.
The FC is compared with a PID (Proportional-Integral-Derivative) controller. The response with PID controller is in Fig. 18. It can be seen that although the PID has better rise time and settling time, this has an overshoot in the high and low level response. Sometimes this overshoot is undesirable, in the case of water tank depending on its height the liquid may overflow. This situation is not in the FC.

Response of the water tank system with PID controller.
The problem of an inverted pendulum is considered a benchmark for non-linear control design, and it is a classical problem in control theory. Inverted pendulum control is similar to the problem of the position control of a rocket during the initial stages of launch, similarly try to balance a broomstick on a finger. The problem consists of balancing the pendulum on a car, as shown in Fig. 19. The car must move so that the bar is always in the vertical position. The car is controlled by a force and it is free to move on a one-dimensional track. The dynamics of the inverted pendulum system can be characterized by state variables, with x1 = θ denoting the angle of the pendulum with respect to the vertical line, and x2 denoting the angular velocity of the pendulum. One model for the inverted pendulum using the state equation can be expressed as follows [22]:

Inverted pendulum on a car.
In the design of the FC, we treat the inverted pendulum as a black box and we only study its dynamic behavior. Let θ denotes the angle that the pendulum makes with the vertical line (in radians), l is the pendulum length (in meters), u is the force applied that moves the car (in Newton), and r denotes the desired angular position of the pendulum. The goal is to ba-lance the pendulum in the upright position (r = 0) when it initially starts with some nonzero angle off the vertical (θ ≠ 0). We analyze the system of the inverted pendulum and choose the input and output variables of the FC. The input variables are “error” (e),
The output variable u (t) is the “force” that moves the car. For the inverted pendulum, the reference input is r = 0 then as e = r - θ we have
All variables are expressed in terms of fuzzy linguistic terms. We assume that “error”, “change-in-error”, and “force” take on the same following terms: “neglarge”, “negsmall”, “zero”, “possmall”, and “pos-large”. We use the linguistic numeric value integers for an shorter description: “-2” represents “neglarge”, “-1” represents “negsmall”, “0” represents “zero”, “1” represents “possmall”, and “2” represents “poslarge”. Defined the linguistic terms, next we will using linguistic descriptions to study how to quantify knowledge about how to control the pendulum. Some declarations that give an understanding of the dynamics of the inverted pendulum are: “error is poslarge” can represent the situation where the pendulum is at a significant angle to the left of the vertical. “error is negsmall” can represent the situation where the pendulum is just slightly to the right of the vertical, but not too close to the vertical to justify quantifying it as “zero” and not too far away to justify quantifying it as “neglarge.” “error is zero” can represent the situation where the pendulum is very near the vertical position. A linguistic quantification by “zero” is not precise, but can be considered a better quantification than “possmall” or “negsmall”. “error is poslarge and change-in-error is possmall” can represent the situation where the pendulum is to the left of the vertical and the pendulum is mo-ving away from the upright position (the pendulum is moving counterclockwise).
The declarations above give us an overview of ope-ration of the process and we use these linguistics quantifications to specify a set of rules about how to control the inverted pendulum. Some of them are: IF (error is neglarge and change-in-error is neglarge) THEN (force is poslarge). It is the situation where the pendulum has a large positive angle and is moving clockwise; hence we should apply a strong positive force (to the right) so that we can try to start the pendulum moving in the proper direction. This situation is in Fig. 20a. IF (error is zero and change-in-error is possmall) THEN (force is negsmall). It is the situation where the pendulum has nearly a zero angle with the vertical (a linguistic quantification of zero does not imply that e(t) = 0 exactly) and is moving counterclockwise; hence we should apply a small negative force (to the left) to counteract the movement so that it moves toward zero. Fig. 20b. IF (error is poslarge and change-in-error is negsmall) THEN (force is negsmall). It is the situation where the pendulum is far to the left of the vertical and is moving clockwise; hence we should apply a small negative force (to the left) to assist the movement, but not a big one since the pendulum is already moving in the proper direction. Fig. 20c.

Inverted pendulum in various positions.
We could continue to write rules, but a convenient way to list all possible rules is to use a matrix representation, shown in Table 1. With a finite number of linguistic variables and linguistic terms, there is a finite number of possible rules. For two inputs and five linguistic terms for each of these, there are 52 = 25 possible rules (all possible combinations of premise linguistic terms for two inputs). Notice in Table 1 there is a symmetry respect a diagonal of zeros. This symmetry that emerges when the rules are tabulated is not an accident. Indeed, it is a representation of abstract knowledge on how to control the pendulum; it arises due to a symmetry in the system’s dynamics.
Rule base of the inverted pendulum
We use the min operator to represent the “and” in the premise and the implication. The composition of the rules is the max operator. Thereby forming the inference process known as the max-min. The FC is a Mamdani fuzzy system and the centroid method is used in defuzzification. In Fig. 21, we can see the initial guess MFs and the initial rule surface of the FC is shown in Fig. 22. The block diagram for the inverted pendulum system is shown in Fig. 23. The input and output variables of the system are the angular position desired, and the angular position, respectively.

Initial guess MFs of the inverted pendulum.

Initial rule surface of the inverted pendulum.
As the same case of the example of the water tank system, the tuning of the input MFs of the inverted pendulum system is an optimization problem with constrains which are given in section III and we used the symmetrical condition of the MFs, see Fig. 21. The decision variables for the optimization problem are the values of the vertexes in the UD of each the input MFs:
The initial response is shown in Fig. 24 with an initial position at an angle of 0.1rad. The pendulum is balanced (vertical position r=0) in approximately 20s.

Block diagram for the inverted pendulum system.

Initial response of the inverted pendulum system.
When we applied the tuning process, we obtained the MFs as show in Fig. 25 with the UD normalized. Figure 26 shows the final rule surface of the FC. The response of simulation with the angular position equal 0.1rad is in Fig. 27 and the time to get the balance is approximately 1.5s, much less than initial response.

Tuning of the input MFs of the inverted pendulum.

Final rule surface of the inverted pendulum.

Responses of the inverted pendulum system.
The initial controller and the tuned FC are compared with a controller’s Proportional, Integral and Feedforward Gains (PIFG). It controller was optimized with a gradient descent algorithm. Fig. 27 we have the response of the three controllers and we see that both optimized controllers have approximately the same time value for the equilibrium of the pendulum. Although, the controller’s PIFG presents an overshoot, that means the pendulum was in the other side of the vertical position with respect to the initial position and after the pendulum get the balance.
Furthermore, other simulations were performed with other initial angles, Fig. 28 shows those responses and they were compared with the results obtained with a gain scheduling PID controller (Fig. 29) which is optimized with genetic algorithm [28]. We find improvements in the response obtained with search pattern algorithm (Fig. 28), regarding of the time value of the equilibrium and particularly the response with an initial angle position equal 0.6rad where in Fig. 29 we see an overshoot. Moreover, Fig. 29 for an initial angle of 0.7rad the system it becomes unstable, whereas in Fig. 28 does not occur. Tuning of the MFs becomes unstable to 1.19rad (≅68 o ). The results show that the proposed scheme are satisfactory.

Response with different initial angle. Inverted pendulum.

Response with different initial angle of the gain scheduling PID controller. Inverted pendulum.
This paper presents a method for the design of a FC for optimal performance by tuning of the MFs. Also, the constraints for ensuring meaningful shape of the MFs are also imposed. The target of optimization used is to improve the controller’s performance to obtain the best response time. The results have shown that the tuning of the MFs of a FC is performing satisfactorily compared with other controllers. In our case of the inverted pendulum, we reduce the rise time regarding the initial response of the FC and the PIFG controller optimized with a gradient descent algorithm. The overshoot and the rise time were improved with a great initial angle compared with other controllers. In the case of a water tank system, we get better a system response compared with an initial response and the overshoot is enhanced with respect of a PID controller.
The pattern search method is simple, easy and fast to implement. Furthermore, it is reliable to be applied to modify the MFs of the system. The system converges to a good solution with only tuning of the input MFs. Further research is recommended to combine the tuning of the input MFs with the output MFs.
The use of a constrained optimization allows a better performance in terms of rise time, settling time, overshoot, steady state error and provides an automatic adjustment mechanism for the MFs. The constrained optimization approach guarantee the simple overlapping of the MFs and resolves the problem of the multiple overlapping of MFs.
Finally, future research will focus on the application another method of DS optimization to compare with the pattern search method.
