This is a static copy of a profile report

Home

Function details for ffs_ipwkz_set_default_paramThis is a static copy of a profile report

Home

ffs_ipwkz_set_default_param (Calls: 1, Time: 0.013 s)
Generated 27-Jul-2019 21:16:51 using performance time.
function in file C:\Users\fan\CodeDynaAsset\m_ipwkz\paramfunc\ffs_ipwkz_set_default_param.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ffs_ipwkbzr_set_default_paramfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
178
support_map('st_profile_suffix...
10.003 s22.8%
234
close all;
10.001 s9.6%
198
support_map('st_mat_suffix') =...
10.000 s2.8%
160
[st_root_path] = preamble(fals...
10.000 s2.3%
214
support_map('st_img_suffix') =...
10.000 s2.1%
All other lines  0.008 s60.4%
Totals  0.013 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
num2strfunction30.003 s20.7%
closefunction10.001 s8.7%
ismemberfunction30.000 s0.5%
preamblefunction10.000 s0.2%
Self time (built-ins, overhead, etc.)  0.009 s69.9%
Totals  0.013 s100% 
Code Analyzer results
Line numberMessage
176Use of brackets [] is unnecessary. Use parentheses to group, if needed.
177Use of brackets [] is unnecessary. Use parentheses to group, if needed.
196Use of brackets [] is unnecessary. Use parentheses to group, if needed.
197Use of brackets [] is unnecessary. Use parentheses to group, if needed.
212Use of brackets [] is unnecessary. Use parentheses to group, if needed.
213Use of brackets [] is unnecessary. Use parentheses to group, if needed.
236Use of brackets [] is unnecessary. Use parentheses to group, if needed.
257Use of brackets [] is unnecessary. Use parentheses to group, if needed.
275Use of brackets [] is unnecessary. Use parentheses to group, if needed.
294Use of brackets [] is unnecessary. Use parentheses to group, if needed.
325Use of brackets [] is unnecessary. Use parentheses to group, if needed.
353Use of brackets [] is unnecessary. Use parentheses to group, if needed.
Coverage results
Show coverage for parent directory
Total lines in function364
Non-code lines (comments, blank lines)181
Code lines (lines that can run)183
Code lines that did run99
Code lines that did not run84
Coverage (did run/can run)54.10 %
Function listing
time 
Calls 
 line
   7 
function [param_map, support_map] = ffs_ipwkz_set_default_param(varargin)
   8 
%% FFS_IPKZ_SET_DEFAULT_PARAM setting model default parameters
   9 
% Define model parameters, similar to
  10 
% <https://fanwangecon.github.io/CodeDynaAsset/m_akz/paramfunc/html/ffs_akz_set_default_param.html
  11 
% ffs_akz_set_default_param> see that file for descriptions.
  12 
%
  13 
% Several changes here: 1, inclusion of percentage based choice grids
  14 
%
  15 
% @param it_subset integer default parameter control subsetting. it_subset = 1 is
  16 
% basic invoke quick test. it_subset = 2 is main invoke. it_subset = 3 is
  17 
% profiling invoke. it_subset = 4 is matlab publish.
  18 
%
  19 
% @param bl_display_defparam boolean local printing
  20 
%
  21 
% @return param_map container parameters needed for solving the model
  22 
%
  23 
% @return support_map container programming control parameters like to graph to print etc
  24 
%
  25 
% @example
  26 
%
  27 
%   it_param_set = 1;
  28 
%   [param_map, support_map] = ffs_akz_set_default_param(it_param_set);
  29 
%
  30 
% @seealso
  31 
%
  32 
% * <https://fanwangecon.github.io/CodeDynaAsset/m_ipwkbz/paramfunc/html/ffs_ipwkbz_set_default_param.html ffs_ipwkbz_set_default_param>
  33 
% * <https://fanwangecon.github.io/CodeDynaAsset/m_ipwkbzr/paramfunc/html/ffs_ipwkbzr_set_default_param.html ffs_ipwkbzr_set_default_param>
  34 
% * <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/m_ipwkbz_paramfunc/html/ffs_ipwkbz_fibs_set_default_param.html ffs_ipwkbz_fibs_set_default_param>
  35 
% * <https://fanwangecon.github.io/CodeDynaAsset/m_fibs/m_ipwkbzr_paramfunc/html/ffs_ipwkbzr_fibs_set_default_param.html ffs_ipwkbzr_fibs_set_default_param>
  36 
%
  37 

  38 
%% Default
  39 

< 0.001 
      1 
  40
it_subset = 4; 
< 0.001 
      1 
  41
if (isempty(varargin)) 
  42 
    bl_display_defparam = true;
      1 
  43
else 
      1 
  44
    bl_display_defparam = false; 
      1 
  45
end 
< 0.001 
      1 
  46
default_params = {it_subset bl_display_defparam}; 
< 0.001 
      1 
  47
[default_params{1:length(varargin)}] = varargin{:}; 
< 0.001 
      1 
  48
[it_subset, bl_display_defparam] = default_params{:}; 
  49 

  50 
%% Setting param_map container
  51 

< 0.001 
      1 
  52
param_map = containers.Map('KeyType','char', 'ValueType','any'); 
  53 

  54 
% model name
< 0.001 
      1 
  55
param_map('st_model') = 'ipwkz'; 
  56 

  57 
% Preferences
< 0.001 
      1 
  58
param_map('fl_crra') = 1.5; 
< 0.001 
      1 
  59
param_map('fl_beta') = 0.94; 
< 0.001 
      1 
  60
param_map('fl_nan_replace') = -9999; 
  61 

  62 
%% 1b. Production Function Parameters
  63 

  64 
% CD Production Function Parameters
< 0.001 
      1 
  65
param_map('fl_Amean') = 1; 
< 0.001 
      1 
  66
param_map('fl_alpha') = 0.36; 
< 0.001 
      1 
  67
param_map('fl_delta') = 0.08; 
  68 

  69 
%% 2a. Set Borrowing Control Parameters
  70 

  71 
% Borrowing Parameters
< 0.001 
      1 
  72
param_map('fl_b_bd') = 0; % borrow bound, = 0 if save only 
  73 

  74 
% Minimum Consumption, utility lower bound. The cmin parameter and
  75 
% fl_nan_replace parameter have no effects on value function, just for
  76 
% resetting invalid choice grid values. fl_nan_replace reset invalid k
  77 
% choice given w. fl_c_min resets invalid consumption levels due to w
  78 
% choices that are invalid. But this is the case when fl_w > 0.
< 0.001 
      1 
  79
param_map('fl_c_min') = 0.02; 
  80 

  81 
%% 2b. Set Asset Grid Parameters
  82 

  83 
% Asset Grids
  84 
% Toal savings aggregate grid (see discussion on top). 35 points picked for
  85 
% for this problem w_max is overall for everyone, but each individual coh
  86 
% levle has associated w_max. Unlike before, when we had it_w_n, now we
  87 
% have it_w_perc_n which is how many percentage grid points to have. We
  88 
% also now include fl_w_interp_grid_gap, the grip gap for interpolation.
< 0.001 
      1 
  89
param_map('fl_w_min') = param_map('fl_b_bd'); % but b_bd overrides this 
< 0.001 
      1 
  90
param_map('fl_w_max') = 50; 
< 0.001 
      1 
  91
param_map('it_w_perc_n') = 50; 
  92 

  93 
% Risky Capital Asset Vector
  94 
% see graph below for how it looks graphically
  95 
% in principle keep it_k_n the same as it_w_n to have equi-distance points
  96 
% in triangle choice grid. For the ipwkz this k_max is the overall max, not
  97 
% the individual max given coh. we have it_ak_perc_n rather than it_ak_n
  98 
% for percentage.
< 0.001 
      1 
  99
param_map('fl_k_min') = 0; 
< 0.001 
      1 
 100
param_map('fl_k_max') = (param_map('fl_w_max') - param_map('fl_b_bd')); 
< 0.001 
      1 
 101
param_map('it_ak_perc_n') = param_map('it_w_perc_n'); % grid for a and k the same 
 102 

 103 
% Prices
 104 
% shock is on k, not on labor, fl_w is fixed wage income
< 0.001 
      1 
 105
param_map('fl_w') = 1.28*0.3466; % min(z*w) from benchmark az model 
 106 

 107 
%% 2c. Set Asset Interpolation Parameters
 108 

 109 
% Interpolation
 110 
% fl_coh_interp_grid_gap controls the number of coh points at which to solve the model
 111 
% it_c_interp_grid_gap determines the gap between consumption terpolation
 112 
% points. For consumption interpolation 10^-4 is extremely accurate, there
 113 
% should be no perceptible differences in value and policy functions when the
 114 
% it_c_interp_grid_gap <= 0.001 compared to actual evaluation. Also include
 115 
% now fl_w_interp_grid_gap above, which is for interpolation over w.
< 0.001 
      1 
 116
param_map('fl_coh_interp_grid_gap') = 0.1; 
 117 

 118 
% param_map('it_coh_interp_n') = 500;
< 0.001 
      1 
 119
param_map('it_c_interp_grid_gap') = 10^-4; 
 120 

 121 
% Interpolation gap second stage w
 122 
% previously only it_w_n, now two grids control w it_w_perc_n for 2nd stage
 123 
% fl_w_interp_grid_gap for first stage, make them the same length for
 124 
% default.
< 0.001 
      1 
 125
param_map('fl_w_interp_grid_gap') = 0.1; 
 126 
% param_map('fl_w_interp_grid_gap') = (param_map('fl_w_max') - param_map('fl_w_min'))/param_map('it_w_perc_n');
 127 

 128 
%% 3. Set Interest Rates non-Shock Parameters
 129 
% Prices
 130 
% shock is on k, not on labor, fl_w is fixed wage income
 131 

< 0.001 
      1 
 132
param_map('fl_w') = 1.28*0.3466; % min(z*w) from benchmark az model 
< 0.001 
      1 
 133
param_map('fl_r_save') = 0.025; 
< 0.001 
      1 
 134
param_map('fl_r_borr') = 0.095; 
 135 

 136 
%% 4. Set Shock 2 Productivity Shock Parameters
 137 

 138 
% Production Function
 139 
% Productivity Shock Parameters
< 0.001 
      1 
 140
param_map('it_z_n') = 15; 
< 0.001 
      1 
 141
param_map('fl_z_mu') = 0; 
< 0.001 
      1 
 142
param_map('fl_z_rho') = 0.8; 
< 0.001 
      1 
 143
param_map('fl_z_sig') = 0.2; 
 144 

 145 
%% 5. Set Solution Control Parameters
 146 
% Solution Accuracy
< 0.001 
      1 
 147
param_map('it_maxiter_val') = 250; 
< 0.001 
      1 
 148
param_map('it_maxiter_dist') = 1000; 
< 0.001 
      1 
 149
param_map('st_analytical_stationary_type') = 'eigenvector'; % could be loop or vector 
< 0.001 
      1 
 150
param_map('fl_tol_val') = 10^-5; 
< 0.001 
      1 
 151
param_map('fl_tol_pol') = 10^-5; 
< 0.001 
      1 
 152
param_map('fl_tol_dist') = 10^-5; 
< 0.001 
      1 
 153
param_map('it_tol_pol_nochange') = 25; % number of iterations where policy does not change 
 154 

 155 
%% Setting support_map container
 156 

< 0.001 
      1 
 157
support_map = containers.Map('KeyType','char', 'ValueType','any'); 
 158 

 159 
% root directory
< 0.001 
      1 
 160
[st_root_path] = preamble(false); 
< 0.001 
      1 
 161
st_matimg_path_root = [st_root_path '/m_ipwkz/']; 
< 0.001 
      1 
 162
support_map('st_matimg_path_root') = st_matimg_path_root; 
 163 

 164 
% timer
< 0.001 
      1 
 165
support_map('bl_time') = true; 
 166 

 167 
% Print Controls
< 0.001 
      1 
 168
support_map('bl_display') = true; 
< 0.001 
      1 
 169
support_map('bl_display_dist') = false; 
< 0.001 
      1 
 170
support_map('it_display_every') = 5; % how often to print results 
 171 

 172 
% Profile Controls
< 0.001 
      1 
 173
support_map('bl_profile') = false; 
< 0.001 
      1 
 174
support_map('bl_profile_dist') = false; % distribution profile 
< 0.001 
      1 
 175
support_map('st_profile_path') = [st_matimg_path_root '/solve/profile/']; 
< 0.001 
      1 
 176
support_map('st_profile_prefix') = ['']; 
< 0.001 
      1 
 177
support_map('st_profile_name_main') = ['_default']; 
  0.003 
      1 
 178
support_map('st_profile_suffix') = ['_p' num2str(it_subset)]; 
 179 

< 0.001 
      1 
 180
support_map('bl_post') = false; 
 181 

 182 
% Final Print
< 0.001 
      1 
 183
support_map('bl_display_final') = false; % print finalized results 
< 0.001 
      1 
 184
support_map('bl_display_final_dist') = false; % print finalized results 
< 0.001 
      1 
 185
support_map('bl_display_final_dist_detail') = false; 
< 0.001 
      1 
 186
support_map('it_display_final_rowmax') = 100; % max row to print (states/iters) 
< 0.001 
      1 
 187
support_map('it_display_final_colmax') = 12; % max col to print (shocks) 
      1 
 188
it_display_summmat_rowmax = 7; 
< 0.001 
      1 
 189
it_display_summmat_colmax = 7; 
< 0.001 
      1 
 190
support_map('it_display_summmat_rowmax') = it_display_summmat_rowmax; 
< 0.001 
      1 
 191
support_map('it_display_summmat_colmax') = it_display_summmat_colmax; 
 192 

 193 
% Mat File Controls
< 0.001 
      1 
 194
support_map('bl_mat') = false; 
< 0.001 
      1 
 195
support_map('st_mat_path') = [st_matimg_path_root '/solve/mat/']; 
< 0.001 
      1 
 196
support_map('st_mat_prefix') = ['']; 
< 0.001 
      1 
 197
support_map('st_mat_name_main') = ['_default']; 
< 0.001 
      1 
 198
support_map('st_mat_suffix') = ['_p' num2str(it_subset)]; 
 199 

 200 
% Graphing Controls
< 0.001 
      1 
 201
support_map('bl_graph') = false; 
< 0.001 
      1 
 202
support_map('bl_graph_onebyones') = true; 
< 0.001 
      1 
 203
support_map('bl_graph_val') = true; 
< 0.001 
      1 
 204
support_map('bl_graph_pol_lvl') = true; 
< 0.001 
      1 
 205
support_map('bl_graph_pol_pct') = true; 
< 0.001 
      1 
 206
support_map('bl_graph_coh_t_coh') = true; 
 207 

 208 
% Image Saving Controls (given graphing)
< 0.001 
      1 
 209
support_map('st_title_prefix') = ''; 
< 0.001 
      1 
 210
support_map('bl_img_save') = false; 
< 0.001 
      1 
 211
support_map('st_img_path') = [st_matimg_path_root '/solve/img/']; 
< 0.001 
      1 
 212
support_map('st_img_prefix') = ['']; 
< 0.001 
      1 
 213
support_map('st_img_name_main') = ['_default']; 
< 0.001 
      1 
 214
support_map('st_img_suffix') = ['_p' num2str(it_subset) '.png']; 
< 0.001 
      1 
 215
support_map('st_mat_test_path') = [st_matimg_path_root '/test/ff_ipwkz_ds_vecsv/mat/']; 
 216 

 217 
% Sub-function graphing controls
< 0.001 
      1 
 218
support_map('bl_graph_funcgrids') = false; 
< 0.001 
      1 
 219
support_map('bl_graph_funcgrids_detail') = false; 
< 0.001 
      1 
 220
support_map('bl_display_funcgrids') = false; 
< 0.001 
      1 
 221
support_map('bl_graph_evf') = false; 
< 0.001 
      1 
 222
support_map('bl_display_evf') = false; 
< 0.001 
      1 
 223
support_map('bl_display_defparam') = false; 
 224 

 225 
%% Subset Options
 226 
%
 227 
% # it_subset = 1 is basic invoke quick test
 228 
% # it_subset = 2 is main invoke
 229 
% # it_subset = 3 is profiling invoke
 230 
% # it_subset = 4 is matlab publish.
 231 
%
 232 

 233 
% close figures
  0.001 
      1 
 234
close all; 
 235 

< 0.001 
      1 
 236
if (ismember(it_subset, [3])) 
 237 
    % Profile run
< 0.001 
      1 
 238
    support_map('bl_profile') = true; 
< 0.001 
      1 
 239
    support_map('bl_display') = false; % don't print 
< 0.001 
      1 
 240
    support_map('bl_time') = true; 
 241 

 242 
elseif (ismember(it_subset, [1,2,4]))
 243 

 244 
    % Main Run
 245 
    support_map('bl_time') = true;
 246 
    support_map('bl_display_defparam') = true;
 247 
    support_map('bl_display') = true;
 248 
    support_map('it_display_every') = 5;
 249 

 250 
    support_map('bl_post') = true;
 251 
    support_map('bl_display_final') = true;
 252 
    support_map('bl_mat') = false;
 253 
    support_map('bl_graph') = true;
 254 
    support_map('bl_graph_onebyones') = false;
 255 
    support_map('bl_img_save') = true;
 256 

 257 
    if (ismember(it_subset, [1]))
 258 
        % TEST quick
 259 
        param_map('it_w_perc_n') = 20;
 260 
        param_map('it_ak_perc_n') = param_map('it_w_perc_n');
 261 
        param_map('it_z_n') = 5;
 262 

 263 
        param_map('fl_coh_interp_grid_gap') = 0.25;
 264 
        param_map('it_c_interp_grid_gap') = 0.001;
 265 
        param_map('fl_w_interp_grid_gap') = 1;
 266 

 267 
        param_map('it_maxiter_val') = 50;
 268 
        param_map('it_tol_pol_nochange') = 1000;
 269 
        support_map('bl_display') = true;
 270 
        support_map('it_display_every') = 1;
 271 

 272 
        support_map('bl_graph') = false;
 273 
    end
 274 

 275 
    if (ismember(it_subset, [4]))
 276 
        support_map('bl_time') = false;
 277 
        support_map('bl_display') = false;
 278 
        support_map('bl_graph_onebyones') = true;
 279 
        support_map('bl_img_save') = false;
 280 
    end
 281 

 282 
end
 283 

 284 

 285 
%% Subset Options for Distribution solutions
 286 
%
 287 
% # it_subset = 5 is basic invoke quick test
 288 
% # it_subset = 6 is invoke full test
 289 
% # it_subset = 7 is profiling invoke
 290 
% # it_subset = 8 is matlab publish
 291 
% # it_subset = 9 is invoke operational (only final stats) and coh graph
 292 
%
 293 

< 0.001 
      1 
 294
if (ismember(it_subset, [7])) 
 295 
    % Profile run
 296 
    support_map('bl_profile_dist') = true;
 297 
    support_map('bl_display') = false; % don't print
 298 
    support_map('bl_display_dist') = false; % don't print
 299 
    support_map('bl_time') = true;
 300 

< 0.001 
      1 
 301
elseif (ismember(it_subset, [5,6,8,9])) 
 302 
    % close all
 303 
    close all;
 304 

 305 
    % Main Run
 306 
    support_map('bl_time') = true;
 307 
    support_map('bl_display_defparam') = true;
 308 
    support_map('bl_display') = true;
 309 
    support_map('bl_display_dist') = true;
 310 
    support_map('it_display_every') = 20;
 311 

 312 
    support_map('bl_post') = true;
 313 
    support_map('bl_display_final_dist') = true;
 314 
    support_map('bl_mat') = false;
 315 
    support_map('bl_graph') = true;
 316 
    support_map('bl_graph_onebyones') = false;
 317 
    support_map('bl_img_save') = true;
 318 

 319 
    % do not generate all graphs when solving for distribution
 320 
    support_map('bl_graph_val') = false;
 321 
    support_map('bl_graph_pol_lvl') = false;
 322 
    support_map('bl_graph_pol_pct') = false;
 323 
    support_map('bl_graph_coh_t_coh') = true;
 324 

 325 
    if (ismember(it_subset, [5]))
 326 
        % TEST quick (need to enough to have distribution)
 327 
        param_map('it_w_perc_n') = 40;
 328 
        param_map('it_ak_perc_n') = param_map('it_w_perc_n');
 329 
        param_map('it_z_n') = 5;
 330 

 331 
        param_map('fl_coh_interp_grid_gap') = 0.25;
 332 
        param_map('it_c_interp_grid_gap') = 0.001;
 333 
        param_map('fl_w_interp_grid_gap') = 1;
 334 

 335 
        param_map('it_maxiter_val') = 50;
 336 
        param_map('it_tol_pol_nochange') = 1000;
 337 
        support_map('bl_display') = true;
 338 
        support_map('it_display_every') = 1;
 339 

 340 
        support_map('bl_display_dist') = true;
 341 
        support_map('bl_graph') = false;
 342 
    end
 343 

 344 
    if (ismember(it_subset, [8, 9]))
 345 

 346 
        support_map('bl_time') = false;
 347 
        support_map('bl_display') = false;
 348 
        support_map('bl_display_dist') = false;
 349 
        support_map('bl_display_final_dist_detail') = true;
 350 
        support_map('bl_graph_onebyones') = true;
 351 
        support_map('bl_img_save') = false;
 352 

 353 
        if (ismember(it_subset, [9]))
 354 
            % quietly turn off all graphs, only tables
 355 
            support_map('bl_display_defparam') = false;
 356 
            support_map('bl_display_final_dist_detail') = false;
 357 
            support_map('bl_graph_coh_t_coh') = false;
 358 
            support_map('bl_graph') = false;
 359 
        end
 360 
    end
 361 
end
 362 

 363 
%% Display
 364 

< 0.001 
      1 
 365
if (bl_display_defparam) 
 366 
    fft_container_map_display(param_map, it_display_summmat_rowmax, it_display_summmat_colmax);
 367 
    fft_container_map_display(support_map, it_display_summmat_rowmax, it_display_summmat_colmax);
 368 
end
 369 

< 0.001 
      1 
 370
end 

Other subfunctions in this file are not included in this listing.