# Indoor Positioning Integrating PDR/Geomagnetic Positioning Based on the Genetic-Particle Filter
## 2 Materials and Methods
### Fusion Positioning Module
#### 2.3.4 Fusion-Positioning Algorithm based on Genetic-Particle Filter  
In this section, we will describe the detailed process of the fusion positioning algorithm based on the G-Particle Filter. We use PDR as the system state \(\mathbf{X}(k)\) and the geomagnetic positioning results  
Figure 8: Process of genetic-particle filter.  
Figure 7: Particle mutation.  
\(\mathbf{Z}(k)=\{\mathbf{Z}_{1},\mathbf{Z}_{2},\cdots,\mathbf{Z}_{m}\},\mathbf{Z}_{1}=(x_{1},y_{1}),\cdots\), as the system observation; the PDR position will be corrected in real-time by the fusion positioning results. The general process is as follows:  
**Step 1**, predict the system state \(\mathbf{X}(k)\) at time \(k\) and reconstruct the particle set based on \(\mathbf{X}(k)\). We assume the particle set is \(\mathbf{P}(k)=\{\mathbf{P}_{1},\mathbf{P}_{2},\cdots,\mathbf{P}_{n}\}\) and the weight of each particle is \(1/N\). Then, we should select the \(s\) observations with the smallest distance to replace the last \(s\) particles to reconstruct the particle set. The new particle set is \(\mathbf{P}(k)=\{\mathbf{P}_{1},\mathbf{P}_{2},\cdots\mathbf{P}_{n-s^{\prime}},\cdots,\mathbf{P}_{n ^{\prime}}\}\).  
**Step 2**, update and normalize the weights of particles. After getting the reconstructed particle set, each particle's weight should be updated by using the Gaussian function:  
\[\omega_{i}(k)=\frac{1}{\sigma_{r}\sqrt{2\pi}}exp\Bigg{[}-\frac{\|\mathbf{P}_{i}- \mathbf{X}(k)\|^{2}}{2\sigma_{r}{}^{2}}\Bigg{]} \tag{25}\]  
where \(\sigma_{r}\) is the observation noise. The normalized weight of each particle can be calculated by:  
\[\omega^{\prime}{}_{i}(k)=\frac{\omega_{i}(k)}{\sum\limits_{i=1}^{n}\omega_{i} (k)} \tag{26}\]  
where \(\omega_{i}(k)\) and \(\omega^{\prime}{}_{i}(k)\) are the un-normalized and normalized weights of \(i\)-th particle, respectively.  
**Step 3**, resample particles and calculate the fusion-positioning results. Based on each particle's normalized weight, the particles with small weights are abandoned and the particles with large weights are copied to replace them. After resampling, the average coordinates of the resampled particles are computed by using Equation (27) and setting as the fusion position \(\mathbf{R}(k)\):  
\[\mathbf{R}(k)=\frac{1}{n}\Bigg{(}\sum\limits_{i=1}^{n}x_{i},\sum\limits_{i=1}^{n}y _{i}\Bigg{)} \tag{27}\]  
**Step 4**, correct the PDR positions. After the three steps above, we should correct the PDR coordinates by using the fusion position \(\mathbf{R}(k)\).  
**Step 5**, particles mutation. In this step, we should convert the coordinates of the resampled particles into the binary code by using Algorithm 2. Gene mutation is used to change the coordinate values of the particles and the mutated particles will be passed to the next generation.  
To summarize, when the system is running continuously, the above steps will be executed cyclically. At each moment, the system will geneticize the best quality particles to the next moment and the geomagnetic positioning results at the next moment will reconstruct the particle set. Particle mutation and the reconstruction of particle set methods ensure the reliability and the diversity of particles. Figure 9 shows the process of the fusion-positioning system.  
Figure 9: Fusion-positioning algorithm based on genetic-particle filter.