# SA-SVM-Based Locomotion Pattern Recognition for Exoskeleton Robot
## 2 Materials and Methods
### Locomotion Pattern Recognition
#### 2.3.2 Support Vector Machine Classifier Based on Simulated Annealing Algorithm  
Simulated annealing algorithm is derived from the research results of statistical mechanics of materials. At high temperatures, particles have higher energies and are free to move and rearrange themselves. At low temperatures, the energy of the particles is low. In order for the particles to reach thermal equilibrium at each temperature, cooling (annealing) is carried out very slowly, starting at high temperatures. Assume that the energy \(E(i)\) of the material in the state is \(i\), then the material will follow the following law when entering the state \(j\) from the state \(i\) at temperature \(T\):  
1. If \(E(j)\leq E(i)\), accept that the state is transitioned;
2. If \(E(j)>E(i)\), the state transition is accepted with the following probabilities: \[e^{\frac{E(i)-E(j)}{K\lambda}}\] (13) where \(K\) is the Boltzmann constant in physics; \(T\) is material temperature. When the material reaches thermal equilibrium after full conversion at a certain temperature, the probability of the material in the state \(i\) satisfies the Boltzmann distribution. \[P_{T}(X=i)=\frac{e^{-\frac{E(i)}{K\lambda}}}{\sum_{j\in S}e^{-\frac{E(j)}{K \lambda}}} \tag{14}\]where \(X\) is the random variable of the current state of the material; \(S\) is the set of state spaces. Clearly,  
\[\lim_{T\rightarrow\infty}\frac{e^{-\frac{E(i)}{kT}}}{e^{-\frac{E(i)}{kT}}}=\frac {1}{|S|} \tag{15}\]  
where \(|S|\) is the number of states in the set \(S\). This means that all the states have the same probability at high temperature. \[ \begin{split}&\lim_{T\rightarrow\infty}\frac{e^{-\frac{E(i)-E_{ min}}{kT}}}{e^{-\frac{E(i)-E_{min}}{kT}}}=\lim_{T\rightarrow\infty}\frac{e^{- \frac{E(i)-E_{min}}{kT}}}{e^{-\frac{E(i)-E_{min}}{kT}}+\sum_{j\in S_{min}}e^{- \frac{E(j)-E_{min}}{kT}}}\\ &=\lim_{T\rightarrow\infty}\frac{e^{-\frac{E(i)-E_{min}}{kT}}}{ \sum_{j\in S_{min}}e^{-\frac{E(j)-E_{min}}{kT}}}=\left\{\begin{array}{l} \frac{1}{|S_{min}|}\\ 0,\ else\end{array},\ i\in S_{min}\right.\end{split}  \tag{16}\]  
where \(E_{min}=minE(j)\) and \(S_{min}=\{i|E(j)=E_{min}\}\). The above equation indicates that when the temperature drops to a very low level, the material will enter a minimum energy state. When the temperature drops to 0, the \(E(i)\) distribution is  
\[P_{i}^{*}=\left\{ \begin{array}{l}\frac{1}{|S_{min}|}\\ 0,\ else\end{array} ,\ i\in S_{min}\right. \tag{17}\]  
and  
\[\sum_{x_{i}\in S_{min}}P_{i}^{*}=1 \tag{18}\]  
This means that the temperature drops very slowly and each temperature has a lot of state transitions so that each temperature to achieve thermal balance. It will find the global optimal solution with probability 1, so the simulated annealing algorithm can find the global optimal solution. Selecting SVM parameters is essentially an optimization problem. In recent years, many experts and scholars have proposed many methods to optimize SVM parameters. [PERSON] et al. proposed a parameter selection algorithm for support vector machines based on ant colony optimization (ACO) [21]. [PERSON] et al. proposed parameter optimization of support vector machines based on particle swarm optimization (PSO) [22]. [PERSON] et al. used genetic algorithm (GA) to optimize the parameters of support vector machines [23]. The convergence speed of ACO algorithm is slow and easy to fall into local optimal. The PSO algorithm is easy to converge in advance and has poor local optimization ability. GA algorithm needs to be encoded first and then decoded and the search speed is slow. To solve these problems, this paper proposes a SVM model optimized by simulated annealing algorithm. The flow chart of optimal SVM parameters for SA search is shown in Figure 7.  
More than 40,000 sets of FSRs data and IMUs data processed by locomotion pattern labeling were used as data set in this experiment. It is divided into 70% training set and 30% test set. The completion process of SA-SVM model is shown in Figure 8, which can be summarized as follows:  
1.