1 function sim_data = detailed_simulation(model, model_data)
4 % Calculate the full solution
for a given problem. This
function relies on
5 % the M.E.S.S.
package from the MPI!
7 % sim_data is a structure containing the following information
8 % Z ..................... The low rank factor, P = Z Z'
9 % time .................. Time for the solve
11 % Andreas Schmidt, 2015
12 sim_data = ARE.SimData;
15 % Assemble the matrices:
16 [E,A,B,C,Q,R] = model.assemble(model_data);
18 if ~exist(
'mess_care',
'file') || model.descr.n < 100 || numel(find(real(eig(R))<0))>0
19 if model.descr.n >= 100
20 warning([
'The function mess_care could not be found. ', ...
21 '"care" will be used which can result in very poor performance! ', ...
22 'Please consider downloading the M.E.S.S. package from ', ...
23 'http://www.mpi-magdeburg.mpg.de/projects/mess.'])
26 sim_data.
P = care(full(A),full(B),full(C'*Q*C),full(R),full(B*0),full(E));
28 % Calculate the low rank factor
29 [V,D] = eigs(sim_data.
P, min(500,size(A,1)));
31 sim_data.
Z = real(V*sqrt(D));
32 sim_data.
Z(:, find(diag(sqrt(D)) <= 1e-10)) = [];
35 if isfield(model_data, 'K_in')
36 K0 = model_data.K_in';
43 Rsqrt = sqrtm(inv(R));
46 [Z,~] = mess_care(A,B*Rsqrt,Qsqrt*C,[],E);
51 sim_data.time = toc(t);
52 sim_data.
K = -inv(R)*((B'*sim_data.Z)*sim_data.Z')*E;
Z
Low rank factor of the solution.
function sim_data = riccati_detailed_simulation(model, model_data)
sim_data = riccati_detailed_simulation(model, model_data)
P
If the problem was small, we also store the full solution.