# Improving Smartphone GNSS Positioning Accuracy Using Inequality Constraints
## 3 Kalman Filter with Inequality Constraints
### Solution of Inequality Constraint  
Typically, a state inequality relationship can be presented in a linear form as follows:  
\[d_{l}\leq\mathbf{C}\mathbf{X}\leq d^{u} \tag{24}\]  
where \(d_{l}\) represents the lower bound of the constraints, and \(d^{u}\) represents the upper bound. In fact, another equality constraint can also be applied to restrict the state based on the Gaussian distribution. It can be expressed as follows:  
\[\left\{\begin{array}{l}\mathbf{C}\mathbf{X}=\overline{d}=\frac{d_{l}+d^{u}}{2}\\ \mathbf{Q}_{\overline{d}}=\frac{1}{m}\times\  
Some strategies can be utilized to solve the inequality constraint, such as the maximum probability method, the mean square method, and the projection method [27]. The common aim of these methods is to solve the problem summarized and expressed in Equation (26).  
\[\min\left(\widetilde{\mathbf{X}}-\widehat{\mathbf{X}}\right)^{\mathrm{T}}\!\! \mathbf{W}_{k}\!\left(\widetilde{\mathbf{X}}-\widehat{\mathbf{X}}\right)\,s.t. \,\,\,C\widetilde{\mathbf{X}}\leq\mathbf{d} \tag{26}\]  
where \(\mathbf{W}_{k}\) represents any symmetric positive definite weighting matrix, \(\widetilde{\mathbf{X}}\) is the state after constraining, and \(\widehat{\mathbf{X}}\) is the estimation of the conventional unconstrained Kalman filter. We can obtain the result using the maximum probability method and the mean square method by setting \(\mathbf{W}_{k}=\hat{\mathbf{Q}}_{k}^{-1}\) and \(\mathbf{W}_{k}=\mathbf{I}\), respectively, in which \(\mathbf{I}\) represents a unit matrix. The problem defined by this inequation is known as a quadratic programming (QP) problem. There are many methods that can be applied to solve it, and almost all of them fall into a category named the active set method. As an optimization method, the active set method treats a subset of constraints as additional equality constraints; then, it transforms the problem into an estimator with an equality constraint, which is also called an \"active set\". As this method has been introduced in numerous works of literature, we will not review it in detail in this paper [45]. In this paper, we apply the density function truncation method to solve the inequality constraint, since the state and the variance can be obtained using this method, which is helpful for sequential estimation [27]. The goal of the method is to reset the cumulative probability of the constrained region to 1. There are several steps that must be followed to reach this goal. Firstly, we transform the state vector and variances into a constrained region. Secondly, we calculate the cumulative probability between the constraints bound based on the transformed state and variance. Note that we use a Gaussian PDF, since we assume that the estimated state follows the distribution. The function can be expressed as:  
\[\left\{ \begin{array}{l}f(x;\mu,\sigma)=\frac{1}{\sigma\sqrt{2\pi}}\exp\! \left(\frac{-(x-\mu)^{2}}{2\sigma^{2}}\right)\\ \mathrm{CPD}=\int_{d_{1}}^{d_{u}}f(\tau;\mu_{0},\,\sigma_{0})d\tau\end{array} \right. \tag{27}\]  
where \(f(x;\mu,\sigma)\) represents the PDF under the expectation \(\mu\) and the variance \(\sigma\). CPD represents the cumulative probability distribution (CPD) of the constrained area. \(\mu_{0}\) and \(\sigma_{0}\) represent the state and variance after transformation, respectively. Thirdly, we normalize the PDF using the CPD, and then compute the expectation and variance in the region using the normalized PDF as follows:  
\[\left\{ \begin{array}{l}f_{0}(x;\mu,\sigma)=\frac{1}{\mathrm{CDF}}f(x;\mu, \sigma)\\ \hat{\mu}=\int_{d_{1}}^{d_{u}}\tau f_{0}(\tau;\mu_{0},\sigma_{0})d\tau\\ \hat{\sigma}=\int_{d_{1}}^{d_{u}}(\tau-\hat{\mu})^{2}f_{0}(\tau;\mu_{0},\sigma _{0})d\tau\end{array} \right. \tag{28}\]  
Figure 5: Probability distribution of inequality and equality constraints: (**a**) inequality constraint; (**b**) equality constraint. where \(\hat{\mu}\) and \(\hat{\sigma}\) represent the exception and variance of the constrained area.