## 2 Materials and Methods
### Fuzzy PID Controller Design Based on Adaptive Dung Beetle Algorithm Optimization
#### 2.5.2 Fuzzy PID Controller  
The PID control achieves precise regulation by generating a control signal through weighted synthesis of three components: proportional, integral, and derivative terms derived from deviation. The explicit expression for PID controller output is as follows:  
\[u(t)=K_{p}e(t)+K_{i}{\int_{0}^{t}e(t)dt}+K_{d}\frac{de(t)}{dt}, \tag{7}\]  
where \(u(t)\) is the output of the PID controller; \(e(t)\) is the deviation; and \(K_{p}\), \(K_{i}\), and \(K_{d}\) are the proportional, integral, and differential parameters of PID, respectively.  
The fuzzy PID controller processes deviation signals through fuzzy logic, dynamically adjusting PID parameters (proportional coefficient \(K_{p}\), integral coefficient \(K_{i}\), and derivative coefficient \(K_{d}\)) based on temperature deviation and its rate of change. This adaptive mechanism enables the control system to effectively accommodate varying operational conditions, achieving precise regulation of the controlled variable (nutrient solution temperature). This study employs a dual-input triple-output fuzzy control architecture, comprising two main components: the fuzzy controller and the PID controller, as illustrated in Figure 10.  
The nutrient solution temperature deviation \(e\) and its rate of change \(ec\) are selected as input variables. These inputs undergo quantization and fuzzification processes, yielding corresponding fuzzy sets \(E\) and \(EC\). Through fuzzy rule-based inference, the fuzzy values of control parameters are determined. Subsequently, the high-precision centroid method is employed for defuzzification of the PID parameters obtained from fuzzy reasoning. Finally, the self-tuning parameters of the fuzzy PID controller (\(\Delta K_{p}\), \(\Delta K_{i}\), \(\Delta K_{d}\)) are adjusted based on scaling factors, enabling real-time PID parameter correction. The parameter adjustment formulas for the control algorithm are as follows:  
\[\left\{\begin{aligned} & K_{p}=K_{p0}+\Delta K_{p}\\ & K_{i}=K_{i0}+\Delta K_{i}\\ & K_{d}=K_{d0}+\Delta K_{d}\\ \end{aligned}\right., \tag{8}\]  
where \(K_{p0}\), \(K_{i0}\), and \(K_{d0}\) are the initial values of the PID parameters.  
The parameter settings of the fuzzy controller are detailed in Table 2. In practical implementation, a combination of triangular and Gaussian membership functions is selected for the temperature deviation \(e\) and its rate of change \(ec\), while triangular membership functions are adopted for the system self-tuning output variables (\(\Delta K_{p}\), \(\Delta K_{i}\), \(\Delta K_{d}\)). The structure of these membership functions is illustrated in Figure 11.  
Prior to fuzzy inference, the actual domain values are transformed into the fuzzy domain of subsets through multiplication with quantization factors. Following defuzzification, the output parameters are adjusted using scaling factors to obtain actual control values. Based on conventional empirical formulas [36], the initial fuzzy PID parameters  
Figure 10: Schematic diagram of fuzzy PID temperature controller.  
before algorithm optimization are set as quantization factors \(K_{e}\) = 2, \(K_{cc}\) = 0.5, and scaling factors \(K_{up}\) = 0.05, \(K_{ui}\) =0.01, and \(K_{ud}\) = 0.005.  
The fuzzy rule base comprises a series of conditional statements following the \"if \(E\) and \(EC\) then \(U^{\prime}\)\" structure. The rational design of fuzzy rules is crucial for optimizing controller performance. During the initial system startup phase, when system deviation is substantial, control outputs should prioritize rapid deviation elimination and enhanced response speed. As the system approaches the target nutrient solution temperature, control outputs should emphasize system stability and minimize overshoot. Drawing upon technical knowledge and practical experience from PID tuning processes, a total of 49 fuzzy rules were designed for the controller, as detailed in Table 3.