Graphical State Space Model
Abstract
In this paper, a new framework, named as graphical state space model, is proposed for the real time optimal estimation of one kind of nonlinear state space model. By discretizing this kind of system model as an equation which can not be solved by Extended Kalman filter, factor graph optimization can outperform Extended Kalman filter in some cases. A simple nonlinear example is given to demonstrate the efficiency of this framework.
Index Terms:
Graphical State Space Model, Graph Optimization, Factor Graph, Kalman Filter, Extended Kalman Filter, Dynamic Bayesian Network, Optimal EstimationI Introduction
Optimal estimation[1]-[4] is a hit subject for engineers, especially in the science community of GPS, inertial navigation or integrated navigation. In many fields, Kalman filter[5] is the chosen one in the eyes of countless engineers. Recently, factor graph[6]-[7] was frequently used to solve many optimal estimation problems in robotics community. It has been widely admitted that on SLAM, SFM and many other subjects better results can be achieved by factor graph optimization than by Kalman filter. However, these good results usually emerged in the cases of post processing. For real time processing, Kalman filter still occupies the hearts of numerous engineers.
In the last forty years, Probabilistic Graphical Model[8] became popular in both academic world and industry world. Pearl[9] introduced the belief propogation to Bayesian network, which can solve the propability inference problem in complex graphical models. Loeiger[7] discovered sum-product algorithm for factor graph, which motivated great improvements in communication community. Dellaert and Kaess[6] developed gorgeous techniques for factor graph, while numerous applications in the robotics community were stimulated by their research.
Generally, there are two kinds of graphcial models[8]: Bayesian network[9] (Directional Graphical Model) and Markov Field (Undirectional Graphical Model). Both of them can be transformed to factor graph. Then, powerful tools, such like junction tree or other appoximate inference algorithms can be used to perform probabilistic inference on factor graph. According to the pioneer work mentioned above, we have enough tools to solve much more complex graphical models than those solved by the pioneers in 1960s. Kalman filter is regarded as a special simple case of dynamic Bayesian network[10] from the viewpoint of graphical models.
In this paper, a new framework, named as Graphical State Space Model(GSSM), is proposed for the real time optimal estimation of one kind of nonlinear state space model. In the framework of Kalman filter, the continous-time state space model is discretized as a time-series model in the chronological order. Here it is demonstrated that some kind of continous-time model can be discretized as a dynamic Bayesian network. Then, factor graph can be used to represent the density functions. This provides the possibility in the increase of the estimation accuracy. Another merit of this dicretization method is that it can reduct the dimension of the equation needed to be solved. A simple example is used to demonstrate the availibility of the new framework. The clou of this paper is how to organize an equation that Kalman filter can not solve while factor graph optimization can solve.
The paper is orginized as follows. Section I is a brief introduction. In section II, Kalman filter is analyzed from the viewpoint of graphical model. In section III, it is demonstrated what factor graph optimization can do for standard discrete state space model. Grapical state space model is proposed in section IV. A simple example is given to demonstrate the availibility of this powerful model in section V. This paper is concluded in section VI.
II Graphical model viewpoint for Kalman Filter
There are many viewpoints for Kalman filter, such as Bayesian filter, information filter or recursive weighted least squared methods. Before we investigate Kalman filter at the perspective of graphical model, let us review this classical algorithm in the traditional manner.
Besides the famous equations of Kalman filter, the prequisite part is continous-time system theory and its discretization. Many problems in the real world can be formulated as a nonlinear system.
(1) | |||
(2) |
The linearization of the above system can be discribed as follows
(3) | |||
(4) |
where is the system state vector, is the measurement vector, is the control vector. is an matrix, which is called the system matrix. is an matrix, which is called the input matrix. is an matrix, which is called the measurement matrix. is the process noise and is the measurement noise. and are the known covariance matrices.
The above system can be discretized as follows
(5) | |||
(6) |
where is the discrete system state vector, is the discrete measurement vector, is the discrete control vector. is an matrix, which is called the system matrix or the predition matrix. is the sample time interval. is an matrix, which is called the input matrix. is an matrix, which is called the measurement matrix. is the process noise and is the measurement noise. and are the known covariance matrices.
The classical Kalman filter can be used to estimate the system described by Equations .
Initialize the estimation,
(7) | |||
(8) |
Update the prior mean and covariance
(9) | |||
(10) |
Calculate Kalman gain
(11) |
Update the posteriori mean and covariance
(12) | |||
(13) |
To summarize, Kalman filter consists of three steps:
1. Utilize the physical laws to model the system correctly, which goes as Equations .
2. Disretize the system, which goes as Equations .
3. Using the famous Equations to update the mean and covariance of in the chronological order. From the viewpoint of graphical models, Kalman filter can be ragarded as a specical case of dynamic Bayesian network.
Probabilistic graphicl model theory consists of three parts[8]: representation, inference and learning. In Fig. 2, the optimization problem is represented as a factor graph. Factor graph [6] is a kind of bipartie graph, , which consists of Factor nodes, Variable nodes and Edges. When inference is done via probabilistic graphicl model theory, Hidden Markov Model assumption [10] for density function is accepted as follows
(14) |
In fact, what Kalman filter do in the process of solving Equation (14) is recursively solving a large block tridiagonal equation as follows
(15) |
At time , probabilistic inference is done on a small factor graph represented by Fig. 4.
According to message-passing algorithm theory[10], Kalman filter can only perform forward directional message passing . The reason is that marginalization, which is discribed by Equations , is done every each time. This means that Kalman filter can not pass the later messages backward to the previous states.
The inference problem represented by Fig. 2 can be perfermed by the solution of the equation as follows
(16) |
Kalman filter utilizes Equations to solve Equation (16). Different from factor graph optimization, Kalman filter only give the estimation of , while factor graph optimization will calculate the estimation of and at the same time.
For factor graph optimization, the above equation can be arranged as three factors [6]:
1. Priori factor, which represents the priori .
2. Between factor, which represents the transition probability .
3. Measurement factor, which represents the conditional probability .
(17) |
The junction tree can be generated for these factors. The clique is simplely comprised of three factors above. Via this tree, probabilistic inference is performed. From the viewpoint of factor graph optimization, the distributions of and are updated while at the perspective of Kalman filter, only the distribution of is updated, which is called marginalization.
Obviously, Kalman filter is a specical case of factor graph optimization. First, Kalman filter have no iteration steps. Secondly, Kalman filter does not update the distributions of previous states, which is called smoothing at the perspective of traditional optimal estimation.
III Factor Graph Optimization for State Space model
It should be noted that Equation (15) can be solved easily be factor graph optimization. Assuming that
(18) | |||
(19) | |||
(20) |
Then, Equation (15) can be formulated as a weighted least squared problem
(21) |
where .
Open source library, such as Ceres[11], G2O[12], GTSAM[6], miniSAM[13] and minisam[14], can be easily gotten via internet to solve the above problem. In fact, factor graph optimization can solve both single connected graphical model, such as state space model, and multi connected graphical model. It is a powerful bottle-opener for complex graphical models.
There are two kinds of methods for factor graph optimization: global optimization and sliding window optimization. The difference lies in whether do marginalization or not. Since the dimension of the whole graph increases as time goes on, the amounts of caculation will be out of control if the dimension of the graph is not limited. For this reason, when factor graph optimization is used in real-time processing case, sliding window optimization will be adopted, which can be represented as Fig. 5 and Fig. 6.
The block tridiagonal equation goes as follows
(22) |
(23) |
After the above equation is solved, should be marginalized out for next measurement update.
This sliding window model just has a bigger dimension than the model discribed in Fig. 4. When factor graph optimization is used to solve Equation (22), its solution accuracy is just like the sliding window filter in theory. It does not use another important merit of factor graph, which is that factor graph can model the system into a multi connected graph.
It should not be igored, what factor graph can do while the traditional space model can not do:
1. Model the system as a multi connected graph.
2. Model the system distributedly not unifiedly.
3. Model one part of the system as constants rather than time-series variables.
These merits are not utilized in Equation (22). If a new framework can be designed to adopt them, maybe factor graph optimization can outperform Kalman filter in real-time processing case.
IV Graphical state space model
It is strongly believed by many engineers that Extended Kalman filter is the best solution for sequential data optimal estimation described by Equations . We totally agree with this opinion. Although graphical models solved by factor graph optimization can be much more complex than space model, factor graph optimization can not outperform Kalman filter when they use the same sequential space model. Another fact which can not be ignored is that factor graph can model the system distributedly. When Kalman filter is used to model the system, there is only one universial state which evolves in the chronological order. If you want better results via factor graph optimization, perhaps you should try a different state space model.
For some continous-time system decribed by Equations , there is a different discretization method. For this kind of system, it can be discretized as another kind of graphical model. Consider the system as follows
(24) | |||
(25) |
where is the system state vector, . is the measurement vector, is the control vector. is an matrix and is an matrix. is an matrix, which is called the input matrix. is an matrix and is an matrix. is the process noise and is the measurement noise. and are the known covariance matrices.
When Kalman filter is used to estimate the state, , in the above equations, Equations will be used to discretize Equations . The prediction matrix will be
(26) |
Next, Kalman filter will recursively solve Equation (15). Obviously, Kalman filter can not make use of the characteristics of this kind of this system.
Graphical state space model is different with the system model used by Kalman filter. No matter in global or sliding window case, it discretizes the system as a graphical model which has a different topological structure.
The system described by Equations can be discretized as follows
(27) | |||
(28) | |||
(29) |
where . is the measurement vector, is the control vector. is an matrix and is an matrix. is the sample time interval. is an matrix, which is called the input matrix. is an matrix, which is called the measurement matrix. is the process noise and is the measurement noise. and are the known covariance matrices.
Equation (29) is the dicretization of the state . This means that constant states can be modeled as a different form rather than a time-series form. This is the distributed discretization not the unified discretization.
Definitely, Kalman filter can not solve Equations if unknown is not discretized as a time-series form. This is the limitation of Kalman filter that it must use time-series forms to represent constant variables. Via the kind of discretization described in Equations , the equation solved by factor graph optimization will be different with Equation (22).
Furthermore, since is not discretized as a time-series form, the dimension of the equation is smaller than that of Equation (22). The variables are , while if the discretization method of Kalman filter is used, the variables of Equation (22) will be . Equation (30) can not be solved by Kalman filter, while factor graph optimization can solve it efficiently. Since the structure of is not block tridiagonal any more, Kalman filter can not be used recursively to solve the equation. By the way, the norm function are smaller than that discribed by Equation (21). This makes it possible that factor graph optimization can achieve different results with Kalman filter in real-time cases.
(30) |
Via factor graph optimization, the solution of Equation (30) can be gotten
(31) |
It is easy to be caculated that the dimension of the equation is smaller than that dimension if sliding window Kalman filter was used.
Viariable | Dim of | Dim of | Dim of |
---|---|---|---|
Sliding window | |||
Kalman filter | |||
Graphicl State | |||
Space model |
Graphical state space model is illustrated with state space form in Fig. 7. It can be also represented in factor graph form as it is illustrated in Fig. 8. Obviously, it is a graphical model with cycles. This means that junction tree algorithm must be used to represent the model with a tree without cycles for exact inference. The estimation will get convergent to a fixed point when the probabilistic inference is being perfermed via the junction tree. It will be demonstrated in the next section that graphical state space model can describe the system more accurately than Extended Kalman filter in some cases.
V A simple example
A simple radar tracking model was usually used to demonstrate how to use Kalman filter[15]. Here it is used to demonstrate the efficiency of the new framework. However, it should be noted that this framework can not be used in all kinds of system!!! For this reason, it is strongly recommended that you must perform simulation before real implementation.
A simple two dimensional radar-tracking problem can be described as follows
(32) |
The measured range
(33) |
The continous-time system of simple radar tracking is described by
(34) | |||
(35) |
When the framework of Kalman filter is used, the discrete-time system goes as follows
(36) | |||
(37) |
where is the prediction interval.
If graphical state space model is used, the system state can be modeled distributedly.
(38) |
The discrete-time system is discribed by
(39) |
(40) |
For Kalman filter, simulation settings are set as follows
(41) |
For graphical state space model, simulation settings are set as follows
(42) |
Obviously, Kalman filter and graphical state space model adopt the same simulation settings. Simulation results111The open soure codes for this example can be found at github, https://github.com/shaolinbit/GraphicalStateSpaceModel are demonstrated in Fig. 9 and Fig. 10. For this example, graphical state space model can outperform Kalman filter.
VI Conclution and Future works
In this paper, a new framework, named as graphical state space model, was proposed to estimate the state of a class of nonlinear system. A simple example was used to demonstrate the efficiency of this framework. In some cases, graphical state space model can extract more information than the standard Kalman disrete model. Detailed error analysis should be done in the future. What should be explorered next is that which kind of system can be estimated by this framework.
Acknowledgment
Graphical state space model[16] is patent pending. Thanks for Professor Yulong Huang from Harbin University of Engineering for his kindly invitation.
References
- [1] D. Simon, “Optimal State Estimation: Kalman, H-infinity, and Nonlinear Approaches,” John Wiley Sons, 2006.
- [2] P. Zarchan, H. Musoff, “Fundamentals of Kalman Filtering: A Practical Approach, ” AIAA, 2009.
- [3] Y. Huang, Y. Zhang, Y. Zhao, J. A. Chambers, “A Novel Robust Gaussian–Student’s t Mixture Distribution Based Kalman Filter, ” IEEE Trans. Signal Processing, vol. 67, Issue. 13, pp. 3606–3620, 2019.
- [4] Y. Huang, Y. Zhang, B. Xu, Z. Wu, J. A. Chambers, “A New Adaptive Extended Kalman Filter for Cooperative Localization, ” IEEE Trans. Aerospace and Electronic System, vol. 54, Issue. 1, pp. 353–368, 2018.
- [5] R. E. Kalman, “A new approach to Linear Filtering and Predition Problem,” ASME Trans. J. Basic Engineering, vol. 82, pp. 35–45, 1960.
- [6] F. Dellaert, M. Kaess, “ Factor Graph for Robotic Perception,” Foundation and Trend in Robotics, Vol. 6 no. 1-2, pp. 1–139, 2017.
- [7] F. R. Kschischang, B. J. Frey, Hans-Andrea Loeliger, “Factor Graphs and the Sum-Product Algorithm,” IEEE Trans. Information Theory, Vol. 47, No. 2, pp. 498–519, 2001.
- [8] D. Koller, N. Friedman, “Probabilistic Graphical Models: Principles and Techniques,” Mit Press, 2009.
- [9] J. Pearl, “Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference,” Morgan Kaufmann, 1988.
- [10] K. P. Murphy, “Dynamic Bayesian Networks: Representation, Inference and Learning,” UC Berkeley, 2002.
- [11] S. Agarwal, K. Mierle and others, “Ceres Solver,” http://ceres-solver.org.
- [12] R, Kümmerle, G. Grisetti, H. Strasdat, K. Konolige, W. Burgard, “ g2o: A General Framework for Graph Optimization,” IEEE Conference on Robotics and Automation, pp. 3607–3613, 2011.
- [13] J. Dong, Z. Lv, “miniSAM: A Flexible Factor Graph Non-linear Least Squares Optimization Framework,” arxiv.org/abs/1909.00903, 2019.
- [14] S. Lü, “http://github.com/shaolinbit/minisam_lib. ”
- [15] R. Labbe, “Kalman and Bayesian Filters in Python,” 2015.
- [16] S. Lü, “One kind of Optimal estimation Method and System, ” (in Chinese), Patent Number: 202110333355.2, 2021.