X = Matrices.Utilities.continuousRiccatiIterative(A, B, R, Q, X0); (X, r) = Matrices.Utilities.continuousRiccatiIterative(A, B, R, Q, X0, maxSteps, eps);
This function provides a Newton-like method for solving continuous algebraic Riccati equations (care). It utilizes Exact Line Search to improve the sometimes erratic
convergence of Newton's method. Exact line search in this case means, that at each iteration i
a Newton step delta_i
X_i+1 = X_i + delta_i
is taken in the direction to minimize the Frobenius norm of the residual
r = || X_i+1*A +A'*X_i+1 - X_i+1*G*X_i+1 + Q ||.
with
-1 G = B*R *B'
The inputs "maxSteps" and "eps" specify the termination of the iteration. The iteration is terminated if either maxSteps iteration steps have been performed or the relative change delta_i/X_i became smaller than eps.
With an appropriate initial value X0 a sufficiently accurate solution might be reach within a few iteration steps. Although a Lyapunov equation
of order n
(n is the order of the Riccati equation) is to be solved at each iteration step, the algorithm might be faster
than a direct method like Matrices.continuousRiccati, since direct methods have to solve the 2*n-order Hamiltonian
system equation.
The algorithm is taken from [1] and [2].
[1] Benner, P., Byers, R. An Exact Line Search Method for Solving Generalized Continuous-Time Algebraic Riccati Equations IEEE Transactions On Automatic Control, Vol. 43, No. 1, pp. 101-107, 1998. [2] Datta, B.N. Numerical Methods for Linear Control Systems Elsevier Academic Press, 2004.
A=[0.0, 1.0, 0.0, 0.0; 0.0, -1.890, 3.900e-01, -5.530; 0.0, -3.400e-02, -2.980, 2.430; 3.400e-02, -1.100e-03, -9.900e-01, -2.100e-01]; B=[ 0.0, 0.0; 3.600e-01, -1.60; -9.500e-01, -3.200e-02; 3.000e-02, 0.0]; R=[1, 0; 0, 1]; Q=[2.313, 2.727, 6.880e-01, 2.300e-02; 2.727, 4.271, 1.148, 3.230e-01; 6.880e-01, 1.148, 3.130e-01, 1.020e-01; 2.300e-02, 3.230e-01, 1.020e-01, 8.300e-02]; X0=identity(4); (X,r) = Matrices.Utilities.continuousRiccatiIterative(A, B, R, Q, X0); // X = [1.3239, 0.9015, 0.5466, -1.7672; 0.9015, 0.9607, 0.4334, -1.1989; 0.5466, 0.4334, 0.4605, -1.3633; -1.7672, -1.1989, -1.3633, 4.4612] // r = 2.48809423389491E-015 (,r) = Matrices.Utilities.continuousRiccatiIterative(A, B, R, Q, X0,4); // r = 0.0004;
function continuousRiccatiIterative extends Modelica.Icons.Function; import Modelica.Math.Matrices; input Real A[:, size(A, 1)] "Matrix A of Riccati equation X*A + A'*X -X*G*X +Q = 0"; input Real B[size(A, 1), :] "Matrix B in G = B*inv(R)*B'"; input Real R[size(B, 2), size(B, 2)] = identity(size(B, 2)) "Matrix R in G = B*inv(R)*B'"; input Real Q[size(A, 1), size(A, 2)] = identity(size(A, 1)) "Matrix Q of Riccati equation X*A + A'*X -X*G*X +Q = 0"; input Real X0[size(A, 1), size(A, 2)] = identity(size(A, 1)) "Initial approximate solution for X*A + A'*X -X*G*X +Q = 0"; input Integer maxSteps = 10 "Maximal number of iteration steps"; input Real eps = Matrices.frobeniusNorm(A)*1e-9 "Tolerance for stop criterion"; output Real X[size(X0, 1), size(X0, 2)] "Solution X of Riccati equation X*A + A'*X -X*G*X +Q = 0"; output Real r "Norm of X*A + A'*X - X*G*X + Q, zero for exact solution"; end continuousRiccatiIterative;