# Intelligent Fusion Structure for Wi-Fi/BLE/QR/MEMS Sensor-Based Indoor Localization
## 3 Mems Sensor-Based Localization, Optimization, and Evaluation Framework
### MLP-Based Crowdsourced Trajectories Evaluation Algorithm  
After the optimized trajectories were processed and collected, the trajectory error needed to be predicated for further trajectory selection and fusion. This section presents an MLP-based trajectory-error-prediction model that uses only motion features extracted from optimized trajectories to predict the accuracy of crowdsourced trajectories. Compared with other classical structures, such as long short-term memory (LSTM) [41] and the convolutional neural network (CNN) [42], MLP networks have a simpler structure and are more efficient to train. In addition, MLP networks can effectively learn and extract features from crowdsourced indoor trajectories and they are not limited by the length of the input vector. To improve the precision of the MLP-based error-evaluation model, different trajectory information features were extracted as input vectors in the MLP training phase, including:  
(1) The step length calculated in real time during each gait;  
(2) Estimated heading result \(\varpi_{k}\) during each gait procedure;  
(3) Cumulative numbers of steps \(\eta_{k}\) from the first moment;  
(4) Cumulative change in heading, which is calculated as follows:  
\[\Delta\theta(k)=\sum_{k=1}^{n}\sqrt{|\varpi_{k}{}^{2}-\varpi_{k-1}{}^{2}|} \tag{15}\]  
where \(\Delta\theta(k)\) indicates the cumulated heading difference and \(\varpi_{k}\) is the real-time heading information;(5) Ratio between used distance and total distance:  
\[\xi_{d}(k)=\frac{\sum\limits_{k=1}^{\beta}{L_{k}}}{\sum\limits_{k=1}^{n}{L_{k}}} \tag{16}\]  
where \(n\) represents the recorded gait quantity of the specific trajectory and \(\beta\) indicates the taken gaits;  
(6) Ratio between used time and total time:  
\[\xi_{t}(k)=T(k)/T_{total} \tag{17}\]  
where \(T_{total}\) represents the overall time period of specific trajectory and \(T(k)\) indicates the current time used;  
(7) The ratio of the number of steps taken to the total number of steps:  
\[\xi_{s}(k)=step(k)/step_{total} \tag{18}\]  
where \(step_{total}\) represents the total gait detected under the selected route and \(step(k)\) indicates the taken gait number at current moment.  
The presented characteristics can adaptively simulate the accuracy of the selected crowdsourced trajectory from different perspectives, which will further be constructed as the input vector in the MLP model for training purposes; the input vector and output vector of the MLP network is described in Figure 1.  
The loss function of the presented MLP is modeled as:  
\[Loss(\mathbf{\alpha},\mathbf{\beta})=\frac{1}{2m}{\sum\limits_{x}{\left\|{g(x)-\mathbf{ \eta}}\right\|^{2}}} \tag{19}\]  
where \(\mathbf{\alpha}\) and \(\mathbf{\beta}\) represent the weight and bias vectors, \(g(x)\) indicates the calculated result during each training phase, and \(\mathbf{\eta}\) indicates the reference output vector. The stochastic gradient descent (SGD) is adopted for model training, which is described as:  
\[\left\{\begin{array}{l}\alpha_{k}\rightarrow\alpha_{k}=\alpha_{k}-\frac{v}{ m}{\sum\limits_{j}{\frac{\partial Loss_{j}}{\partial\alpha_{k}}}}\\ \beta_{l}\rightarrow\beta_{l}=\beta_{l}-\frac{v}{m}{\sum\limits_{j}{\frac{ \partial Loss_{j}}{\partial\beta_{l}}}}\end{array}\right. \tag{20}\]  
Figure 1: Structure of presented MLP network.  
where \(\
u\) represents the set learning rate during training phase and \(\alpha_{k}\) and \(\beta_{l}\) are the trained weight and bias parameters, respectively. The trained model of the MLP is further applied for the autonomous evaluation of crowdsourced trajectories.