-
Notifications
You must be signed in to change notification settings - Fork 3
/
examplesForTAC.m
153 lines (117 loc) · 3.99 KB
/
examplesForTAC.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
% This is the script used to run the testcases for qqr and NST
% as well as closed-loop simulations that were reported in
%
% Borggaard and Zietsman, The Quadratic-Quadratic Regulator
% IEEE Transactions on Automatic Control (submitted).
% - testcases 3, 4, 5, and 6.
%
% testcase 3 - random, stable quadratic system
%
% testcase 4 - Lorenz equations
%
% testcase 5 - Burgers equation
%
% testcase 6 - simple first-order problem
%
% testcase 8 - connected van der Pol oscillators
%
% if testNST==true
% - solutions from NST are provided in the ka and py arrays.
%
% if testAlbrekhtQQR==true
% - solutions from qqr are provided in the kk and vv arrays.
%
% if testAlbrekhtKronQQR==true
% - solutions from AlbrekhtKronQQR are provided in the k and v arrays.
% - this can require a lot of memory and CPU time, so keep n, m, and the
% degree variables small.
%
% Part of the QQR library.
%%
setKroneckerToolsPath
% Set up test examples, problem dimensions (order), and degree of feedback
addpath('./examples')
testcase = 7;
% Flag those methods used for the current test (NST is reqd for errors)
testNST = false;
testFull = false;
if ( testcase==1 )
%%
% For the ACC submission, we chose n=6:2:20, m=1, degree=2:4
% the full Kronecker solution wasn't calculated for 16:2:20
n = 6; % state dimension
m = 2; % control dimension
degree = 5; % degree of optimal feedback
[A,B,Q,R,N] = example01(n,m);
tic
[k,v] = qqr(A,B,Q,R,N,degree);
compQQR = toc;
fprintf('\n');
fprintf(' qqr solution required %g seconds\n\n',compQQR);
elseif ( testcase==2 )
%%
% For the ACC submission, we chose n=10:2:20, m=2, degree=2:3
% the full Kronecker solution wasn't calculated for 16:2:20
n = 8; % state dimension
m = 2; % control dimension
degree = 5; % degree of optimal feedback
[A,B,Q,R,N,zInit] = example02(n,m);
tic
[k,v] = qqr(A,B,Q,R,N,degree);
compQQR = toc;
fprintf('\n');
fprintf(' qqr solution required %g seconds\n\n',compQQR);
elseif ( testcase==3 )
%%
% For the TAC submission, we chose n=10:2:20, m=2, degree=2:3
% the full Kronecker solution wasn't calculated
n = 8; % state dimension
m = 2; % control dimension
degree = 4; % degree of optimal feedback
[A,B,Q,R,N] = example03(n,m);
tic
[k,v] = qqr(A,B,Q,R,N,degree);
compQQR = toc;
fprintf('\n');
fprintf(' qqr solution required %g seconds\n\n',compQQR);
elseif ( testcase==4 )
%%
% Test the QQR algorithm on a well-known low-dimensional problem (Lorenz)
%
% This example calls qqr internally and n=3,m=1 must be specified as the
% problem dimensions for the runNSTcomparisons script.
n = 3; % state dimension
m = 1; % control dimension
degree = 5; % degree of optimal feedback
example04
elseif ( testcase==5 )
%%
% A Burgers equation example with closed-loop simulations and a better
% change of variable to remove the mass matrix.
n = 8; % state dimension
m = 2; % control dimension
degree = 5; % degree of optimal feedback
example05
elseif ( testcase==6 )
% A one-dimensional example where we also compute the stabilizability
% radius.
n = 8; % state dimension
m = 2; % control dimension
degree = 5; % degree of optimal feedback
example06
elseif ( testcase==7 )
example07
elseif ( testcase==8 )
% A ring of van der Pol oscillators to test feedback controls in a system
% with a cubic nonlinearity.
No = 4; % number of van der Pol oscillators ( n=2*No )
m = 2; % control dimension
degree = 5; % degree of optimal feedback
example08
elseif ( testcase==9 )
% Comparison to a published example.
example09
end
if ( testNST )
runNSTcomparisons
end