source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/demos/decayex.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.4 KB
Line 
1clc
2echo on
3%*********************************************************
4%
5% Advanced YALMIP modeling, generalized eigenvalue problem
6%
7%*********************************************************
8%
9% The problem we solve here is estimatation of decay-rate
10% of a linear system x' = Ax.
11%
12% This can be formulated as
13%
14% max alpha
15% s.t A'P+PA < -2alphaP
16%          P > I
17%
18pause
19
20% Define the variables
21A = [-1 2;-3 -4];
22P = sdpvar(2,2);
23pause
24
25 %To find a lower bound on alpha, we solve a standard Lyapunov stability problem.
26F = set(P>eye(2))+set(A'*P+P*A < -eye(2));
27pause
28solvesdp(F,trace(P));
29P0 = double(P)
30pause
31
32%For this particular solution, the decay-rate is
33alpha_lower = -max(eig(inv(P0)*(A'*P0+P0*A)))/2
34pause
35
36% We now find an upper bound on the decay-rate by doubling alpha until
37% the problem is infeasible. To find out if the problem is infeasible,
38% we check the problem field in the solution structure. The
39% meaning of this variable is explained in the help text for the command
40% yalmiperror. Infeasibility is detected if the value is 1. To
41% reduce the amount of information written on the screen, we run the
42% solver in a completely silent mode. This can be accomplished by
43% using the verbose and warning options in sdpsettings.
44%
45% Note, on some solvers, just checking infeasibility flag is not enough. A
46% more careful bisection code should check also for numerical problems that
47% could indicate infeasibility
48pause
49
50options = sdpsettings('verbose',0,'warning',0);
51alpha_upper = alpha_lower*2;
52F = set(P>eye(2))+set(A'*P+P*A < -2*alpha_upper*P);
53sol = solvesdp(F,[],options);
54while ~(sol.problem==1)
55  alpha_upper = alpha_upper*2;
56  F = set(P>eye(2))+set(A'*P+P*A < -2*alpha_upper*P);
57  sol = solvesdp(F,trace(P),options);
58end
59alpha_upper
60pause
61
62% Having both an upper bound and a lower bound allows us to perform a
63% bisection. (see code in decayex.m)
64pause
65echo off
66
67tol = 0.01;
68alpha_works = alpha_lower;
69clc
70disp('################################');
71disp('#   Lower     Upper     Current');
72disp('################################');
73while (alpha_upper-alpha_lower)>tol
74  alpha_test = (alpha_upper+alpha_lower)/2;
75  disp([alpha_lower alpha_upper alpha_test])
76  F = set(P>eye(2))+set(A'*P+P*A < -2*alpha_test*P);
77  sol = solvesdp(F,trace(P),options);
78  if sol.problem==1
79    alpha_upper = alpha_test;
80  else
81    alpha_lower = alpha_test;
82    alpha_works = alpha_test;
83  end
84end
85
86
87% A lower bound on the optimal value is thus
88alpha_works
89pause
90echo off
Note: See TracBrowser for help on using the repository browser.