forked from zhengy09/distributed_design_methods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounterExample.m
57 lines (33 loc) · 788 Bytes
/
CounterExample.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%% Counter example
% a decentralized controller exists for a full Lyapunov function
% but a decentralized controller fails for a diagonal Lyapunov function
clc;clear
n = 3;
A = rand(n);
A = A - (0.01+max(real(eig(A))))*eye(n);
Q = 10*eye(n)
X = lyap(A',Q)
eig(X)
A'*X + X*A
A = [1 2; -1 0.5]
B = [0 0;0 1]
K = [0 0; 0 2]
A - B*K
eig(A - B*K)
X = [];
Z = [];
for i = 1:2
X = blkdiag(X,sdpvar(1));
Z = blkdiag(Z,sdpvar(1));
end
Objective = 0;
epsilon = 1e-2;
Constraint = [(A*X - B*Z) + (A*X - B*Z)' + epsilon*eye(2)<=0, X- epsilon *eye(2) >= 0];
options = sdpsettings('solver','sedumi');
sol = optimize(Constraint,Objective,options);
K1 = value(Z)*value(X)^(-1);
K2 = K;
K2(2,2) = K1(2,2)
eig(A - B*K2)
X1 = sdpvar(1);X2 = sdpvar(1);
Z2 = sdpvar(1);