1 function sim_data = detailed_simulation(model, model_data)
3 % Perform a detailed simulation, i.e. a high-dimensional solve of the
DARE.
8 [E,A,B,C,Q,R] = model.assemble(model_data);
11 if exist(
'LowRankDARE.m',
'file') && model.n > 30
12 sim_data.Z = LowRankDARE(E,A, B, C, Q, R);
15 warning(
'Using MATLAB solver dare. This can be slow for large dimensions.')
18 [P,~,~] = dare(full(A), full(B), full(C'*Q*C), full(R), [], full(E));
21 [V,D] = svd(sim_data.P, 'econ');
26 if sum(D(1:k))/s>1-1e-7, break; end
29 sim_data.Z = real(V*diag(D));
30 sim_data.Z = sim_data.Z(:, 1:k);
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.