rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
detailed_simulation.m
1 function sim_data = detailed_simulation(model, model_data)
2 % DETAILED_SIMULATION
3 % Perform a detailed simulation, i.e. a high-dimensional solve of the DARE.
4 %
5 
6 sim_data = DARE.SimData;
7 
8 [E,A,B,C,Q,R] = model.assemble(model_data);
9 
10 t = tic;
11 if exist('LowRankDARE.m', 'file') && model.n > 30
12  sim_data.Z = LowRankDARE(E,A, B, C, Q, R);
13 else
14  if model.n > 100
15  warning('Using MATLAB solver dare. This can be slow for large dimensions.')
16  end
17 
18  [P,~,~] = dare(full(A), full(B), full(C'*Q*C), full(R), [], full(E));
19  sim_data.P = P;
20 
21  [V,D] = svd(sim_data.P, 'econ');
22  D = sqrt(diag(D));
23  s = sum(D);
24 
25  for k = 1:length(D)
26  if sum(D(1:k))/s>1-1e-7, break; end
27  end
28 
29  sim_data.Z = real(V*diag(D));
30  sim_data.Z = sim_data.Z(:, 1:k);
31 end
32 sim_data.time = toc(t);
33 sim_data.K = (R + B'*sim_data.Z*sim_data.Z'*B)\B'*sim_data.Z*sim_data.Z'*A;
Implementation of the parametric discrete-time algebraic Riccati equation.
Definition: Kernel.m:1