-
Notifications
You must be signed in to change notification settings - Fork 1
/
fill_edp_structs.m
69 lines (49 loc) · 1.74 KB
/
fill_edp_structs.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [mdlstruct,optstruct,dpstruct]=fill_edp_structs(mdlstruct,dpstruct)
% FILL_EDP_STRUCTS Complete the structures by adding default options if
% needed, and prepare additionnal parameters required for the computation.
% [MDLSTRUCT,OPTSTRUCT,DPSTRUCT]=FILL_EDP_STRUCTS(MDLSTRUCT,OPTSTRUCT,DPSTRUCT)
% Several fields are filled with default options in the structure
% containing the data information MDLSTRUCT, the optimal control problem
% structure OPTSTRUCT and the approximated dynamic programming method
% structure DPSTRUCT.
%% Model Structure
if isfield(dpstruct,'data')
mdlstruct.n_dim = size(mdlstruct.data,2);
else
if isfield(dpstruct,'name')
mdlstruct.n_dim = length(mdlstruct.name);
end
end
%% Optimal control Structure
%% Dynamic programming Structure
if ~isfield(dpstruct,'method')
dpstruct.method = 'td';
end
if ~isfield(dpstruct,'n_support_states')
% number of support states
dpstruct.n_support_states=50;
end
if dpstruct.method == 'td' & ~isfield(dpstruct,'generating_support_states_method')
% How to generate the support states used here
% 'random' -> randomely generated
% 'grid' -> create a grid of support states (number of points on each dimension equal to dpstruct.nb_support_states^(1/n) (round to lower))
dpstruct.generating_support_states_method = 'random';
dpstruct = generate_support_states(mdlstruct,dpstruct);
end
if ~isfield(dpstruct,'lambda')
% TD lambda parameter
dpstruct.lambda=0.5;
end
if ~isfield(dpstruct,'n_out_max')
% outer loop number of iterations
dpstruct.n_out_max = 20;
end
if ~isfield(dpstruct,'n_in_max')
% inner loop number of iterations
dpstruct.n_in_max = 5;
end
if ~isfield(dpstruct,'debug')
% debug mode with additionnal display during the computation
dpstruct.debug = 0;
end
end