# Fuzzy Dynamic Parameter Adaptation in ACO and PSO for Designing Fuzzy Controllers: The Cases of Water Level and Temperature Control

Authors: Fevrier Valdez; Juan Carlos Vazquez; Fernando Gaxiola
Journal: Advances in Fuzzy Systems
 (2018)

---

## Abstract

A novel approach applied to Particle Swarm Optimization (PSO) and Ant Colony Optimization is presented. The main contribution of this work is the use of fuzzy systems to dynamically update the parameters for the ACO and PSO algorithms. In the case of ACO, two fuzzy systems are designed for the Ant Colony System (ACS) algorithm variant. The first system adjusts the value for the pheromone evaporation parameter from the global pheromone trail update equation and the second system adjusts the values for the pheromone evaporation parameter from the local pheromone trail update equation. In the case of PSO, a fuzzy system is designed to find the values for the inertia weight parameter from the velocity equation. Fuzzy logic controllers (FLCs) are optimized with ACO and PSO, respectively, to prove the performance of the proposed approach. The particular benchmark problems considered to test the proposed methods are the water level control in a tank and temperature control in a shower. Therefore, PSO and ACO algorithms are applied in the optimization of the parameters of the FLCs. The achievement of the proposed fuzzy ACO and PSO algorithms is compared with the original results of each benchmark control problem.


---

## Body

## 1. Introduction

In automating the design of fuzzy controllers, the use of metaheuristic algorithms has been amply proposed. The proposed approach is based on the swarm intelligence models [1] that perform research of the collective behavior in decentralized schemes; two swarm intelligence models are utilized in this paper: the Ant Colony Optimization (ACO) [2] and Particle Swarm Optimization (PSO) [3, 4] algorithms. The development of the swarm intelligence models is founded on imitating the social behavior of living beings, particularly of insects or animals, in performing the search for the optimal solution in a solution space for a problem.ACO is a metaheuristic algorithm based on the collaboration of artificial ants in a colony to search for an optimal solution for complex problems. In ACO algorithms, the collaboration between the artificial ants is an important part, and this consists in assigning the computational resources to artificial ants (artificial agents) by indirect communication mediated by the environment. ACO algorithms are utilized to solve many paradigmatic problems, like the Travelling Salesman Problem (TSP) [5, 6]. Different ACO variants have been used for fuzzy system controller problems models [7, 8]. Those algorithms have focused on fuzzy logic parameter tuning to find the values to each membership function, the membership functions type, the number of membership functions, and so forth [9, 10].The inspiration of PSO is based on the social behavior of flock of birds or fishes. The procedure of PSO to encounter the optimal solution is based on the task of this animal community. In a PSO method, in the search space, a swarm of particles (individuals) is scattered. Each particle can be an aspirant solution for the problem at optimization. The PSO has been implemented, obtaining optimal results, to different optimization problems, such as benchmark functions [11, 12], finding optimal results for permutation problems [13, 14], and optimizing the training of neural networks [15, 16] and we also found optimization of fuzzy inference systems [17] and some optimization problems for fuzzy control systems [18], even with other hybrid optimization algorithms [19].Unlike other algorithms that have been applied for control problems, we have proposed the design of fuzzy systems to adjust some parameters for each of the optimization algorithms. The algorithms, both ACO and PSO, are applied to optimize control systems [20, 21]. For this paper, we have considered two benchmark control problems for designing their fuzzy controllers with the proposed approach [22].The novelty in the contribution of this work is the development of fuzzy systems to dynamically adjust parameters of the ACO and PSO algorithms [23, 24]. In the ACO algorithm, we have proposed the use of two fuzzy inference systems to dynamically adjust in each iteration the pheromone evaporation parameter in the equations used to calculate the update of the local and global pheromone. For the PSO algorithm, we have designed a fuzzy inference system to adjust dynamically in each iteration the parameter of the inertia weight in the equation used to obtain the velocity of the particle. The approaches were applied to the optimization of water level control and temperature control in a shower for testing.In the PSO parameters control problems in this work, the membership functions will help in automating the fuzzy control [25, 26]. The rules were framed through numerous simulations, which are carried out to determine the best possible set of rules aimed at pushing the stability limits of the system to its maximum. The membership functions can be estimated by studying the behavior of different conditions and for different contingency cases [27, 28].The organization of this paper is as follows: Section2 describes some basic concepts of fuzzy logic, Section 3 provides a brief description of the fuzzy logic controller (FLC), and Section 3 explains the standard PSO and ACO algorithms with the basic structure for water level control in a shower in a tank and the structure for temperature control in a shower and the experimental results made in this research. The conclusions are summarized in Section 4.


## 2. Background

### 2.1. Fuzzy Logic Control (FLC)

The fuzzy logic control is utilized in ill-defined complex process that can be operated by a trained human without knowing the dynamics of the system.In a FLC, the basic idea consists in utilizing the knowledge of an expert operator for the construction of the FLC that performs the control for a system; the input-output variables for the system are represented by fuzzy rules (IF-THEN) at difference to a complicated mathematical model. In the design of the FLC, the use of fuzzy rules with linguistic variables and the fuzzy reasoning allows incorporating the experience of the human expert. A traditional scheme for a FLC is shown in Figure1.Figure 1
Scheme of fuzzy logic control (FLC).


### 2.2. Particle Swarm Optimization

PSO works with particles for representing a potential solution to the optimization problem [3, 4]; the process consists of flying around a search space, and the position of each particle is updated using the personal experience and the social particles experience [29, 30]. The position of each particle is updated by the following equation:(1)xit+1=xit+vit+1wherexi(t+1) describes the position of the particle i in the time (t+1), xi(t) describes the position of the particle i in the time (t), and vi(t+1) denotes the velocity of the particle i in the time (t+1).In this work, we utilized the gbest PSO variant, in which the experience neighborhood for each particle is obtained from the entire swarm. For each particlei, the velocity is calculated with the equation as follows:(2)vijt+1=vijt+c1r1jtyijt-xijt+c2r2jty^jt-xijtwherevij(t) describes the velocity of the particle i in the dimension j in the time t, xij(t) represents the position of the particle in the time t, yij(t) denotes the best position of the particle, y^j(t) describes the global best position of all particles, c1,c2 are cognitive and social components, respectively (positive acceleration constants), and r1j(t),r2j(t) are random numbers in the interval [0,1].Some research work has been developed to enhance the convergence and the optimal solution obtained with the basic PSO, like the velocity constriction [31], inertia weight [32], and velocity clamping [27].In this paper, a modification of the gbest PSO variant using the inertia weight (w) is proposed. The inertia weight allows having control in the exploration and exploitation swarm besides the control of the speed and direction of the particles. Equation (2) of the gbest PSO changes as follows:(3)vijt+1=wvijt+c1r1jtyijt-xijt+c2r2jty^jt-xijtA number of works to dynamically adjust the inertia weightw have been developed, like the random adjustments [33], linear decreasing [26, 34], nonlinear decreasing [34], and fuzzy adaptive inertia [35]. We propose adjusting the inertia weight w and learning factors c1 and c2 of the PSO during the iteration process.The learning factorsc1 and c2 affect the total velocity of a particle [36]. The cognitive component (c1) determines the own confidence of the particle and the social component (c2) defines the confidence of the particle in the neighbors.We have designed a fuzzy inference system for the adaptation of the inertia weight and learning factors; the design consists of the following:Two inputs: the number of iterations (NU) when the best fitness does not change and the actual value of the inertia weight (w)Three outputs: the change in inertia weight (chw) and the change in learning factors c1 and c2Three membership functions for each input and outputs in the fuzzy inference systems: they are shown in Figure2, defined as LOW, MEDIUM, and HIGH and represented as a left triangle, middle triangle, and right triangle, respectivelyFigure 2
Membership functions for the inputs and outputs of the fuzzy inference system.Figure3 illustrates the fuzzy inference system architecture with two inputs (the number of iterations when the best fitness does not change (NU) and the actual inertia weight (w)) and three outputs (the change in inertia weight (chw) and learning factors (c1) and (c2)).To obtain the newchw, c1, and c2 values, nine fuzzy rules are used in the fuzzy inference system. An example of one fuzzy rule is given as follows:
IfNU is MEDIUM, and
w is HIGHthenc1 is HIGH, c2 is HIGH and chw is LOWFigure 3
Fuzzy inference system to adjust thechw, c1, and c2 parameters.The rules were obtained by empirical knowledge obtained by experimenting and are shown in Table1.The range ofNU is in [1,10], the value for w is in 0.2≤w≤1.2, and the values of c1 and c2 are in 1.0 ≤ c1, c2≤2.0.The mathematical descriptions forc1 and c2 are defined with the following expressions:(4)c1=∑i=1rc1μic1c1i∑i=1rc1μic1wherec1 is percent of cognitive acceleration of the particle i, rc1 is number of fuzzy rules activated to c1, c1i is output of the fuzzy rule i for c1, and μic1 is membership function value of fuzzy rule i for c1.(5)c2=∑i=1rc2μic2c2i∑i=1rc2μic2wherec2 is percent of cognitive acceleration of the particle i, rc2 is number of fuzzy rules activated to c2, c2i is output of the fuzzy rule i for c2, and μic2 is membership function value of fuzzy rule i for c2.Table 1
Fuzzy rules forchw, c1, and c2.
Rule number Input Output N U w c h w c 1 c 2 1 1 1 3 1 1  2 1 2 1 3 3  3 1 3 1 3 3  4 2 1 3 1 1  5 2 2 2 1 3  6 2 3 1 3 3  7 3 1 3 1 1  8 3 2 1 3 3  9 3 3 1 3 3For obtaining the values of the variable, the Mamdani FIS model is utilized. The method of the centroid of area is performed to obtain the defuzzification:(6)O=∫zMozzdz∫zMozdz


## 2.1. Fuzzy Logic Control (FLC)

The fuzzy logic control is utilized in ill-defined complex process that can be operated by a trained human without knowing the dynamics of the system.In a FLC, the basic idea consists in utilizing the knowledge of an expert operator for the construction of the FLC that performs the control for a system; the input-output variables for the system are represented by fuzzy rules (IF-THEN) at difference to a complicated mathematical model. In the design of the FLC, the use of fuzzy rules with linguistic variables and the fuzzy reasoning allows incorporating the experience of the human expert. A traditional scheme for a FLC is shown in Figure1.Figure 1
Scheme of fuzzy logic control (FLC).


## 2.2. Particle Swarm Optimization

PSO works with particles for representing a potential solution to the optimization problem [3, 4]; the process consists of flying around a search space, and the position of each particle is updated using the personal experience and the social particles experience [29, 30]. The position of each particle is updated by the following equation:(1)xit+1=xit+vit+1wherexi(t+1) describes the position of the particle i in the time (t+1), xi(t) describes the position of the particle i in the time (t), and vi(t+1) denotes the velocity of the particle i in the time (t+1).In this work, we utilized the gbest PSO variant, in which the experience neighborhood for each particle is obtained from the entire swarm. For each particlei, the velocity is calculated with the equation as follows:(2)vijt+1=vijt+c1r1jtyijt-xijt+c2r2jty^jt-xijtwherevij(t) describes the velocity of the particle i in the dimension j in the time t, xij(t) represents the position of the particle in the time t, yij(t) denotes the best position of the particle, y^j(t) describes the global best position of all particles, c1,c2 are cognitive and social components, respectively (positive acceleration constants), and r1j(t),r2j(t) are random numbers in the interval [0,1].Some research work has been developed to enhance the convergence and the optimal solution obtained with the basic PSO, like the velocity constriction [31], inertia weight [32], and velocity clamping [27].In this paper, a modification of the gbest PSO variant using the inertia weight (w) is proposed. The inertia weight allows having control in the exploration and exploitation swarm besides the control of the speed and direction of the particles. Equation (2) of the gbest PSO changes as follows:(3)vijt+1=wvijt+c1r1jtyijt-xijt+c2r2jty^jt-xijtA number of works to dynamically adjust the inertia weightw have been developed, like the random adjustments [33], linear decreasing [26, 34], nonlinear decreasing [34], and fuzzy adaptive inertia [35]. We propose adjusting the inertia weight w and learning factors c1 and c2 of the PSO during the iteration process.The learning factorsc1 and c2 affect the total velocity of a particle [36]. The cognitive component (c1) determines the own confidence of the particle and the social component (c2) defines the confidence of the particle in the neighbors.We have designed a fuzzy inference system for the adaptation of the inertia weight and learning factors; the design consists of the following:Two inputs: the number of iterations (NU) when the best fitness does not change and the actual value of the inertia weight (w)Three outputs: the change in inertia weight (chw) and the change in learning factors c1 and c2Three membership functions for each input and outputs in the fuzzy inference systems: they are shown in Figure2, defined as LOW, MEDIUM, and HIGH and represented as a left triangle, middle triangle, and right triangle, respectivelyFigure 2
Membership functions for the inputs and outputs of the fuzzy inference system.Figure3 illustrates the fuzzy inference system architecture with two inputs (the number of iterations when the best fitness does not change (NU) and the actual inertia weight (w)) and three outputs (the change in inertia weight (chw) and learning factors (c1) and (c2)).To obtain the newchw, c1, and c2 values, nine fuzzy rules are used in the fuzzy inference system. An example of one fuzzy rule is given as follows:
IfNU is MEDIUM, and
w is HIGHthenc1 is HIGH, c2 is HIGH and chw is LOWFigure 3
Fuzzy inference system to adjust thechw, c1, and c2 parameters.The rules were obtained by empirical knowledge obtained by experimenting and are shown in Table1.The range ofNU is in [1,10], the value for w is in 0.2≤w≤1.2, and the values of c1 and c2 are in 1.0 ≤ c1, c2≤2.0.The mathematical descriptions forc1 and c2 are defined with the following expressions:(4)c1=∑i=1rc1μic1c1i∑i=1rc1μic1wherec1 is percent of cognitive acceleration of the particle i, rc1 is number of fuzzy rules activated to c1, c1i is output of the fuzzy rule i for c1, and μic1 is membership function value of fuzzy rule i for c1.(5)c2=∑i=1rc2μic2c2i∑i=1rc2μic2wherec2 is percent of cognitive acceleration of the particle i, rc2 is number of fuzzy rules activated to c2, c2i is output of the fuzzy rule i for c2, and μic2 is membership function value of fuzzy rule i for c2.Table 1
Fuzzy rules forchw, c1, and c2.
Rule number Input Output N U w c h w c 1 c 2 1 1 1 3 1 1  2 1 2 1 3 3  3 1 3 1 3 3  4 2 1 3 1 1  5 2 2 2 1 3  6 2 3 1 3 3  7 3 1 3 1 1  8 3 2 1 3 3  9 3 3 1 3 3For obtaining the values of the variable, the Mamdani FIS model is utilized. The method of the centroid of area is performed to obtain the defuzzification:(6)O=∫zMozzdz∫zMozdz


## 3. Ant Colony Optimization

The first algorithm to fall into the framework of the ACO metaheuristics was the Ant System (AS) [2]. In AS, k (artificial) ants build, at the same time, a graph for the solution of the optimization problem. At first, the nodes for the ants are randomly chosen. At each building step, to obtain the node in the next iteration of the ant k, a probabilistic action selection rule, called random proportional rule, is applied [37]. Determining the probability of the ant k to select the path from node i to j is as follows:(7)pijk=τijαηijβ∑l∈Nikτijαηijβηij defines the heuristic value that is independent of the experience of the ant.α,β are two parameters that define the influence of the pheromone trail and the heuristic information.Nik represents the probable neighborhood of the ant k in the node i, namely, the grouping of nodes that the ant k has not visited yet.τij defines the pheromone evaporation for the route.The update of the pheromone trails is performed after all the ants build their routes. To reach the update, first the pheromone values on the arcs are reduced by a constant factor and later, on the arcs which the ants passed, pheromone is added. This action is called pheromone evaporation and is performed as follows:(8)τij⟵1-ρτijwhere0<ρ≤1 is the pheromone evaporation rate. The parameter ρ is utilized to elude the accumulation without limits of the pheromone trails and it allows the algorithm to ‘‘forget’’ wrong decisions previously taken. After applying the evaporation, the ants add pheromones on the arcs of their route as follows:(9)τij⟵τij+∑k=1mΔτijkwhereΔτijk is the quantity of pheromones that the ant k provides on the arcs visited. It is determined as follows:(10)Δτijk=1ck,arc⁡i,j∈Tk0otherwisewhereck represents the longitude of the graph and Tk is calculated as the sum of the longitudes of the arcs of the route for the kth ant.Many research works dealing with the updating rules forΔτijk have been performed, like the Ant System (AS) [2], Elitist Ant System (EAS) [38], Rank-Based Ant System (ASrank) [39], Max-Min ant System (MMAS) [40], and Ant Colony System (ACS) [41].In this paper, we used an Ant Colony System (ACS) [41] for three important reasons. At first instance, the ACS uses an action choice rule that is more aggressive than the AS in the exploitation of the search experience concentrated by the strongest ants. Second, the ACS applies the pheromone deposit and the pheromone evaporation only in the arcs of the more promising route. Third, when the ant moves from node i to node j using the arc (i,j), with the objective of incrementing the exploration, it eliminates a small amount of pheromone from the arc [42, 43].ACO has a process in which it does not use heuristic values and the part of the consequent can be merely selected as follows:(11)pijk=τijα∑l∈NikτijαIn ACS, the antk moves from node i to node j according to a pseudo-random-proportional rule as follows:(12)Δτijk=argmaxj∈Nikτijα,ifq≤q0Jotherwisewhereq is random value uniformly distributed in [0,1], q0 is parameter in the interval [0,1], and J is random value calculated by (11) (with α=1).In the global pheromone trial update for ACS, in each iteration, only the global best ant has authorization to add the pheromone. Accordingly, the update in ACS is performed as follows:(13)τij⟵1-ρτij+ρΔτijbswhereΔτijbs=1/Cbs; in ACS, the pheromone trail update is applied to the arcs of τbs, not to all the arcs as in AS.We have defined a fuzzy inference system for pheromone evaporationρ which is made up of the following elements:Two inputs: the value ofΔτijbs and the pheromone trail τijOne output: the change in pheromone evaporationρThree membership functions for each input and output: LOW, MEDIUM, and HIGH, respectively, represented as membership functions of left triangle, middle triangle, and right triangle. Figure4 illustrates the fuzzy system to obtain the change in pheromone evaporation ρNine fuzzy rules are considered from which the changes inρ are calculated. The rules are obtained by experimental knowledge as shown in Table 2The ranges ofΔτbs and τ are normalized into [0,1]Table 2
Fuzz rulesρ.
Rule number Input Output Δ τ b s τ ρ 1 1 1 3  2 1 2 2  3 1 3 1  4 2 1 3  5 2 2 2  6 2 3 1  7 3 1 3  8 3 2 2  9 3 3 1Figure 4
Fuzzy system to adjust the pheromone evaporationρ.In ACS, besides the global pheromone trail update rule, a local pheromone update rule is applied after the ants cross an arc (i,j) in the construction of the graph. This rule is given by the following equation:(14)τij⟵1-ξτij+ξτ0whereξ,0<ξ<1. The value of τ0 is configured to take the initial value of the pheromone trails.We have defined a fuzzy inference system for pheromone evaporationξ which consists of the following components:Two inputs: the maximum probability of choosing the next nodepijk and the pheromone trail τijOne output: the change in pheromone evaporationξThree membership functions for each input and output: LOW, MEDIUM, and HIGH, respectively, represented as membership functions of left triangle, middle triangle, and right triangle. Figure5 illustrates the fuzzy inference system to obtain the change in pheromone evaporation ξNine fuzzy rules are considered from which the changes inξ are calculated. The rules are obtained by experimental knowledge as shown in Table 3The ranges ofp and τ are normalized into [0,1]Table 3
Fuzz rulesξ.
Rule number Input Output p τ ξ 1 1 1 3  2 1 2 2  3 1 3 3  4 2 1 2  5 2 2 2  6 2 3 2  7 3 1 1  8 3 2 2  9 3 3 3Figure 5
Fuzzy system to adjust the pheromone evaporationξ.


### 3.1. Water Level Control in a Tank

The water tank model and the control of this water tank using a fuzzy control system is the system used for the experiments of the proposed approach [22]. For this case, the control of the water that flows into the tank is made by using one valve. The outflow rate depends on the diameter of the output pipe, which is constant, and the pressure in the tank, which varies with the water level. Therefore, the system has nonlinear characteristics. The main objective of the fuzzy logic controller (FLC) for the water tank is to maintain the water in between the lower level L and upper level U according to the reference R, as shown in Figure 6. The FLC performs the control of the level and velocity to the water, giving as output of the FLC the quickness of flow out of the pipe.Figure 6
Water tank representation.The controller needs to be efficient to manage flow in the pipe and maintain the current level of water in the tank. The water level error is the input for the controller (the difference between the desired water level and the current water level) and the rate of opening or closing for the valve is the output.As Figure7 illustrates, the fuzzy controller has two inputs: the rate of change of the water level and the difference between the actual and the required water levels. The controller uses these inputs to manipulate the inflow rate.Figure 7
Original representation of the fuzzy system for water tank.For the fuzzy system of the water tank, 11 membership functions were used: 3 per each input and 5 at the output and all this is illustrated in Figure7. The linguistic variablelevel is defined to have three fuzzy sets, HIGH, OK, and LOW, with the associated membership functions asleftGaussian,Gaussian, and rightGaussian,respectively; the linguistic variablerate is defined to have three fuzzy sets, NEGATIVE, NONE, and POSITIVE, with associated membership functions asleftGaussian,Gaussian, and rigthGaussian,respectively; the linguistic variablevalve is defined to have five fuzzy sets, CLOSE_FAST, CLOSE_SLOW, NO_CHANGE, OPEN_SLOW, and OPEN_FAST, with associated membership function asleftTriangle,Triangle, and rigthTriangle,respectively. The following five fuzzy rules are used to calculate the change in the valve:(1)
If (level is OKAY) then (valve in NO_CHANGE)(2)
If (level is LOW) then (valve in OPEN_FAST)(3)
If (level is HIGH) then (valve in CLOSE_FAST)(4)
If (level is OKAY) and (rate is POSITIVE) then (valve in CLOSE_SLOW)(5)
If (level is OKAY) and (rate is NEGATIVE) then (valve in OPEN_SLOW)


### 3.2. Temperature Control in a Shower

We also used as basis for our experiments the problem of temperature control and the fuzzy system presented in [22]. As Figure 8 illustrates, the fuzzy controller consists of two inputs: the water temperature and the flow velocity. The controller utilizes the outputs obtained with the two inputs to control the cold and hot valves.Figure 8
Original representation of the fuzzy system for temperature control.For the fuzzy system of the temperature control, 16 membership functions were used: 3 per each input and 5 at the output and all this is illustrated in Figure8. The fuzzy variabletemp is defined to have three fuzzy sets, COLD, GOOD, and HOT, with associated membership functions asleftTriangle,Triangle, and rigthTriangle,respectively; the fuzzy variableflow is defined to have three fuzzy sets, SOFT, GOOD, and HARD, with associated membership function asleftTriangle,Triangle, and rigthTriangle,respectively; the fuzzy variablescoldandhot are defined to have five fuzzy sets, CLOSEFAST, CLOSESLOW, STEADY, OPENSLOW, and OPENFAST, with associated membership functions asleftTriangle,Triangle, and rigthTriangle,respectively. The following nine fuzzy rules were used to calculate the change of the flow and temperature in the outputs:(1)
If (temp is COLD) and (flow is SOFT) then (cold is OPENSLOW) and (hot is OPENFAST)(2)
If (temp is COLD) and (flow is GOOD) then (cold is CLOSESLOW) and (hot is OPENSLOW)(3)
If (temp is COLD) and (flow is HARD) then (cold is CLOSEFAST) and (hot is CLOSESLOW)(4)
If (temp is GOOD) and (flow is SOFT) then (cold is OPENSLOW) and (hot is OPENSLOW)(5)
If (temp is GOOD) and (flow is GOOD) then (cold is STEADY) and (hot is STEADY)(6)
If (temp is GOOD) and (flow is HARD) then (cold is CLOSESLOW) and (hot is CLOSESLOW)(7)
If (temp is HOT) and (flow is SOFT) then (cold is OPENFAST) and (hot is OPENSLOW)(8)
If (temp is HOT) and (flow is GOOD) then (cold is OPENSLOW) and (hot is CLOSESLOW)(9)
If (temp is HOT) and (flow is HARD) then (cold is CLOSESLOW) and (hot is CLOSEFAST)


#### 3.2.1. Implementation of the Proposed Methodology

In this section, the PSO and ACO algorithms are implemented for the optimization of two FLC systems [44, 45]. The optimization approach has been designed in the following sequence: first, the optimization defines the type of membership function: can be Gaussian, triangular, trapezoidal, or generalized bell; later, the optimization determines the parameters for the chosen membership functions; it is for the interesting values depending on the type of membership function, like the coordinates of the points of edge, the standard deviation, and so forth.The objective function is built to represent the fitness of a solution and is considered as an interface between optimization problem and the algorithm. In order to determine the fitness of the fuzzy model, the mean square error (MSE) is used (defined in (15)). The goal error for MSE is zero.(15)MSE=1N∑k=1nyk-y~k2whereyk is desired output, y~k is calculated output of the proposed methodology, andN is number of pieces of data by the validation of model.


### 3.3. Proposed Methodology for PSO

In this case, we represented the problem as is shown in Figure9, where one particle can be divided into sections to represent the type and parameters of the membership function.Figure 9
Example of the graphical representation of the PSO particles for the membership functions.PSO is used to optimize fuzzy controllers for two cases. In one, PSO is used to optimize the FLC from the water control in a tank and in the other PSO is used to optimize the temperature control in a shower. They both used a set of 200 particles and 300 iterations and they perform 30 experiments. We use 200 particles and 300 iterations because after making several tests the best results were obtained with these values. In Section3.6.3, we show a statistical test with the 30 experiments against ACO to validate in the best way the experimental results. The flowchart and pseudocode of the PSO algorithm are displayed in Figure 10 and Algorithm 1 of PSO, respectively, and the process is described as follows:(1)
In the search space of the problem, we use random values for the positions and velocities of the particles; this is to create and initialize the population.(2)
The fitness (in the fuzzy controller) is evaluated for all particles using the established objective function, MSE.(3)
A comparison between the current fitness against the previous fitness of each particle is applied. If the current fitness is better than the previous fitness, then the current value is established for thepbest and the current position like thepbest position.(4)
A comparison among the current fitness of each particle against the best global fitness (gbest) of the previous population is applied. If the current fitness is better thangbest, then the index and value of the current particle are established like thegbest.(5)
The evaluation is performed with the star topology:
(5.1)
In base to (3) and the proposed fuzzy inference system (Figure 3), the particle velocity is calculated.(5.2)
Actualize the particle position using (1).(6)
Steps (2) to (6) are repeated until the algorithm reaches the maximum number of iterations or the best fitness is better than the desired value.Algorithm 1:PSO algorithm.
FOR each particlei FOR each dimension d Initialize position xid randomly Initialize velocity vid randomly END FOR END FOR Iteration k=1 DO FOR each particle i Calculate fitness value IF the fitness value is better than p_bestid in history Assign current fitness value as the p_bestid END IF IF the fitness value is better than g_bestid in history Assign current fitness value as the g_bestid END IF END FOR FOR each particle i FOR each dimension d Calculate w, c1 and c2 with the fuzzy inference system Calculate velocity using the equation v id (k+1) = w vid (k) + c1Rand1 (pid - xid) + c2 Rand2 (pgd - xid) Update particle position using the equation x id (k+1) = xid (k) + vid (k+1) END FOR END FOR k = k + 1 WHILE Maximum iterations or mínimum error criteria are not attainedFigure 10
The flowchart of PSO.


#### 3.3.1. PSO for Water Level Control

Figure11 shows the graphical representation of the particles used for the optimization of the FLC for tank control. As it was mentioned before, we have implemented a set of subswarms of size of 27 particles, where we can see that each subswarm is formed with two value types, such as the type of membership function and parameter value corresponding to each variable (input-output).Figure 11
Representation of the PSO for the optimization of membership functions.


#### 3.3.2. PSO for Temperature Control

Figure12 shows the graphical representation of particles used for the optimization of the FLC from tank control. As mentioned before, we have implemented a set of subswarms of size of 40 particles, where we can see that each subswarm is formed with two value types such as type of membership function and parameter value corresponding to each variable (input-output).Figure 12
Representation of PSO for the optimization of membership functions.


### 3.4. Proposed Methodology for ACO

In the Ant Colony Optimization algorithm, the problem to optimize must be represented as a combinatorial problem; in this case, the types of membership functions should be represented as a graph; it means that the potential values require to be represented as a graph. This is an important part, for the reason that ACO operates with this type of representation. Each node must be a possible solution that an ant can take.The ant can consider each node like a potential solution to choose. At the end of the iterations, every ant will have a graph with the potential values to make the evaluation; in this graph, if we suppose that the problem to optimize is used to design a graph withqi nodes, the node value is determined as xij withi as the variable index (i=1, 2,…,n) andj as the number node forxi  (j =1, 2,qij). After the division, a network that is composed of variables and their division is constructed as depicted in Figure 13.Figure 13
Variable division and ant search path.The flowchart for ACO is displayed in Figure14, and the illustration of the ACO algorithm is shown in Algorithm 2 and the process is described as follows:(1)
The ant colony is created and initialized with random positions. We set the initial parameters for ACO making several trial and error experiments. For each ant, construct a graph (for the fuzzy controller).
(1.1)
The next node is selected in function to the probability obtained with (11).(1.2)
Reduce the local pheromone trail (evaporation) according to (14) with the proposed fuzzy system (Figure 7).(2)
Reduce the global pheromone trail (evaporation) according to (14) with the proposed fuzzy system (Figure 6).(3)
Steps (2) to (4) are repeated until the algorithm reaches the maximum iterations or the best fitness is better than the desired value.Algorithm 2:ACO algorithm.
FOR each ant i Initialize ant i END FOR Iteration k=1 DO FOR each particle i Construct the trail Select the next node Calculate the value with the fuzzy inference system Update the local pheromone trail IF the trail is complete Calculate the value with the fuzzy inference system Update the global pheromone trail ELSE GO to Select the next node END IF END FOR k = k + 1 WHILE Maximum iterations or mínimum error criteria are not attainedFigure 14
The flowchart of the ACO algorithm.


#### 3.4.1. Water Level Control in a Tank

In this paper, the design of fuzzy logic control (FLC) is performed using Ant Colony System. Figure15 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 27 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 15
Representation of the potential solutions in the pheromone matrix for the water system.


#### 3.4.2. Temperature Control in a Shower

We also used the Ant Colony System algorithm for this case. Figure16 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 40 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 16
Representation of the potential solutions in the pheromone matrix for temperature system.


### 3.5. Simulation Results

In this part, the results of the optimization of the FLCs for the water level control and temperature control systems with Particle Swarm Optimization and Ant Colony Optimization are presented. For comparison purposes, we used FLCs provided by [22] which have not been optimized.


#### 3.5.1. Simulation Results for the Water Level Control

Figure17 shows the fuzzy logic control (FLC) for the water tank without optimization, the type of membership functions, and their structure.Figure 17
Membership functions for the water tank FLC without optimization.Figure18 shows the original simulation in relation with the Mean Square Error (described in Section 3) obtaining an error of 0.0668 when the fuzzy system was not optimized, where y~ is taken as the control signal, y as the reference signal, andN as the number of data points.Figure 18
Behavior of the water level in the tank with the FLC not optimized.


#### 3.5.2. Simulation Results for Water Level Control with PSO

The best experiments, with the smaller error of 0.026952, are presented in Figure19; Figure 19 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 20.Figure 19
Behavior for the optimized water tank FLC with PSO.Figure 20
Membership functions optimized with PSO for the water tank FLC.


#### 3.5.3. Simulation Results for Water Level Control with ACO

The best experiments, with a smaller error of 0.045792, are presented in Figure21; Figure 21 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 22.Figure 21
Behavior for the optimized water tank FLC with ACO.Figure 22
Membership functions optimized for the water tank FLC with ACO.


### 3.6. Simulation Results for Temperature Control

Figure23 shows the fuzzy logic control (FLC) for the shower temperature without optimization, the type of membership functions, and their structure.Figure 23
Membership functions not optimized for the temperature control FLC.Figure24 shows the original simulation in relation with the Mean Square Error (described in Section 3) obtaining an error of 0.007013 when the fuzzy system was not optimized, where y~ is taken as the control signal, y as the reference signal, and N as the number of data points.Figure 24
Behavior of the not optimized temperature control in the FLC for the shower.


#### 3.6.1. Simulation Results for Temperature Control with PSO

The best experiment, with a smaller error of 0.0003758, is presented in Figure25; Figure 25 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 26.Figure 25
Behavior for the optimized temperature control FLC with PSO.Figure 26
Membership functions optimized for the temperature control FLC with PSO.


#### 3.6.2. Simulation Results for Temperature Control with ACO

The best experiment, with a smaller error of 0.00076356, is presented in Figure27; Figure 27 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 28.Figure 27
Behavior for the optimized temperature control FLC with ACO.Figure 28
Membership functions optimized for the temperature control FLC with ACO.


#### 3.6.3. Comparative Study of Optimized ACO versus Optimized PSO: The Case of Temperature Control in a Shower

In this section, we included a statistical test to validate in the best way our approach between the ACO and PSO optimized methods. We made 100 experiments for the case of the temperature control with both methods. The following table shows the results with a Student’st-test. We use 30 samples, selected randomly from the 100 experiments to make this test. We can see in Table 4 for this case that the ACO method was better than PSO because the T-value was -7.28; however, in Table 5, we can see that the 30 experiments and the values are very similar with both methods; however, some values of PSO are larger than 1, and for the ACO algorithm, the values are smaller than 1. Therefore, the differences for these two methods using optimized controllers were significant.Table 4
Student’st-test.
N Mean Standard deviation SE mean 30 0.190 0.163 0.030  30 0.807 0.434 0.079 Difference =μ (ACO) - μ (PSO). Estimate for difference: -0.6164. 95% lower bound for difference: -0.7593. T-value = -7.28 P value = 1.20587E-08.Table 5
Experimental results with ACO and PSO.
Experiment PSO ACO 1 1.1456 0.0067823  2 1.2076 0.012086  3 0.90314 0.0281  4 0.42635 0.033326  5 0.20136 0.051824  6 0.75873 0.066958  7 0.093008 0.077077  8 0.68108 0.080195  9 1.1802 0.083176  10 1.1365 0.10675  11 1.1563 0.10827  12 0.31743 0.12463  13 1.2254 0.13095  14 1.0505 0.13263  15 1.2925 0.13276  16 0.40378 0.14014  17 1.2477 0.14722  18 1.1119 0.16984  19 0.63035 0.17191  20 1.0559 0.17539  21 0.41091 0.22107  22 0.069772 0.22883  23 1.2036 0.23622  24 1.1208 0.3004  25 0.078089 0.30398  26 1.071 0.30562  27 0.30528 0.4007  28 1.2911 0.49584  29 1.1934 0.57976  30 0.23343 0.65851  Error average 0.806756967 0.19036481


## 3.1. Water Level Control in a Tank

The water tank model and the control of this water tank using a fuzzy control system is the system used for the experiments of the proposed approach [22]. For this case, the control of the water that flows into the tank is made by using one valve. The outflow rate depends on the diameter of the output pipe, which is constant, and the pressure in the tank, which varies with the water level. Therefore, the system has nonlinear characteristics. The main objective of the fuzzy logic controller (FLC) for the water tank is to maintain the water in between the lower level L and upper level U according to the reference R, as shown in Figure 6. The FLC performs the control of the level and velocity to the water, giving as output of the FLC the quickness of flow out of the pipe.Figure 6
Water tank representation.The controller needs to be efficient to manage flow in the pipe and maintain the current level of water in the tank. The water level error is the input for the controller (the difference between the desired water level and the current water level) and the rate of opening or closing for the valve is the output.As Figure7 illustrates, the fuzzy controller has two inputs: the rate of change of the water level and the difference between the actual and the required water levels. The controller uses these inputs to manipulate the inflow rate.Figure 7
Original representation of the fuzzy system for water tank.For the fuzzy system of the water tank, 11 membership functions were used: 3 per each input and 5 at the output and all this is illustrated in Figure7. The linguistic variablelevel is defined to have three fuzzy sets, HIGH, OK, and LOW, with the associated membership functions asleftGaussian,Gaussian, and rightGaussian,respectively; the linguistic variablerate is defined to have three fuzzy sets, NEGATIVE, NONE, and POSITIVE, with associated membership functions asleftGaussian,Gaussian, and rigthGaussian,respectively; the linguistic variablevalve is defined to have five fuzzy sets, CLOSE_FAST, CLOSE_SLOW, NO_CHANGE, OPEN_SLOW, and OPEN_FAST, with associated membership function asleftTriangle,Triangle, and rigthTriangle,respectively. The following five fuzzy rules are used to calculate the change in the valve:(1)
If (level is OKAY) then (valve in NO_CHANGE)(2)
If (level is LOW) then (valve in OPEN_FAST)(3)
If (level is HIGH) then (valve in CLOSE_FAST)(4)
If (level is OKAY) and (rate is POSITIVE) then (valve in CLOSE_SLOW)(5)
If (level is OKAY) and (rate is NEGATIVE) then (valve in OPEN_SLOW)


## 3.2. Temperature Control in a Shower

We also used as basis for our experiments the problem of temperature control and the fuzzy system presented in [22]. As Figure 8 illustrates, the fuzzy controller consists of two inputs: the water temperature and the flow velocity. The controller utilizes the outputs obtained with the two inputs to control the cold and hot valves.Figure 8
Original representation of the fuzzy system for temperature control.For the fuzzy system of the temperature control, 16 membership functions were used: 3 per each input and 5 at the output and all this is illustrated in Figure8. The fuzzy variabletemp is defined to have three fuzzy sets, COLD, GOOD, and HOT, with associated membership functions asleftTriangle,Triangle, and rigthTriangle,respectively; the fuzzy variableflow is defined to have three fuzzy sets, SOFT, GOOD, and HARD, with associated membership function asleftTriangle,Triangle, and rigthTriangle,respectively; the fuzzy variablescoldandhot are defined to have five fuzzy sets, CLOSEFAST, CLOSESLOW, STEADY, OPENSLOW, and OPENFAST, with associated membership functions asleftTriangle,Triangle, and rigthTriangle,respectively. The following nine fuzzy rules were used to calculate the change of the flow and temperature in the outputs:(1)
If (temp is COLD) and (flow is SOFT) then (cold is OPENSLOW) and (hot is OPENFAST)(2)
If (temp is COLD) and (flow is GOOD) then (cold is CLOSESLOW) and (hot is OPENSLOW)(3)
If (temp is COLD) and (flow is HARD) then (cold is CLOSEFAST) and (hot is CLOSESLOW)(4)
If (temp is GOOD) and (flow is SOFT) then (cold is OPENSLOW) and (hot is OPENSLOW)(5)
If (temp is GOOD) and (flow is GOOD) then (cold is STEADY) and (hot is STEADY)(6)
If (temp is GOOD) and (flow is HARD) then (cold is CLOSESLOW) and (hot is CLOSESLOW)(7)
If (temp is HOT) and (flow is SOFT) then (cold is OPENFAST) and (hot is OPENSLOW)(8)
If (temp is HOT) and (flow is GOOD) then (cold is OPENSLOW) and (hot is CLOSESLOW)(9)
If (temp is HOT) and (flow is HARD) then (cold is CLOSESLOW) and (hot is CLOSEFAST)


### 3.2.1. Implementation of the Proposed Methodology

In this section, the PSO and ACO algorithms are implemented for the optimization of two FLC systems [44, 45]. The optimization approach has been designed in the following sequence: first, the optimization defines the type of membership function: can be Gaussian, triangular, trapezoidal, or generalized bell; later, the optimization determines the parameters for the chosen membership functions; it is for the interesting values depending on the type of membership function, like the coordinates of the points of edge, the standard deviation, and so forth.The objective function is built to represent the fitness of a solution and is considered as an interface between optimization problem and the algorithm. In order to determine the fitness of the fuzzy model, the mean square error (MSE) is used (defined in (15)). The goal error for MSE is zero.(15)MSE=1N∑k=1nyk-y~k2whereyk is desired output, y~k is calculated output of the proposed methodology, andN is number of pieces of data by the validation of model.


## 3.2.1. Implementation of the Proposed Methodology

In this section, the PSO and ACO algorithms are implemented for the optimization of two FLC systems [44, 45]. The optimization approach has been designed in the following sequence: first, the optimization defines the type of membership function: can be Gaussian, triangular, trapezoidal, or generalized bell; later, the optimization determines the parameters for the chosen membership functions; it is for the interesting values depending on the type of membership function, like the coordinates of the points of edge, the standard deviation, and so forth.The objective function is built to represent the fitness of a solution and is considered as an interface between optimization problem and the algorithm. In order to determine the fitness of the fuzzy model, the mean square error (MSE) is used (defined in (15)). The goal error for MSE is zero.(15)MSE=1N∑k=1nyk-y~k2whereyk is desired output, y~k is calculated output of the proposed methodology, andN is number of pieces of data by the validation of model.


## 3.3. Proposed Methodology for PSO

In this case, we represented the problem as is shown in Figure9, where one particle can be divided into sections to represent the type and parameters of the membership function.Figure 9
Example of the graphical representation of the PSO particles for the membership functions.PSO is used to optimize fuzzy controllers for two cases. In one, PSO is used to optimize the FLC from the water control in a tank and in the other PSO is used to optimize the temperature control in a shower. They both used a set of 200 particles and 300 iterations and they perform 30 experiments. We use 200 particles and 300 iterations because after making several tests the best results were obtained with these values. In Section3.6.3, we show a statistical test with the 30 experiments against ACO to validate in the best way the experimental results. The flowchart and pseudocode of the PSO algorithm are displayed in Figure 10 and Algorithm 1 of PSO, respectively, and the process is described as follows:(1)
In the search space of the problem, we use random values for the positions and velocities of the particles; this is to create and initialize the population.(2)
The fitness (in the fuzzy controller) is evaluated for all particles using the established objective function, MSE.(3)
A comparison between the current fitness against the previous fitness of each particle is applied. If the current fitness is better than the previous fitness, then the current value is established for thepbest and the current position like thepbest position.(4)
A comparison among the current fitness of each particle against the best global fitness (gbest) of the previous population is applied. If the current fitness is better thangbest, then the index and value of the current particle are established like thegbest.(5)
The evaluation is performed with the star topology:
(5.1)
In base to (3) and the proposed fuzzy inference system (Figure 3), the particle velocity is calculated.(5.2)
Actualize the particle position using (1).(6)
Steps (2) to (6) are repeated until the algorithm reaches the maximum number of iterations or the best fitness is better than the desired value.Algorithm 1:PSO algorithm.
FOR each particlei FOR each dimension d Initialize position xid randomly Initialize velocity vid randomly END FOR END FOR Iteration k=1 DO FOR each particle i Calculate fitness value IF the fitness value is better than p_bestid in history Assign current fitness value as the p_bestid END IF IF the fitness value is better than g_bestid in history Assign current fitness value as the g_bestid END IF END FOR FOR each particle i FOR each dimension d Calculate w, c1 and c2 with the fuzzy inference system Calculate velocity using the equation v id (k+1) = w vid (k) + c1Rand1 (pid - xid) + c2 Rand2 (pgd - xid) Update particle position using the equation x id (k+1) = xid (k) + vid (k+1) END FOR END FOR k = k + 1 WHILE Maximum iterations or mínimum error criteria are not attainedFigure 10
The flowchart of PSO.


### 3.3.1. PSO for Water Level Control

Figure11 shows the graphical representation of the particles used for the optimization of the FLC for tank control. As it was mentioned before, we have implemented a set of subswarms of size of 27 particles, where we can see that each subswarm is formed with two value types, such as the type of membership function and parameter value corresponding to each variable (input-output).Figure 11
Representation of the PSO for the optimization of membership functions.


### 3.3.2. PSO for Temperature Control

Figure12 shows the graphical representation of particles used for the optimization of the FLC from tank control. As mentioned before, we have implemented a set of subswarms of size of 40 particles, where we can see that each subswarm is formed with two value types such as type of membership function and parameter value corresponding to each variable (input-output).Figure 12
Representation of PSO for the optimization of membership functions.


## 3.3.1. PSO for Water Level Control

Figure11 shows the graphical representation of the particles used for the optimization of the FLC for tank control. As it was mentioned before, we have implemented a set of subswarms of size of 27 particles, where we can see that each subswarm is formed with two value types, such as the type of membership function and parameter value corresponding to each variable (input-output).Figure 11
Representation of the PSO for the optimization of membership functions.


## 3.3.2. PSO for Temperature Control

Figure12 shows the graphical representation of particles used for the optimization of the FLC from tank control. As mentioned before, we have implemented a set of subswarms of size of 40 particles, where we can see that each subswarm is formed with two value types such as type of membership function and parameter value corresponding to each variable (input-output).Figure 12
Representation of PSO for the optimization of membership functions.


## 3.4. Proposed Methodology for ACO

In the Ant Colony Optimization algorithm, the problem to optimize must be represented as a combinatorial problem; in this case, the types of membership functions should be represented as a graph; it means that the potential values require to be represented as a graph. This is an important part, for the reason that ACO operates with this type of representation. Each node must be a possible solution that an ant can take.The ant can consider each node like a potential solution to choose. At the end of the iterations, every ant will have a graph with the potential values to make the evaluation; in this graph, if we suppose that the problem to optimize is used to design a graph withqi nodes, the node value is determined as xij withi as the variable index (i=1, 2,…,n) andj as the number node forxi  (j =1, 2,qij). After the division, a network that is composed of variables and their division is constructed as depicted in Figure 13.Figure 13
Variable division and ant search path.The flowchart for ACO is displayed in Figure14, and the illustration of the ACO algorithm is shown in Algorithm 2 and the process is described as follows:(1)
The ant colony is created and initialized with random positions. We set the initial parameters for ACO making several trial and error experiments. For each ant, construct a graph (for the fuzzy controller).
(1.1)
The next node is selected in function to the probability obtained with (11).(1.2)
Reduce the local pheromone trail (evaporation) according to (14) with the proposed fuzzy system (Figure 7).(2)
Reduce the global pheromone trail (evaporation) according to (14) with the proposed fuzzy system (Figure 6).(3)
Steps (2) to (4) are repeated until the algorithm reaches the maximum iterations or the best fitness is better than the desired value.Algorithm 2:ACO algorithm.
FOR each ant i Initialize ant i END FOR Iteration k=1 DO FOR each particle i Construct the trail Select the next node Calculate the value with the fuzzy inference system Update the local pheromone trail IF the trail is complete Calculate the value with the fuzzy inference system Update the global pheromone trail ELSE GO to Select the next node END IF END FOR k = k + 1 WHILE Maximum iterations or mínimum error criteria are not attainedFigure 14
The flowchart of the ACO algorithm.


### 3.4.1. Water Level Control in a Tank

In this paper, the design of fuzzy logic control (FLC) is performed using Ant Colony System. Figure15 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 27 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 15
Representation of the potential solutions in the pheromone matrix for the water system.


### 3.4.2. Temperature Control in a Shower

We also used the Ant Colony System algorithm for this case. Figure16 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 40 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 16
Representation of the potential solutions in the pheromone matrix for temperature system.


## 3.4.1. Water Level Control in a Tank

In this paper, the design of fuzzy logic control (FLC) is performed using Ant Colony System. Figure15 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 27 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 15
Representation of the potential solutions in the pheromone matrix for the water system.


## 3.4.2. Temperature Control in a Shower

We also used the Ant Colony System algorithm for this case. Figure16 shows the graphical representation of the potential solutions in the pheromone matrix used for the optimization of FLC from tank control, where the first node of the graph represents the nest and the food source is the last node. This implementation is structured with a total of 40 nodes, where each node is formed for a type of membership function or parameter value (input-output).Figure 16
Representation of the potential solutions in the pheromone matrix for temperature system.


## 3.5. Simulation Results

In this part, the results of the optimization of the FLCs for the water level control and temperature control systems with Particle Swarm Optimization and Ant Colony Optimization are presented. For comparison purposes, we used FLCs provided by [22] which have not been optimized.


### 3.5.1. Simulation Results for the Water Level Control

Figure17 shows the fuzzy logic control (FLC) for the water tank without optimization, the type of membership functions, and their structure.Figure 17
Membership functions for the water tank FLC without optimization.Figure18 shows the original simulation in relation with the Mean Square Error (described in Section 3) obtaining an error of 0.0668 when the fuzzy system was not optimized, where y~ is taken as the control signal, y as the reference signal, andN as the number of data points.Figure 18
Behavior of the water level in the tank with the FLC not optimized.


### 3.5.2. Simulation Results for Water Level Control with PSO

The best experiments, with the smaller error of 0.026952, are presented in Figure19; Figure 19 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 20.Figure 19
Behavior for the optimized water tank FLC with PSO.Figure 20
Membership functions optimized with PSO for the water tank FLC.


### 3.5.3. Simulation Results for Water Level Control with ACO

The best experiments, with a smaller error of 0.045792, are presented in Figure21; Figure 21 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 22.Figure 21
Behavior for the optimized water tank FLC with ACO.Figure 22
Membership functions optimized for the water tank FLC with ACO.


## 3.5.1. Simulation Results for the Water Level Control

Figure17 shows the fuzzy logic control (FLC) for the water tank without optimization, the type of membership functions, and their structure.Figure 17
Membership functions for the water tank FLC without optimization.Figure18 shows the original simulation in relation with the Mean Square Error (described in Section 3) obtaining an error of 0.0668 when the fuzzy system was not optimized, where y~ is taken as the control signal, y as the reference signal, andN as the number of data points.Figure 18
Behavior of the water level in the tank with the FLC not optimized.


## 3.5.2. Simulation Results for Water Level Control with PSO

The best experiments, with the smaller error of 0.026952, are presented in Figure19; Figure 19 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 20.Figure 19
Behavior for the optimized water tank FLC with PSO.Figure 20
Membership functions optimized with PSO for the water tank FLC.


## 3.5.3. Simulation Results for Water Level Control with ACO

The best experiments, with a smaller error of 0.045792, are presented in Figure21; Figure 21 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the water tank FLC are shown in Figure 22.Figure 21
Behavior for the optimized water tank FLC with ACO.Figure 22
Membership functions optimized for the water tank FLC with ACO.


## 3.6. Simulation Results for Temperature Control

Figure23 shows the fuzzy logic control (FLC) for the shower temperature without optimization, the type of membership functions, and their structure.Figure 23
Membership functions not optimized for the temperature control FLC.Figure24 shows the original simulation in relation with the Mean Square Error (described in Section 3) obtaining an error of 0.007013 when the fuzzy system was not optimized, where y~ is taken as the control signal, y as the reference signal, and N as the number of data points.Figure 24
Behavior of the not optimized temperature control in the FLC for the shower.


### 3.6.1. Simulation Results for Temperature Control with PSO

The best experiment, with a smaller error of 0.0003758, is presented in Figure25; Figure 25 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 26.Figure 25
Behavior for the optimized temperature control FLC with PSO.Figure 26
Membership functions optimized for the temperature control FLC with PSO.


### 3.6.2. Simulation Results for Temperature Control with ACO

The best experiment, with a smaller error of 0.00076356, is presented in Figure27; Figure 27 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 28.Figure 27
Behavior for the optimized temperature control FLC with ACO.Figure 28
Membership functions optimized for the temperature control FLC with ACO.


### 3.6.3. Comparative Study of Optimized ACO versus Optimized PSO: The Case of Temperature Control in a Shower

In this section, we included a statistical test to validate in the best way our approach between the ACO and PSO optimized methods. We made 100 experiments for the case of the temperature control with both methods. The following table shows the results with a Student’st-test. We use 30 samples, selected randomly from the 100 experiments to make this test. We can see in Table 4 for this case that the ACO method was better than PSO because the T-value was -7.28; however, in Table 5, we can see that the 30 experiments and the values are very similar with both methods; however, some values of PSO are larger than 1, and for the ACO algorithm, the values are smaller than 1. Therefore, the differences for these two methods using optimized controllers were significant.Table 4
Student’st-test.
N Mean Standard deviation SE mean 30 0.190 0.163 0.030  30 0.807 0.434 0.079 Difference =μ (ACO) - μ (PSO). Estimate for difference: -0.6164. 95% lower bound for difference: -0.7593. T-value = -7.28 P value = 1.20587E-08.Table 5
Experimental results with ACO and PSO.
Experiment PSO ACO 1 1.1456 0.0067823  2 1.2076 0.012086  3 0.90314 0.0281  4 0.42635 0.033326  5 0.20136 0.051824  6 0.75873 0.066958  7 0.093008 0.077077  8 0.68108 0.080195  9 1.1802 0.083176  10 1.1365 0.10675  11 1.1563 0.10827  12 0.31743 0.12463  13 1.2254 0.13095  14 1.0505 0.13263  15 1.2925 0.13276  16 0.40378 0.14014  17 1.2477 0.14722  18 1.1119 0.16984  19 0.63035 0.17191  20 1.0559 0.17539  21 0.41091 0.22107  22 0.069772 0.22883  23 1.2036 0.23622  24 1.1208 0.3004  25 0.078089 0.30398  26 1.071 0.30562  27 0.30528 0.4007  28 1.2911 0.49584  29 1.1934 0.57976  30 0.23343 0.65851  Error average 0.806756967 0.19036481


## 3.6.1. Simulation Results for Temperature Control with PSO

The best experiment, with a smaller error of 0.0003758, is presented in Figure25; Figure 25 shows the behavior of the reference signal against the control signal in simulation for the optimization with PSO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 26.Figure 25
Behavior for the optimized temperature control FLC with PSO.Figure 26
Membership functions optimized for the temperature control FLC with PSO.


## 3.6.2. Simulation Results for Temperature Control with ACO

The best experiment, with a smaller error of 0.00076356, is presented in Figure27; Figure 27 shows the behavior of the reference signal against the control signal in simulation for the optimization with ACO; the resulting new structures of membership functions after parameter optimization for the shower temperature FLC are shown in Figure 28.Figure 27
Behavior for the optimized temperature control FLC with ACO.Figure 28
Membership functions optimized for the temperature control FLC with ACO.


## 3.6.3. Comparative Study of Optimized ACO versus Optimized PSO: The Case of Temperature Control in a Shower

In this section, we included a statistical test to validate in the best way our approach between the ACO and PSO optimized methods. We made 100 experiments for the case of the temperature control with both methods. The following table shows the results with a Student’st-test. We use 30 samples, selected randomly from the 100 experiments to make this test. We can see in Table 4 for this case that the ACO method was better than PSO because the T-value was -7.28; however, in Table 5, we can see that the 30 experiments and the values are very similar with both methods; however, some values of PSO are larger than 1, and for the ACO algorithm, the values are smaller than 1. Therefore, the differences for these two methods using optimized controllers were significant.Table 4
Student’st-test.
N Mean Standard deviation SE mean 30 0.190 0.163 0.030  30 0.807 0.434 0.079 Difference =μ (ACO) - μ (PSO). Estimate for difference: -0.6164. 95% lower bound for difference: -0.7593. T-value = -7.28 P value = 1.20587E-08.Table 5
Experimental results with ACO and PSO.
Experiment PSO ACO 1 1.1456 0.0067823  2 1.2076 0.012086  3 0.90314 0.0281  4 0.42635 0.033326  5 0.20136 0.051824  6 0.75873 0.066958  7 0.093008 0.077077  8 0.68108 0.080195  9 1.1802 0.083176  10 1.1365 0.10675  11 1.1563 0.10827  12 0.31743 0.12463  13 1.2254 0.13095  14 1.0505 0.13263  15 1.2925 0.13276  16 0.40378 0.14014  17 1.2477 0.14722  18 1.1119 0.16984  19 0.63035 0.17191  20 1.0559 0.17539  21 0.41091 0.22107  22 0.069772 0.22883  23 1.2036 0.23622  24 1.1208 0.3004  25 0.078089 0.30398  26 1.071 0.30562  27 0.30528 0.4007  28 1.2911 0.49584  29 1.1934 0.57976  30 0.23343 0.65851  Error average 0.806756967 0.19036481


## 4. Conclusions

In this work, we have applied the Ant Colony Optimization (ACO) and Particle Swarm Optimization (PSO) metaheuristics for the design of fuzzy systems. For this purpose, we have adopted one ACO variant, namely, the Ant Colony System (ACS). Both algorithms, ACS and PSO, have changing parameters with fuzzy dynamic adaptation during execution. For the ACS algorithm, the global and local evaporation of the pheromone is dynamically adapted using a fuzzy system. For the PSO algorithm, the inertia weight and the parametersc1 andc2 are adapted dynamically with a fuzzy system. The type of membership functions and the parameters of membership function of the fuzzy logic controllers for temperature control and water level control were optimized with ACO and PSO algorithms, respectively. The results of both optimization algorithms are compared. Those results show good solutions in comparison with the original problem that is not optimized.The use of metaheuristic algorithms is amply utilized in optimization of problems; for the benchmark problems of temperature control and water level control, the implemented fuzzy systems are used to adjust parameters of the ACO and PSO and improve the results of the algorithms.As a general conclusion with the statistical test applied with both analyzed methods, we can demonstrate that, with the dynamic parameter adaptation, ACO and PSO can be good alternatives to solve some cases of control; the experimental results are very similar to the two optimized methods; however, for the case of temperature control in a shower, ACO was slightly superior to PSO. Also, there are other experiments to validate this approach with other cases, for example, the water tank control, and in some cases PSO is better than ACO.For future work, we plan to hybridize these algorithms to compare results and test with fuzzy inference systems for different membership functions or implement type 2 fuzzy inference systems to enhance the results of the work.



---

*Source: 1274969-2018-07-02.xml*