-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDynOpt4.m
45 lines (34 loc) · 939 Bytes
/
DynOpt4.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
% Dynamic Optimization
% (eventually with uncertain parameters & shocks)
% By Andrew Fritz
% Title: DynOpt4.m
% Functions exactly like qlpabel.m
t = 7;
a = [0.914 -0.016;
0.097 0.424];
b = [0.305 0.424;
-0.101 1.459];
c = [-59.437;
-184.766];
x0 = [387.9;
85.3];
sum = 0;
k = 0;
nn = 0;
xold = x0;
n = 2; m = 2;
u2 = zeros(m,t+1);
x2 = zeros(n,t+1);
while nn <= t-1;
[x2,u2,sum,xold] = abel4(a, b, c, k, t, x2, u2, n, m, xold, sum);
k = k + 1;
nn = nn + 1;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Print the solution
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u2 = u2'; % The optimal control vector
%u2
x2 = x2'; % The optimal state vector
%x2
Criterion = sum % The value of the criterion function