.Modelica_LinearSystems2.StateSpace.Design.lqg

Information

Syntax

(Kc, Kf, sslqg) = StateSpace.lqg(ss, Q, R, V, W)

Description

This function calculates matrices Kc and Kf for linear quadratic gaussian problem (LQG), i.e. the minimization of the expected value of a cost function in consideration of stochastically disturbed states and outputs of the system

der(x) = Ax + Bu + w
     y = Cx + Du + v

The noise w(t) and v(t) are supposed to be both white, Gaussian zero-mean, stationary stochastic processes with positive semidefinte covariance matrix W

E[w(t)*w'(tau)] = W*delta(t-tau)

and positive covariance matrix V

E[v(t)*v'(tau)] = V*delta(t-tau).

E[s] denotes the expected value of a signal s.

The LQG approach combines the deterministic LQR approach and Kalman filter principle to estimate stochastically disturbed systems, such that input u(t) is given by

u(t) = -Kc(t)

where Kc is a lqr feedback matrix and (t) the reconstructed state vector estimated by a Kalman filter.

Since, the considered problem is stochastic, the objective function to minimize is an expected value

           1      T
J = lim   ---- E[Integral (x'*Q*x + u'*R*u)dt],
  (T->inf) 2T    -T

where the weighting matrices Q and R are, respectively, symmetric positive semidefinite and positive definite.

The feedback matrix Kc is calculated by

Kc = R-1*B'*Xc,

where Xc satisfying the continuous-time algebraic Riccati equation (care)

Q + A'*Xc + Xc*A - Xc*B*R-1*B'*Xc = 0.

The matrix Kf of the filter problem to generate the estimated state vector (t) is given by

Kf = Xf*CT*V-1,

where Xf is satisfying the continuous-time algebraic Riccati equation

W + A*Xf + Xf*A' - Xf*C'*V-1*C*Xf = 0.

The vector (t) satisfies the differential equation

x̂̇(t) = (A - KfC)(t) + (B - KfD)u(t) + Kfy(t)

Combining the equation state feedback and state estimation, the state vector x(t) and the estimated state vector (t) are given by

| | | A BKc | | x | | I 0 | | w |
| x |   =   | | | |   +   | | | |
| x̂̇ | | KfC ABKc − KfC | | | | 0 Kf | | v | .

Finally, the output sslqg represents the estimated system with y(t), the output of the real system, as the input

x̂̇ = [A - KfC - BKc + KfDKc]* + Kf*y
= [C - DKc]

Example

  StateSpace ss=StateSpace(
    A=[-0.02, 0.005, 2.4,  -32; -0.14,  0.44,  -1.3,  -30; 0,  0.018,  -1.6,  1.2; 0, 0, 1, 0],
    B=[0.14,  -0.12; 0.36, -8.6; 0.35, 0.009; 0, 0],
    C=[0, 1, 0, 0; 0, 0, 0, 57.3],
    D=[0,0; 0,0]);

   Real Q[:,:] = transpose(ss.C)*ss.C " state weighting matrix";
   Real R[:,:] = identity(2) " input weighting matrix";
   Real V[:,:] = identity(2) " covariance output noise matrix";
   Real W[:,:] = ss.B*transpose(ss.B) " covariance state noise matrix";
   Real Kc[size(ss.B, 2),size(ss.A, 1)] "Controller feedback gain matrix";
   Real Kf[size(ss.A, 1),size(ss.C, 1)] "Kalman feedback gain matrix";

algorithm
  (Kc, Kf) := StateSpace.Design.lqg(ss, Q, R, V, W);

// Kc = [-0.0033,     0.04719,      14.6421,        60.8894;
          0.0171,    -1.05154,       0.29273,        3.2468]

// Kf = [0.015,     -0.2405;
         9.066,     -0.1761;
         0.009,      0.2289;
        -0.003,      0.08934]

Interface

encapsulated function lqg
  import Modelica;
  import Modelica_LinearSystems2;
  import Modelica_LinearSystems2.StateSpace;
  import Modelica_LinearSystems2.Math;
  input StateSpace ss "Open loop system in state space form";
  input Real Q[size(ss.A, 1), size(ss.A, 2)] = identity(size(ss.A, 1)) "State weighting matrix";
  input Real R[size(ss.B, 2), size(ss.B, 2)] = identity(size(ss.B, 2)) "Input weighting matrix";
  input Real V[size(ss.C, 1), size(ss.C, 1)] = identity(size(ss.C, 1)) "Covariance output noise matrix";
  input Real W[size(ss.A, 1), size(ss.A, 1)] = identity(size(ss.A, 1)) "Covariance state noise matrix";
  input Boolean iscontinuousSystem = true "True, if state space system is continuous";
  output Real Kc[size(ss.B, 2), size(ss.A, 1)] "Controller feedback gain matrix";
  output Real Kf[size(ss.A, 1), size(ss.C, 1)] "Kalman feedback gain matrix";
  output StateSpace sslqg(redeclare Real A[size(ss.A, 1), size(ss.A, 2)], redeclare Real B[size(ss.B, 1), size(ss.C, 1)], redeclare Real C[size(ss.C, 1), size(ss.C, 2)], redeclare Real D[size(ss.C, 1), size(ss.C, 1)]) "Closed loop system";
end lqg;

Revisions

Date Author Comment
2010-05-31 Marcus Baur, DLR-RM Realization

Generated at 2024-11-22T19:25:38Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos