Tartalomjegyzék

LTI controllability observability

Teljes Matlab script kiegészítő függvényekkel.

Check controllability and observability of an LTI system using LMI conditions

File: LTI_ctrb_obsv.m
Directory: 2_demonstrations/workspace/ccs/ccs_2018
Author: Peter Polcz (ppolcz@gmail.com)
Created on 2018. November 06.

Generate an unstable non-minimum phase MIMO LTI system

a = 4;        % Nr. of contr. and obs.
b = 2;        % Nr. of contr. and unobs.
c = 1;        % Nr. of uncontr. and obs.
d = 2;        % Nr. of uncontr. and unobs.
n = a+b+c+d;  % Nr. of states
m = 2;        % Nr. of inputs
p = 3;        % Nr. of outputs
is_stabilisable = 1;

[A,B,C,D] = LTI_generate_sys(a,b,c,d,m,p,is_stabilisable);

pcz_display(A,B,C,D)
Output:
A [9x9] = 
 
  Columns 1 through 7

   -0.7133   -0.8096    0.1205   -1.8870   -1.1994    1.3781   -0.3345
   -0.3155   -0.9061    0.1360   -0.5072   -0.1441    0.7988   -0.0119
   -1.0551   -0.4048    0.6322   -0.2716   -0.0652    0.5923   -0.9039
   -0.4383    1.1600   -0.5307   -0.2200   -0.7026   -0.0309    0.4819
    0.7237   -1.0182   -0.4602   -0.6953   -0.3437    0.5771    0.6972
   -0.6133   -0.3200   -0.0853    0.3476    0.1530    0.4782    0.9597
   -0.6471    1.0909    0.1917    0.6902   -0.1175   -0.2533   -1.2189
    0.3614   -0.6029    0.0237   -1.4579   -0.7253    0.6867   -0.5887
   -0.2655   -0.6340    0.2827   -0.7155   -0.4540    1.0812   -0.3331

  Columns 8 through 9

   -1.9839    0.3631
   -1.8753   -0.3619
   -0.6597   -0.4457
   -0.6175    0.6516
   -0.7353    0.0525
   -0.9051   -0.0375
   -0.1694   -0.7943
   -1.8883    0.0211
   -0.6463   -0.6177

 
B [9x2] = 
 
   -0.1950    0.1173
   -0.6804   -0.1330
    0.2484    0.8463
   -0.2721   -1.0088
    0.0042   -0.2183
   -0.3025    2.0736
   -0.6414    0.9666
   -1.6839    0.6606
    0.2164   -0.0616

 
C [3x9] = 
 
  Columns 1 through 7

    0.1422   -0.3378    0.1971   -0.5098    0.0441   -0.4651   -0.3756
    1.5335   -0.8053    1.3047   -0.9906    0.6754    0.1004   -1.1887
    0.3162    0.6132    0.4366    0.7592    0.6316   -0.0773   -0.0353

  Columns 8 through 9

   -0.2195    0.0869
    0.4146    0.8364
    0.2100    0.3036

 
D [3x2] = 
 
     0     0
     0     0
     0     0

 

Compute the uncontrollable eigenvalues

Check wether the system is stabilisable.

Cn = ctrb(A,B);

[U,Sigma,V] = svd(Cn);

T = U';

A_Ctrb_Staircase = round(T*A*T',10)
B_Ctrb_Staircase = round(T*B,10)

k = c+d-1;
A_Unctrb = A_Ctrb_Staircase(end-k:end,end-k:end)

Uncontrollable_Eigenvalues = eig(A_Unctrb)

Check wether the system is detectable.

On = obsv(A,C);

[U,Sigma,V] = svd(On);

T = V';

A_Obsv_Staircase = round(T*A*T',10)
C_Obsv_Staircase = round(C*T',10)

k = b+d-1;
A_Unobsv = A_Obsv_Staircase(end-k:end,end-k:end)

Unobservable_Eigenvalues = eig(A_Unobsv)
Output:
A_Ctrb_Staircase =

  Columns 1 through 7

   -2.0455   -0.4262    2.6091   -2.5460   -1.6275    1.9781   -0.3326
    0.0024   -0.3403    1.1716    0.0599    0.1856   -0.2883   -1.0109
   -0.0008    0.6713    0.1646    1.2267    0.4327   -1.3781    0.8142
    0.0002   -0.0091    0.0141   -0.4884   -0.0999   -1.3248   -0.6121
   -0.0007    0.1879    0.0065   -0.1890   -0.6261    0.6130    0.5874
    0.0001   -0.0500    0.0117    0.0075    0.0585    0.1515    0.0711
         0         0         0         0         0         0   -0.2659
         0         0         0         0         0         0    0.1487
         0         0         0         0         0         0   -0.3722

  Columns 8 through 9

   -0.6745   -1.0431
   -1.0971    0.6241
    1.0481    0.2289
    0.0626   -0.9662
   -1.4221    0.6277
    0.3063    0.1266
   -0.8613    0.5724
    0.0038    0.1983
    0.2720   -1.3514


B_Ctrb_Staircase =

   -0.9896    1.1768
    0.0256   -0.5689
    0.1923    1.3809
   -1.4677    0.3477
   -0.9060    0.0691
   -0.1731    1.9355
         0         0
         0         0
         0         0


A_Unctrb =

   -0.2659   -0.8613    0.5724
    0.1487    0.0038    0.1983
   -0.3722    0.2720   -1.3514


Uncontrollable_Eigenvalues =

   -1.0807
   -0.3462
   -0.1866


A_Obsv_Staircase =

  Columns 1 through 7

   -2.0457   -0.0012    0.0004    0.0001    0.0000         0         0
    1.5594   -0.3092    0.2883    0.0646    0.0157         0         0
   -2.8119    2.4336    0.2847    0.0585    0.0029         0         0
    0.9918   -1.3934    0.8955   -0.1435   -0.1645         0         0
   -2.2451    1.0432   -1.7931   -0.3435    0.0100         0         0
    0.4903   -0.0436   -0.1690   -0.2983   -0.1739   -0.4915    0.1358
    0.0500    1.0218    0.1962   -0.0520    0.1103   -0.9700   -1.1370
   -0.3120    0.6560   -0.3933   -0.6671   -0.6981    1.1783   -0.0090
    0.0710    0.1490   -0.1659   -0.2785   -0.2498    1.7491    0.4581

  Columns 8 through 9

         0         0
         0         0
         0         0
         0         0
         0         0
   -0.0309    0.3837
   -0.0795   -0.7095
   -0.2954   -0.8172
    0.1230   -0.6700


C_Obsv_Staircase =

  Columns 1 through 7

   -0.3458    0.2315    0.4981   -0.1520   -0.6355         0         0
   -0.1624    1.1215    2.3569   -1.2628    0.0287         0         0
    0.7369   -0.5872    0.1117   -0.8838    0.3227         0         0

  Columns 8 through 9

         0         0
         0         0
         0         0


A_Unobsv =

   -0.4915    0.1358   -0.0309    0.3837
   -0.9700   -1.1370   -0.0795   -0.7095
    1.1783   -0.0090   -0.2954   -0.8172
    1.7491    0.4581    0.1230   -0.6700


Unobservable_Eigenvalues =

   -1.0807
   -0.9322
   -0.1866
   -0.3944

Compute a stabilising static state feedback gain with LMI

Q = sdpvar(n,n,'symmetric');
N = sdpvar(m,n,'full');

CONS = [
    Q - 0.01*eye(n) >= 0
    Q*A' + A*Q - B*N - N'*B' + 0.01*eye(n) <= 0
    ];

sol = optimize(CONS)

Q = double(Q);
N = double(N);
P = inv(Q);
K = N/Q;

Check solution

Eigenvalues_of_the_closed_loop = eig(A - B*K)
Output:
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 63              
  Cones                  : 0               
  Scalar variables       : 0               
  Matrix variables       : 2               
  Integer variables      : 0               

Optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator - tries                  : 0                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 0.00    
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 63              
  Cones                  : 0               
  Scalar variables       : 0               
  Matrix variables       : 2               
  Integer variables      : 0               

Optimizer  - threads                : 4               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 63
Optimizer  - Cones                  : 0
Optimizer  - Scalar variables       : 0                 conic                  : 0               
Optimizer  - Semi-definite variables: 2                 scalarized             : 90              
Factor     - setup time             : 0.00              dense det. time        : 0.00            
Factor     - ML order time          : 0.00              GP order time          : 0.00            
Factor     - nonzeros before factor : 2016              after factor           : 2016            
Factor     - dense dim.             : 0                 flops                  : 2.16e+05        
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   1.4e+00  1.0e+00  8.2e-01  0.00e+00   -1.800000000e-01  0.000000000e+00   1.0e+00  0.00  
1   2.4e-01  1.7e-01  2.9e-01  8.99e-01   -7.434373035e-02  0.000000000e+00   1.7e-01  0.01  
2   4.8e-02  3.5e-02  1.0e-01  7.24e-01   -3.471435471e-02  0.000000000e+00   3.4e-02  0.01  
3   4.9e-03  3.5e-03  3.6e-02  8.91e-01   -2.143662557e-03  0.000000000e+00   3.5e-03  0.01  
4   3.3e-07  2.4e-07  2.8e-04  9.89e-01   -2.078577969e-07  0.000000000e+00   2.3e-07  0.01  
5   6.1e-13  4.3e-13  3.4e-13  1.00e+00   -7.033482389e-13  0.000000000e+00   4.9e-13  0.01  
Optimizer terminated. Time: 0.02    


Interior-point solution summary
  Problem status  : PRIMAL_AND_DUAL_FEASIBLE
  Solution status : OPTIMAL
  Primal.  obj: -7.0334823890e-13   nrm: 2e-11    Viol.  con: 3e-12    barvar: 0e+00  
  Dual.    obj: 0.0000000000e+00    nrm: 3e+00    Viol.  con: 0e+00    barvar: 6e-13  
Optimizer summary
  Optimizer                 -                        time: 0.02    
    Interior-point          - iterations : 5         time: 0.01    
      Basis identification  -                        time: 0.00    
        Primal              - iterations : 0         time: 0.00    
        Dual                - iterations : 0         time: 0.00    
        Clean primal        - iterations : 0         time: 0.00    
        Clean dual          - iterations : 0         time: 0.00    
    Simplex                 -                        time: 0.00    
      Primal simplex        - iterations : 0         time: 0.00    
      Dual simplex          - iterations : 0         time: 0.00    
    Mixed integer           - relaxations: 0         time: 0.00    


sol = 

  struct with fields:

    yalmiptime: 0.2342
    solvertime: 0.0328
          info: 'Successfully solved (MOSEK)'
       problem: 0


Eigenvalues_of_the_closed_loop =

  -0.8361 + 5.5836i
  -0.8361 - 5.5836i
  -0.5299 + 0.8968i
  -0.5299 - 0.8968i
  -0.1866 + 0.0000i
  -0.3462 + 0.0000i
  -0.4264 + 0.0000i
  -1.0807 + 0.0000i
  -0.9181 + 0.0000i