# A Bilevel Optimization Approach for Tuning a Neuro-Fuzzy Controller
## 5 Experiments and Results  
In order to validate the proposed bilevel optimization method, the temperature model of the industrial plant for the biodiesel process described in [14] was used as a case study. As mentioned before, the results from the proposed method were compared with the tuning obtained in [13], where an NFC was applied to control a system with a disturbance. The plant shown in Figure 6 represents the system to be controlled. In the scheme, \(TC\) corresponds to the temperature of the thermal agent, \(Tp\) corresponds to the temperature of the output product, and \(T1\) corresponds to the temperature of the product. The system was designed to maintain the temperature of the product (\(T1\)) equal to \(T0\), which is the reference temperature. This is achieved through a control system that uses a transducer to receive information from the tank. Mathematical modeling of the reversible chemical reactions that occur during the transesterification process is required before designing a biodiesel reactor, in order to establish a relationship between the control system and the process variables. In [35], the authors consider the transesterification reaction in three stages, with each intermediate reaction as a second-order reaction. The reaction of this process is described by (30), where \(k_{1}-k_{8}\) denote the reaction speed constants. Figure 5: Flowchart of the second level of the tuning process. \[\text{Tg}+3\,\text{CH}_{3}\text{OH} \tag{30}\]  
This model considers the stirring intensity and the temperature effect on the conversion rate. It also quantifies the activation energy for the transesterification simulation at different temperatures and stirring rates [13]. Also, [PERSON] model [36] takes into consideration the modeling of the reaction, the saponification, and the water content effect. It is the most complex model found in the literature and is described by (31), where \(\text{Uv}\) is the oil used in the reaction. \[\text{Uv}+3\,\text{ROH}=\text{Gl}+3\,\text{Bd} \tag{31}\]  
A serial array of three transfer functions is used to calculate the transfer function for the tank temperature. Equation (32) corresponds to the execution element where \(KE=2\) and \(TE=360\), (33) applies to the process with \(Tp=1143\), \(Kp=1\), and (34) denotes a gain. These parameters physically represent system properties and differentiate it from other systems that also produce biodiesel but with different production volumes. An explanation of how to find the numerical parameters of the system is included in [14]. \[G_{E}=\frac{K_{E}}{T_{E}s+1}; \tag{32}\]  
\[G_{P}=\frac{K_{p}}{T_{p}s+1}; \tag{33}\]  
\[G_{T}=2. \tag{34}\]  
According to the data, (35) is the resultant transfer function of the system:  
\[G_{f}=\frac{4}{(360s+1)(1143s+1)}. \tag{35}\]  
The system can be treated as a batch process due to its characteristics, as mentioned in [14], and it is also possible to find a detailed explanation of the mathematical model developed in that work. The tuning optimization algorithm and the equations for the NFC were programmed in MATLAB R2020a, which was also used for simulating the temperature control. The computing platform employed had the following specifications: Intel i7 processor @3.70 GHz, 16 GB RAM, and a Windows 11 operating system. The simulation shows 12,000 seconds of the controller's behavior using the parameter sets generated by the proposed method. The task involves tracking a set point (60 \"C) that suffers a disturbance at a time \(t=5000\) s. In both levels of optimization, the parameters for DE were set as follows, using the same  
Figure 6: Pilot plant scheme [14]. settings as in [13]: scaling factor \(F=0.6\), crossover rate \(Cr=0.5\), and population size \(NP=20\). In the first level of optimization, a stagnation criterion was employed, considering 400 consecutive generations without fitness improvement. Table 1 shows the range of each variable.