rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
riccati_detailed_simulation.m
Go to the documentation of this file.
1 function sim_data = riccati_detailed_simulation(model, model_data)
2 % sim_data = riccati_detailed_simulation(model, model_data)
3 %
4 % Calculate the full solution for a given problem. This function relies on
5 % the M.E.S.S. package from the MPI!
6 %
7 % sim_data is a structure containing the following information
8 % Z ..................... The low rank factor, P = Z Z'
9 sim_data = {};
10 [E,A,B,C] = riccati_assemble_system_matrices(model, model_data);
11 
12 if ~exist('lrcf_nm_g_r3', 'function')
13  R = eye(size(B,2));
14  warning(['The function lrcf_nm_g_r3 could not be found. ', ...
15  '"care" will be used which can result in very poor performance!'])
16  sim_data.P = care(full(A),full(B),full(C'*C),full(R),full(B*0),full(E));
17 
18  % Calculate the low rank factor:
19  [V,D] = eigs(sim_data.P, size(A,1)-1);
20  sim_data.Z = real(V*sqrt(D));
21  sim_data.Z(:, find(diag(sqrt(D)) < sqrt(eps))) = [];
22 else
23  K0 = [];
24  if isfield(model_data, 'K_in')
25  K0 = model_data.K_in';
26  end
27 
28  maxnm = 100;
29  maxadi = 200;
30 
31  warning('off','all')
32  [Z,~,nmiter,adimax,rc,res_norm] = lrcf_nm_g_r3(A,B,C,E,K0,maxnm,maxadi);
33  warning('on','all');
34  solver_info.res_norm = res_norm;
35  solver_info.rc = rc;
36  solver_info.adimax = adimax;
37  solver_info.nmiter = nmiter;
38  sim_data.solver_info = solver_info;
39  sim_data.Z = real(Z);
40 end
function [ E , A , B , C , x0 ] = riccati_assemble_system_matrices(model, model_data)
model_data)
function sim_data = riccati_detailed_simulation(model, model_data)
sim_data = riccati_detailed_simulation(model, model_data)