time | Calls | line |
---|
| | 7 | function result_map = ff_ipwkz_vf(varargin)
|
| | 8 | %% FF_IPWKZ_VF solve infinite horizon exo shock + endo asset problem
|
| | 9 | % This program solves the infinite horizon dynamic savings and risky
|
| | 10 | % capital asset problem. This is the two step solution
|
| | 11 | % with interpolation and with percentage asset grids version of
|
| | 12 | % <https://fanwangecon.github.io/CodeDynaAsset/m_akz/solve/html/ff_akz_vf.html
|
| | 13 | % ff_akz_vf>. See
|
| | 14 | % <https://fanwangecon.github.io/CodeDynaAsset/m_akz/solve/html/ff_wkz_vf.html
|
| | 15 | % ff_wkz_vf> for details about the second stage. See
|
| | 16 | % <https://fanwangecon.github.io/CodeDynaAsset/m_akz/solve/html/ff_iwkz_vf.html
|
| | 17 | % ff_iwkz_vf> for details about interpolation over u(c) and value(coh,z).
|
| | 18 | % The new ingredient here is the use of percentage choice grid rather than
|
| | 19 | % level choice grid. This is the looped code.
|
| | 20 | %
|
| | 21 | % @param param_map container parameter container
|
| | 22 | %
|
| | 23 | % @param support_map container support container
|
| | 24 | %
|
| | 25 | % @param armt_map container container with states, choices and shocks
|
| | 26 | % grids that are inputs for grid based solution algorithm
|
| | 27 | %
|
| | 28 | % @param func_map container container with function handles for
|
| | 29 | % consumption cash-on-hand etc.
|
| | 30 | %
|
| | 31 | % @return result_map container contains policy function matrix, value
|
| | 32 | % function matrix, iteration results, and policy function, value function
|
| | 33 | % and iteration results tables.
|
| | 34 | %
|
| | 35 | % keys included in result_map:
|
| | 36 | %
|
| | 37 | % * mt_val matrix states_n by shock_n matrix of converged value function grid
|
| | 38 | % * mt_pol_a matrix states_n by shock_n matrix of converged policy function grid
|
| | 39 | % * ar_val_diff_norm array if bl_post = true it_iter_last by 1 val function
|
| | 40 | % difference between iteration
|
| | 41 | % * ar_pol_diff_norm array if bl_post = true it_iter_last by 1 policy
|
| | 42 | % function difference between iterations
|
| | 43 | % * mt_pol_perc_change matrix if bl_post = true it_iter_last by shock_n the
|
| | 44 | % proportion of grid points at which policy function changed between
|
| | 45 | % current and last iteration for each element of shock
|
| | 46 | %
|
| | 47 | % @example
|
| | 48 | %
|
| | 49 | % @include
|
| | 50 | %
|
| | 51 | % * <https://github.com/FanWangEcon/CodeDynaAsset/blob/master/m_ipwkz/paramfunc/ff_ipwkz_evf.m ff_ipwkz_evf>
|
| | 52 | % * <https://github.com/FanWangEcon/CodeDynaAsset/blob/master/m_ipwkz/paramfunc/ffs_ipwkz_set_default_param.m ffs_ipwkz_set_default_param>
|
| | 53 | % * <https://github.com/FanWangEcon/CodeDynaAsset/blob/master/m_ipwkz/paramfunc/ffs_ipwkz_get_funcgrid.m ffs_ipwkz_get_funcgrid>
|
| | 54 | % * <https://github.com/FanWangEcon/CodeDynaAsset/blob/master/m_akz/solvepost/ff_akz_vf_post.m ff_akz_vf_post>
|
| | 55 | %
|
| | 56 |
|
| | 57 | %% Default
|
| | 58 | % * it_param_set = 1: quick test
|
| | 59 | % * it_param_set = 2: benchmark run
|
| | 60 | % * it_param_set = 3: benchmark profile
|
| | 61 | % * it_param_set = 4: press publish button
|
| | 62 |
|
| | 63 | it_param_set = 3;
|
| | 64 | bl_input_override = true;
|
| | 65 | [param_map, support_map] = ffs_ipwkz_set_default_param(it_param_set);
|
| | 66 |
|
| | 67 | % parameters can be set inside ffs_ipwkz_set_default_param or updated here
|
| | 68 | param_map('it_w_perc_n') = 10;
|
| | 69 | % param_map('it_ak_perc_n') = param_map('it_w_perc_n');
|
| | 70 | param_map('it_z_n') = 5;
|
| | 71 | % param_map('fl_coh_interp_grid_gap') = 0.025;
|
| | 72 | % param_map('it_c_interp_grid_gap') = 0.001;
|
| | 73 | % param_map('fl_w_interp_grid_gap') = 0.25;
|
| | 74 | % param_map('it_w_perc_n') = 100;
|
| | 75 | % param_map('it_ak_perc_n') = param_map('it_w_perc_n');
|
| | 76 | % param_map('it_z_n') = 11;
|
| | 77 | param_map('fl_coh_interp_grid_gap') = 0.5;
|
| | 78 | % param_map('it_c_interp_grid_gap') = 10^-4;
|
| | 79 | param_map('fl_w_interp_grid_gap') = 0.5;
|
| | 80 |
|
| | 81 | % get armt and func map
|
| | 82 | [armt_map, func_map] = ffs_ipwkz_get_funcgrid(param_map, support_map, bl_input_override); % 1 for override
|
| | 83 | default_params = {param_map support_map armt_map func_map};
|
| | 84 |
|
| | 85 | %% Parse Parameters 1
|
| | 86 |
|
| | 87 | % if varargin only has param_map and support_map,
|
| | 88 | params_len = length(varargin);
|
| | 89 | [default_params{1:params_len}] = varargin{:};
|
| | 90 | param_map = [param_map; default_params{1}];
|
| | 91 | support_map = [support_map; default_params{2}];
|
| | 92 | if params_len >= 1 && params_len <= 2
|
| | 93 | % If override param_map, re-generate armt and func if they are not
|
| | 94 | % provided
|
| | 95 | bl_input_override = true;
|
| | 96 | [armt_map, func_map] = ffs_ipwkz_get_funcgrid(param_map, support_map, bl_input_override);
|
| | 97 | else
|
| | 98 | % Override all
|
| | 99 | armt_map = [armt_map; default_params{3}];
|
| | 100 | func_map = [func_map; default_params{4}];
|
| | 101 | end
|
| | 102 |
|
| | 103 | % append function name
|
| | 104 | st_func_name = 'ff_ipwkz_vf';
|
| | 105 | support_map('st_profile_name_main') = [st_func_name support_map('st_profile_name_main')];
|
| | 106 | support_map('st_mat_name_main') = [st_func_name support_map('st_mat_name_main')];
|
| | 107 | support_map('st_img_name_main') = [st_func_name support_map('st_img_name_main')];
|
| | 108 |
|
| | 109 | %% Parse Parameters 2
|
| | 110 |
|
| | 111 | % armt_map
|
| | 112 | params_group = values(armt_map, {'ar_w_perc', 'ar_w_level', 'ar_z'});
|
| | 113 | [ar_w_perc, ar_w_level, ar_z] = params_group{:};
|
| | 114 | params_group = values(armt_map, {'ar_interp_c_grid', 'ar_interp_coh_grid', ...
|
| | 115 | 'mt_interp_coh_grid_mesh_z', 'mt_z_mesh_coh_interp_grid',...
|
| | 116 | 'mt_w_by_interp_coh_interp_grid'});
|
| | 117 | [ar_interp_c_grid, ar_interp_coh_grid, ...
|
| | 118 | mt_interp_coh_grid_mesh_z, mt_z_mesh_coh_interp_grid, ...
|
| | 119 | mt_w_by_interp_coh_interp_grid] = params_group{:};
|
| | 120 | params_group = values(armt_map, {'mt_coh_wkb', 'mt_z_mesh_coh_wkb'});
|
| | 121 | [mt_coh_wkb, mt_z_mesh_coh_wkb] = params_group{:};
|
| | 122 |
|
| | 123 | % func_map
|
| | 124 | params_group = values(func_map, {'f_util_log', 'f_util_crra', 'f_cons'});
|
| | 125 | [f_util_log, f_util_crra, f_cons] = params_group{:};
|
| | 126 |
|
| | 127 | % param_map
|
| | 128 | params_group = values(param_map, {'it_z_n', 'fl_crra', 'fl_beta', 'fl_c_min'});
|
| | 129 | [it_z_n, fl_crra, fl_beta, fl_c_min] = params_group{:};
|
| | 130 | params_group = values(param_map, {'it_maxiter_val', 'fl_tol_val', 'fl_tol_pol', 'it_tol_pol_nochange'});
|
| | 131 | [it_maxiter_val, fl_tol_val, fl_tol_pol, it_tol_pol_nochange] = params_group{:};
|
| | 132 |
|
| | 133 | % support_map
|
| | 134 | params_group = values(support_map, {'bl_profile', 'st_profile_path', ...
|
| | 135 | 'st_profile_prefix', 'st_profile_name_main', 'st_profile_suffix',...
|
| | 136 | 'bl_time', 'bl_graph_evf', 'bl_display', 'it_display_every', 'bl_post'});
|
| | 137 | [bl_profile, st_profile_path, ...
|
| | 138 | st_profile_prefix, st_profile_name_main, st_profile_suffix, ...
|
| | 139 | bl_time, bl_graph_evf, bl_display, it_display_every, bl_post] = params_group{:};
|
| | 140 |
|
| | 141 | %% Initialize Output Matrixes
|
| | 142 |
|
| | 143 | mt_val_cur = zeros(length(ar_interp_coh_grid),length(ar_z));
|
| | 144 | mt_val = mt_val_cur - 1;
|
| | 145 | mt_pol_a = zeros(length(ar_interp_coh_grid),length(ar_z));
|
| | 146 | mt_pol_a_cur = mt_pol_a - 1;
|
| | 147 | mt_pol_k = zeros(length(ar_interp_coh_grid),length(ar_z));
|
| | 148 | mt_pol_k_cur = mt_pol_k - 1;
|
| | 149 |
|
| | 150 | %% Initialize Convergence Conditions
|
| | 151 |
|
| | 152 | bl_vfi_continue = true;
|
| | 153 | it_iter = 0;
|
| | 154 | ar_val_diff_norm = zeros([it_maxiter_val, 1]);
|
| | 155 | ar_pol_diff_norm = zeros([it_maxiter_val, 1]);
|
| | 156 | mt_pol_perc_change = zeros([it_maxiter_val, it_z_n]);
|
| | 157 |
|
| | 158 | %% Pre-calculate u(c)
|
| | 159 | % Interpolation, see
|
| | 160 | % <https://fanwangecon.github.io/M4Econ/support/speed/partupdate/fs_u_c_partrepeat_main.html
|
| | 161 | % fs_u_c_partrepeat_main> for why interpolate over u(c)
|
| | 162 |
|
| | 163 | % Evaluate
|
| | 164 | if (fl_crra == 1)
|
| | 165 | ar_interp_u_of_c_grid = f_util_log(ar_interp_c_grid);
|
| | 166 | fl_u_neg_c = f_util_log(fl_c_min);
|
| | 167 | else
|
| | 168 | ar_interp_u_of_c_grid = f_util_crra(ar_interp_c_grid);
|
| | 169 | fl_u_neg_c = f_util_crra(fl_c_min);
|
| | 170 | end
|
| | 171 | ar_interp_u_of_c_grid(ar_interp_c_grid <= fl_c_min) = fl_u_neg_c;
|
| | 172 |
|
| | 173 | % Get Interpolant
|
| | 174 | f_grid_interpolant_spln = griddedInterpolant(ar_interp_c_grid, ar_interp_u_of_c_grid, 'spline');
|
| | 175 |
|
| | 176 | %% Iterate Value Function
|
| | 177 | % Loop solution with 4 nested loops
|
| | 178 | %
|
| | 179 | % # loop 1: over exogenous states
|
| | 180 | % # loop 2: over endogenous states
|
| | 181 | % # loop 3: over choices
|
| | 182 | % # loop 4: add future utility, integration--loop over future shocks
|
| | 183 | %
|
| | 184 |
|
| | 185 | % Start Profile
|
| | 186 | if (bl_profile)
|
| | 187 | close all;
|
| | 188 | profile off;
|
| | 189 | profile on;
|
< 0.001 | 1 | 190 | end
|
| | 191 |
|
| | 192 | % Start Timer
|
< 0.001 | 1 | 193 | if (bl_time)
|
< 0.001 | 1 | 194 | tic;
|
< 0.001 | 1 | 195 | end
|
| | 196 |
|
| | 197 | % Value Function Iteration
|
< 0.001 | 1 | 198 | while bl_vfi_continue
|
< 0.001 | 75 | 199 | it_iter = it_iter + 1;
|
| | 200 |
|
| | 201 | %% Interpolate (1) reacahble v(coh(k(w,z),b(w,z),z),z) given v(coh, z)
|
| | 202 | % v(coh,z) solved on ar_interp_coh_grid, ar_z grids, see
|
| | 203 | % ffs_ipwkz_get_funcgrid.m. Generate interpolant based on that, Then
|
| | 204 | % interpolate for the coh reachable levels given the k(w,z) percentage
|
| | 205 | % choice grids in the second stage of the problem
|
| | 206 |
|
| | 207 | % Generate Interpolant for v(coh,z)
|
0.007 | 75 | 208 | f_grid_interpolant_value = griddedInterpolant(...
|
| 75 | 209 | mt_z_mesh_coh_interp_grid', mt_interp_coh_grid_mesh_z', mt_val_cur', 'linear', 'nearest');
|
| | 210 |
|
| | 211 | % Interpoalte for v(coh(k(w,z),b(w,z),z),z)
|
0.050 | 75 | 212 | mt_val_wkb_interpolated = f_grid_interpolant_value(mt_z_mesh_coh_wkb, mt_coh_wkb);
|
| | 213 |
|
| | 214 | %% Solve Second Stage Problem k*(w,z)
|
| | 215 | % This is the key difference between this function and
|
| | 216 | % <https://fanwangecon.github.io/CodeDynaAsset/m_akz/paramfunc/html/ffs_akz_set_functions.html
|
| | 217 | % ffs_akz_set_functions> which solves the two stages jointly
|
| | 218 | % Interpolation first, because solution coh grid is not the same as all
|
| | 219 | % points reachable by k and b choices given w.
|
| | 220 |
|
0.008 | 75 | 221 | support_map('bl_graph_evf') = false;
|
< 0.001 | 75 | 222 | if (it_iter == (it_maxiter_val + 1))
|
< 0.001 | 1 | 223 | support_map('bl_graph_evf') = bl_graph_evf;
|
< 0.001 | 1 | 224 | end
|
| | 225 |
|
< 0.001 | 75 | 226 | bl_input_override = true;
|
0.045 | 75 | 227 | [mt_ev_condi_z_max, ~, mt_ev_condi_z_max_kp, ~] = ...
|
| 75 | 228 | ff_ipwkz_evf(mt_val_wkb_interpolated, param_map, support_map, armt_map, bl_input_override);
|
| | 229 |
|
| | 230 | %% Solve First Stage Problem w*(z) given k*(w,z)
|
| | 231 | % loop 1: over exogenous states
|
< 0.001 | 75 | 232 | for it_z_i = 1:length(ar_z)
|
| | 233 |
|
| | 234 | % Get 2nd Stage Arrays
|
0.001 | 375 | 235 | ar_ev_condi_z_max_z = mt_ev_condi_z_max(:, it_z_i);
|
< 0.001 | 375 | 236 | ar_w_level_kstar_z = mt_ev_condi_z_max_kp(:, it_z_i);
|
| | 237 |
|
| | 238 | % Interpolant (2) k*(ar_w_perc) from k*(ar_w_level,z)
|
| | 239 | % There are two w=k'+b' arrays. ar_w_level is the level even grid based
|
| | 240 | % on which we solve the 2nd stage problem in ff_ipwkz_evf.m. Here for
|
| | 241 | % each coh level, we have a different vector of w levels, but the same
|
| | 242 | % vector of percentage ws. So we need to interpolate to get the optimal
|
| | 243 | % k* and b* choices at each percentage level of w.
|
0.016 | 375 | 244 | f_interpolante_w_level_kstar_z = griddedInterpolant(ar_w_level, ar_w_level_kstar_z', 'linear', 'nearest');
|
| | 245 |
|
| | 246 | % Interpolant for (3) EV(k*(ar_w_perc),Z)
|
0.008 | 375 | 247 | f_interpolante_ev_condi_z_max_z = griddedInterpolant(ar_w_level, ar_ev_condi_z_max_z', 'linear', 'nearest');
|
| | 248 |
|
| | 249 | % loop 2: over endogenous states
|
< 0.001 | 375 | 250 | for it_coh_interp_j = 1:length(ar_interp_coh_grid)
|
| | 251 | % Get cash-on-hand which include k,b,z
|
0.003 | 42375 | 252 | fl_coh = mt_interp_coh_grid_mesh_z(it_coh_interp_j, it_z_i);
|
| | 253 |
|
| | 254 | % loop 3: over choices, only w vector
|
| | 255 | % we choose w(z), know from ff_wkz_evf k*(w,z), b*=w-k*
|
| | 256 | % fl_w_level_perc_z is the level of w given coh and z based on
|
| | 257 | % the w percentage grid generated in ffs_akz_get_funcgrid.m
|
0.035 | 42375 | 258 | ar_val_cur = zeros(size(ar_w_perc));
|
0.022 | 42375 | 259 | ar_w_kstar_z = zeros(size(ar_w_perc));
|
0.021 | 42375 | 260 | ar_w_astar_z = zeros(size(ar_w_perc));
|
0.002 | 42375 | 261 | for it_cohp_k = 1:length(ar_w_perc)
|
| | 262 |
|
| | 263 | % Interpolate (2) to get optimal k at current percentage grid
|
| | 264 | % level given coh and z
|
0.020 | 423750 | 265 | fl_w_level_perc_z = mt_w_by_interp_coh_interp_grid(it_cohp_k, it_coh_interp_j);
|
3.559 | 423750 | 266 | fl_w_kstar_interp_z = f_interpolante_w_level_kstar_z(fl_w_level_perc_z);
|
0.017 | 423750 | 267 | fl_w_astar_interp_z = fl_w_level_perc_z - fl_w_kstar_interp_z;
|
| | 268 |
|
| | 269 | % store optimal interpolated k and a choices given w
|
0.018 | 423750 | 270 | ar_w_kstar_z(it_cohp_k) = fl_w_kstar_interp_z;
|
0.018 | 423750 | 271 | ar_w_astar_z(it_cohp_k) = fl_w_astar_interp_z;
|
| | 272 |
|
| | 273 | % consumption
|
1.019 | 423750 | 274 | fl_c = f_cons(fl_coh, fl_w_astar_interp_z, fl_w_kstar_interp_z);
|
| | 275 |
|
| | 276 | % Interpolate (3) EV(k*(ar_w_perc),Z)
|
3.863 | 423750 | 277 | fl_ev_condi_z_max_interp_z = f_interpolante_ev_condi_z_max_z(fl_w_level_perc_z);
|
| | 278 |
|
| | 279 | % Interpolate (4) consumption
|
3.573 | 423750 | 280 | ar_val_cur(it_cohp_k) = f_grid_interpolant_spln(fl_c) + fl_beta*fl_ev_condi_z_max_interp_z;
|
| | 281 |
|
| | 282 | % Replace if negative consumption
|
0.017 | 423750 | 283 | if fl_c <= 0
|
| | 284 | ar_val_cur(it_cohp_k) = fl_u_neg_c;
|
| | 285 | end
|
| | 286 |
|
0.019 | 423750 | 287 | end
|
| | 288 |
|
| | 289 | % maximization over loop 3 choices for loop 1+2 states
|
0.052 | 42375 | 290 | it_max_lin_idx = find(ar_val_cur == max(ar_val_cur));
|
0.003 | 42375 | 291 | mt_val(it_coh_interp_j,it_z_i) = ar_val_cur(it_max_lin_idx(1));
|
0.002 | 42375 | 292 | mt_pol_a(it_coh_interp_j,it_z_i) = ar_w_astar_z(it_max_lin_idx(1));
|
0.003 | 42375 | 293 | mt_pol_k(it_coh_interp_j,it_z_i) = ar_w_kstar_z(it_max_lin_idx(1));
|
| | 294 |
|
0.002 | 42375 | 295 | end
|
0.001 | 375 | 296 | end
|
| | 297 |
|
| | 298 | %% Check Tolerance and Continuation
|
| | 299 |
|
| | 300 | % Difference across iterations
|
0.018 | 75 | 301 | ar_val_diff_norm(it_iter) = norm(mt_val - mt_val_cur);
|
0.012 | 75 | 302 | ar_pol_diff_norm(it_iter) = norm(mt_pol_a - mt_pol_a_cur) + norm(mt_pol_k - mt_pol_k_cur);
|
0.001 | 75 | 303 | ar_pol_a_perc_change = sum((mt_pol_a ~= mt_pol_a_cur))/length(ar_interp_coh_grid);
|
< 0.001 | 75 | 304 | ar_pol_k_perc_change = sum((mt_pol_k ~= mt_pol_k_cur))/length(ar_interp_coh_grid);
|
0.009 | 75 | 305 | mt_pol_perc_change(it_iter, :) = mean([ar_pol_a_perc_change;ar_pol_k_perc_change]);
|
| | 306 |
|
| | 307 | % Update
|
< 0.001 | 75 | 308 | mt_val_cur = mt_val;
|
< 0.001 | 75 | 309 | mt_pol_a_cur = mt_pol_a;
|
< 0.001 | 75 | 310 | mt_pol_k_cur = mt_pol_k;
|
| | 311 |
|
| | 312 | % Print Iteration Results
|
< 0.001 | 75 | 313 | if (bl_display && (rem(it_iter, it_display_every)==0))
|
| | 314 | fprintf('VAL it_iter:%d, fl_diff:%d, fl_diff_pol:%d\n', ...
|
| | 315 | it_iter, ar_val_diff_norm(it_iter), ar_pol_diff_norm(it_iter));
|
| | 316 | tb_valpol_iter = array2table([mean(mt_val_cur,1);...
|
| | 317 | mean(mt_pol_a_cur,1); ...
|
| | 318 | mean(mt_pol_k_cur,1); ...
|
| | 319 | mt_val_cur(length(ar_interp_coh_grid),:); ...
|
| | 320 | mt_pol_a_cur(length(ar_interp_coh_grid),:); ...
|
| | 321 | mt_pol_k_cur(length(ar_interp_coh_grid),:)]);
|
| | 322 | tb_valpol_iter.Properties.VariableNames = strcat('z', string((1:size(mt_val_cur,2))));
|
| | 323 | tb_valpol_iter.Properties.RowNames = {'mval', 'map', 'mak', 'Hval', 'Hap', 'Hak'};
|
| | 324 | disp('mval = mean(mt_val_cur,1), average value over a')
|
| | 325 | disp('map = mean(mt_pol_a_cur,1), average choice over a')
|
| | 326 | disp('mkp = mean(mt_pol_k_cur,1), average choice over k')
|
| | 327 | disp('Hval = mt_val_cur(ar_interp_coh_grid,:), highest a state val')
|
| | 328 | disp('Hap = mt_pol_a_cur(ar_interp_coh_grid,:), highest a state choice')
|
| | 329 | disp('mak = mt_pol_k_cur(ar_interp_coh_grid,:), highest k state choice')
|
| | 330 | disp(tb_valpol_iter);
|
| | 331 | end
|
| | 332 |
|
| | 333 | % Continuation Conditions:
|
| | 334 | % 1. if value function convergence criteria reached
|
| | 335 | % 2. if policy function variation over iterations is less than
|
| | 336 | % threshold
|
< 0.001 | 75 | 337 | if (it_iter == (it_maxiter_val + 1))
|
< 0.001 | 1 | 338 | bl_vfi_continue = false;
|
0.001 | 74 | 339 | elseif ((it_iter == it_maxiter_val) || ...
|
| 74 | 340 | (ar_val_diff_norm(it_iter) < fl_tol_val) || ...
|
| 74 | 341 | (sum(ar_pol_diff_norm(max(1, it_iter-it_tol_pol_nochange):it_iter)) < fl_tol_pol))
|
| | 342 | % Fix to max, run again to save results if needed
|
< 0.001 | 1 | 343 | it_iter_last = it_iter;
|
< 0.001 | 1 | 344 | it_iter = it_maxiter_val;
|
< 0.001 | 1 | 345 | end
|
| | 346 |
|
< 0.001 | 75 | 347 | end
|
| | 348 |
|
| | 349 | % End Timer
|
< 0.001 | 1 | 350 | if (bl_time)
|
< 0.001 | 1 | 351 | toc;
|
< 0.001 | 1 | 352 | end
|
| | 353 |
|
| | 354 | % End Profile
|
< 0.001 | 1 | 355 | if (bl_profile)
|
0.004 | 1 | 356 | profile off
|
| | 357 | profile viewer
|
| | 358 | st_file_name = [st_profile_prefix st_profile_name_main st_profile_suffix];
|
| | 359 | profsave(profile('info'), strcat(st_profile_path, st_file_name));
|
| | 360 | end
|
| | 361 |
|
| | 362 | %% Process Optimal Choices
|
| | 363 |
|
| | 364 | result_map = containers.Map('KeyType','char', 'ValueType','any');
|
| | 365 | result_map('mt_val') = mt_val;
|
| | 366 |
|
| | 367 | result_map('cl_mt_pol_coh') = {mt_interp_coh_grid_mesh_z, zeros(1)};
|
| | 368 | result_map('cl_mt_pol_a') = {mt_pol_a, zeros(1)};
|
| | 369 | result_map('cl_mt_pol_k') = {mt_pol_k, zeros(1)};
|
| | 370 | result_map('cl_mt_pol_c') = {f_cons(mt_interp_coh_grid_mesh_z, mt_pol_a, mt_pol_k), zeros(1)};
|
| | 371 | result_map('ar_st_pol_names') = ["cl_mt_pol_coh", "cl_mt_pol_a", "cl_mt_pol_k", "cl_mt_pol_c"];
|
| | 372 |
|
| | 373 | if (bl_post)
|
| | 374 | bl_input_override = true;
|
| | 375 | result_map('ar_val_diff_norm') = ar_val_diff_norm(1:it_iter_last);
|
| | 376 | result_map('ar_pol_diff_norm') = ar_pol_diff_norm(1:it_iter_last);
|
| | 377 | result_map('mt_pol_perc_change') = mt_pol_perc_change(1:it_iter_last, :);
|
| | 378 |
|
| | 379 | % graphing based on coh_wkb, but that does not match optimal choice
|
| | 380 | % matrixes for graphs.
|
| | 381 | armt_map('mt_coh_wkb') = mt_interp_coh_grid_mesh_z;
|
| | 382 | armt_map('it_ameshk_n') = length(ar_interp_coh_grid);
|
| | 383 | armt_map('ar_a_meshk') = mt_interp_coh_grid_mesh_z(:,1);
|
| | 384 | armt_map('ar_k_mesha') = zeros(size(mt_interp_coh_grid_mesh_z(:,1)) + 0);
|
| | 385 |
|
| | 386 | result_map = ff_akz_vf_post(param_map, support_map, armt_map, func_map, result_map, bl_input_override);
|
| | 387 | end
|
| | 388 |
|
| | 389 |
|
| | 390 | end
|
Other subfunctions in this file are not included in this listing.