![]() |
Eigen-Contrib
5.0.1-dev+master
|
#include <contrib/Eigen/src/Riccati/DiscreteAlgebraicRiccatiSolver.h>
Solves the discrete-time algebraic Riccati equation (DARE)
| MatrixType_ | the type of the solution matrix \( X \), a square matrix of real or complex scalars; this is expected to be an instantiation of the Matrix class template. |
This class computes the stabilizing solution \( X \) of the discrete-time algebraic Riccati equation
\[ A^* X A - X - (A^* X B) (R + B^* X B)^{-1} (B^* X A) + Q = 0 \]
or of its generalized version
\[ A^* X A - E^* X E - (A^* X B + S) (R + B^* X B)^{-1} (B^* X A + S^*) + Q = 0, \]
where \( A \) and \( E \) are \( m \times m \), \( B \) and \( S \) are \( m \times n \), \( Q \) is \( m \times m \) selfadjoint, \( R \) is \( n \times n \) selfadjoint and \( E \) is nonsingular. \( R \) itself does not need to be invertible.
For a solution to exist, the eigenvalues of \( A \) outside the unit disc have to be controllable and the associated symplectic pencil (see below) must not have eigenvalues on, or too close to, the unit circle.
The solver follows the generalized eigenvalue approach of [1]: it forms the extended symplectic pencil
\[H - \lambda J = \begin{bmatrix} A & 0 & B \\ -Q & E^* & -S \\ S^* & 0 & R \end{bmatrix} - \lambda \begin{bmatrix} E & 0 & 0 \\ 0 & A^* & 0 \\ 0 & -B^* & 0 \end{bmatrix}, \]
optionally balances it as in [3], deflates it by the columns of \( R \), computes its generalized Schur form (RealQZ or ComplexQZ) and reorders it such that the eigenvalues inside the unit circle come first. The leading \( m \) Schur vectors \( [U_1; U_2] \) span the stable deflating subspace and \( X = U_2 U_1^{-1} \) (for the generalized equation, \( U_1 \) is first replaced by \( E U_1 \)). The computation is reported as failed if the pencil does not have exactly \( m \) eigenvalues inside the unit circle, if \( U_1 \) is numerically singular or so small that \( \|X\| \) (of the balanced problem) would exceed about \( 0.2 / \varepsilon \), or if \( U_1^* U_2 \) is far from selfadjoint, which happens when the pencil has eigenvalues too close to the unit circle [2]. A stabilizing solution that large cannot be told apart from an unstable mode that \( B \) does not reach, for which none exists.
Balancing is essential for some badly scaled problems, but it can cost accuracy for others, notably when \( B \) is very small compared to the other matrices. With balancing enabled (the default), the solver therefore checks the backward error of the balanced solution whenever balancing changed the pencil; if it is large, or the balanced computation fails, the unbalanced pencil is solved as well and the more accurate solution is returned. compute(..., false) never balances.
The algorithm follows SciPy's scipy.linalg.solve_discrete_are, with these differences: the generalized equation combines the stable subspace with the balanced \( E \) (SciPy uses the original one, which is wrong when balancing scales the pencil), the unbalanced pencil serves as a fallback (see above), and the number of stable eigenvalues is checked.
Example: a discrete-time LQR controller for a sampled double integrator.
Output:
The stabilizing solution X is: 13.3172 3.20156 3.20156 4.60351 The optimal gain K is: 2.5857 3.44344 The closed-loop eigenvalues of A - B K are: (0.89917,0) (0.743558,0)
References:
Public Member Functions | |
| template<typename InputTypeA, typename InputTypeB, typename InputTypeQ, typename InputTypeR> | |
| DiscreteAlgebraicRiccatiSolver & | compute (const EigenBase< InputTypeA > &A, const EigenBase< InputTypeB > &B, const EigenBase< InputTypeQ > &Q, const EigenBase< InputTypeR > &R, bool balance=true) |
| Solves \( A^* X A - X - (A^* X B) (R + B^* X B)^{-1} (B^* X A) + Q = 0 \). | |
| template<typename InputTypeA, typename InputTypeB, typename InputTypeQ, typename InputTypeR, typename InputTypeE, typename InputTypeS> | |
| DiscreteAlgebraicRiccatiSolver & | compute (const EigenBase< InputTypeA > &A, const EigenBase< InputTypeB > &B, const EigenBase< InputTypeQ > &Q, const EigenBase< InputTypeR > &R, const EigenBase< InputTypeE > &E, const EigenBase< InputTypeS > &S, bool balance=true) |
| Solves \( A^* X A - E^* X E - (A^* X B + S) (R + B^* X B)^{-1} (B^* X A + S^*) + Q = 0 \). | |
| DiscreteAlgebraicRiccatiSolver ()=default | |
| Default constructor; the solver is initialized by calling compute(). | |
| template<typename InputTypeA, typename InputTypeB, typename InputTypeQ, typename InputTypeR> | |
| DiscreteAlgebraicRiccatiSolver (const EigenBase< InputTypeA > &A, const EigenBase< InputTypeB > &B, const EigenBase< InputTypeQ > &Q, const EigenBase< InputTypeR > &R, bool balance=true) | |
| Constructor; solves the discrete-time algebraic Riccati equation. | |
| template<typename InputTypeA, typename InputTypeB, typename InputTypeQ, typename InputTypeR, typename InputTypeE, typename InputTypeS> | |
| DiscreteAlgebraicRiccatiSolver (const EigenBase< InputTypeA > &A, const EigenBase< InputTypeB > &B, const EigenBase< InputTypeQ > &Q, const EigenBase< InputTypeR > &R, const EigenBase< InputTypeE > &E, const EigenBase< InputTypeS > &S, bool balance=true) | |
| Constructor; solves the generalized discrete-time algebraic Riccati equation. | |
| ComputationInfo | info () const |
| Reports whether the last computation was successful. | |
| const MatrixType & | solution () const |
|
inline |
Constructor; solves the discrete-time algebraic Riccati equation.
This is equivalent to calling compute(const EigenBase<InputTypeA>&, const EigenBase<InputTypeB>&, const EigenBase<InputTypeQ>&, const EigenBase<InputTypeR>&, bool).
|
inline |
Constructor; solves the generalized discrete-time algebraic Riccati equation.
This is equivalent to calling compute(const EigenBase<InputTypeA>&, const EigenBase<InputTypeB>&, const EigenBase<InputTypeQ>&, const EigenBase<InputTypeR>&, const EigenBase<InputTypeE>&, const EigenBase<InputTypeS>&, bool).
|
inline |
Solves \( A^* X A - X - (A^* X B) (R + B^* X B)^{-1} (B^* X A) + Q = 0 \).
| [in] | A | square \( m \times m \) matrix |
| [in] | B | \( m \times n \) matrix |
| [in] | Q | selfadjoint \( m \times m \) matrix |
| [in] | R | selfadjoint \( n \times n \) matrix |
| [in] | balance | whether the symplectic pencil is balanced before the QZ decomposition, see the class documentation |
*this The result of the computation is reported by info().
|
inline |
Solves \( A^* X A - E^* X E - (A^* X B + S) (R + B^* X B)^{-1} (B^* X A + S^*) + Q = 0 \).
| [in] | A | square \( m \times m \) matrix |
| [in] | B | \( m \times n \) matrix |
| [in] | Q | selfadjoint \( m \times m \) matrix |
| [in] | R | selfadjoint \( n \times n \) matrix |
| [in] | E | nonsingular \( m \times m \) matrix |
| [in] | S | \( m \times n \) matrix |
| [in] | balance | whether the symplectic pencil is balanced before the QZ decomposition, see the class documentation |
*this Pass the identity for E or zero for S to leave out one of the generalized terms. The result of the computation is reported by info().
|
inline |
Reports whether the last computation was successful.
Success if the computation was successful, InvalidInput if an input matrix is not finite, Q or R is not selfadjoint, or E is numerically singular, NoConvergence if the QZ iteration did not converge, and NumericalIssue if the stable deflating subspace of the symplectic pencil could not be isolated (no stabilizing solution exists, the pencil has eigenvalues too close to the unit circle, or the solution would be too large to compute, see the class documentation).
|
inline |
Success.