# Hysteresis Compensation and Trajectory Tracking Control Model for Pneumatic Artificial Muscles
## 2 Hysteresis Model and Inverse Model of PAM
### Parameter Optimization  
The parameter optimization of the FN-QUPI model includes two parts, namely the weight coefficients \(d_{ij}\) of the QUPI hysteresis operator and the neural network parameters \(w_{\overline{ij}}\) and the three coefficients of the activation function (quadratic function) in the FNN-NARMAX. The parameters to be optimized in the QUPI inverse model are \(q^{-1}\) and g in the formula.  
The parameter identification of the PAM system involves multiple nonlinear characteristics, and traditional optimization methods may easily fall into local optima. However, particle swarm optimization (PSO), by simulating the cooperation and competition among individuals in a swarm, can effectively avoid this issue. Additionally, PSO has a fast convergence speed and relatively low computational complexity, making it highly suitable for parameter optimization in PAM system models, ensuring more accurate and stable model parameters [20]. PSO relies on information exchange among particles in the swarm, referred to as a \"swarm\". The swarm is composed of individuals known as particles, and it is initialized with a population of random solutions. Each particle is also assigned a random velocity function. Particles adjust their trajectories toward their current best solution, \(\mathrm{P_{best}}\). Moreover, each particle modifies its trajectory based on the current best position, \(\mathrm{G_{best}}\), achieved by other particles in its neighborhood. The fitness function measures the performance of each particle to determine whether the best-fitting solution has been achieved. Throughout this process, the fitness of the best individual improves over time and eventually stabilizes when the process concludes, with the final stabilized parameters aligning with the globally optimal parameters.  
In this paper, the particle swarm optimization (PSO) is selected for system model recognition. In terms of the FN-QUPI model and its inverse model, the parameters to be discerned have been greatly reduced compared with other hysteresis models. Therefore, the least-squares method shown in Formula (12) can be directly used as the fitness function. The specific objective is to achieve a satisfactory fitness value for the model through iterative optimization or to terminate the calculation when the maximum number of iterations is reached. By combining particle swarm optimization, the optimal parameter values for the FN-QUPI model are ultimately obtained. The process of parameter identification for the FN-QUPI model using particle swarm optimization is shown in Algorithm 1.  
\[S=\frac{1}{H}\sum_{i=1}^{H}\left(F_{i}-\hat{F}_{i}\right)^{2} \tag{12}\]  
In the equation, \(F_{i}\) represents the actual value of the PAM's driving mechanism, \(\hat{F}_{i}\) represents the model output value, and \(H\) represents the number of samples in identification.  
```
Input: Training dataset of pressure and displacement. Parameter settings: maximum iterations \(\mathit{ite}=100\); number of QUPI operators \(N_{r}=10\); number of particles in the swarm \(N=50\); polynomial function order \(N_{p}=2\). Initialization of parameters: weights in the QUPI model \(w\)-(\(-0.02\),\(0.02\)); Parameters of the activation function in the hidden layer: \(a\)-(\(-1\),\(0\)); \(b\)-(\(0\),\(0\)); \(c\)-(\(0\),\(0\)). The weights of the two-layer neural network \(w_{i\bar{j}}\)-(\(0\),\(0\)). If i \(\leq\) ite (where i represents the current iteration count) Calculate the output of the FN-QUPI model O(k). Calculate the particle swarm fitness function S. Update the parameters. End Output: Final computed results of the model.
```  
**Algorithm 1** The parameter identification process using particle swarm optimization