This is a static copy of a profile report

Home

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

Home

ffs_abz_fibs_set_default_param (Calls: 1, Time: 0.025 s)
Generated 07-Jul-2019 17:49:15 using performance time.
function in file C:\Users\fan\CodeDynaAsset\m_fibs\m_abz_paramfunc\ffs_abz_fibs_set_default_param.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ff_abz_fibs_vf_vecsvfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
240
close all;
10.010 s38.0%
226
if (ismember(it_subset, [1,2,3...
10.004 s16.7%
175
support_map('st_profile_suffix...
10.003 s13.6%
227
if (ismember(it_subset, [1]))
10.003 s12.0%
159
[st_root_path] = preamble(fals...
10.001 s3.9%
All other lines  0.004 s15.9%
Totals  0.025 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
closefunction10.009 s37.0%
ismemberfunction60.007 s28.4%
num2strfunction30.003 s12.6%
preamblefunction10.001 s3.0%
Self time (built-ins, overhead, etc.)  0.005 s19.0%
Totals  0.025 s100% 
Code Analyzer results
Line numberMessage
173Use of brackets [] is unnecessary. Use parentheses to group, if needed.
174Use of brackets [] is unnecessary. Use parentheses to group, if needed.
187Use of brackets [] is unnecessary. Use parentheses to group, if needed.
188Use of brackets [] is unnecessary. Use parentheses to group, if needed.
208Use of brackets [] is unnecessary. Use parentheses to group, if needed.
209Use of brackets [] is unnecessary. Use parentheses to group, if needed.
227Use of brackets [] is unnecessary. Use parentheses to group, if needed.
253Use of brackets [] is unnecessary. Use parentheses to group, if needed.
260Use of brackets [] is unnecessary. Use parentheses to group, if needed.
278Use of brackets [] is unnecessary. Use parentheses to group, if needed.
322Use of brackets [] is unnecessary. Use parentheses to group, if needed.
331Use of brackets [] is unnecessary. Use parentheses to group, if needed.
Coverage results
Show coverage for parent directory
Total lines in function356
Non-code lines (comments, blank lines)150
Code lines (lines that can run)206
Code lines that did run123
Code lines that did not run83
Coverage (did run/can run)59.71 %
Function listing
time 
Calls 
 line
   7 
function [param_map, support_map] = ffs_abz_fibs_set_default_param(varargin)
   8 
%% FFS_ABZ_FIBS_SET_DEFAULT_PARAM setting model default parameters
   9 
% two groups of default parameters stored in container maps
  10 
%
  11 
% @param it_subset integer default parameter control subsetting. it_subset = 1 is
  12 
% basic invoke quick test. it_subset = 2 is main invoke. it_subset = 3 is
  13 
% profiling invoke. it_subset = 4 is matlab publish.
  14 
%
  15 
% @param bl_display_defparam boolean local printing
  16 
%
  17 
% @return param_map container parameters needed for solving the model
  18 
%
  19 
% @return support_map container programming control parameters like to graph to print etc
  20 
%
  21 
% @example
  22 
%
  23 
%   it_param_set = 1;
  24 
%   [param_map, support_map] = ffs_abz_fibs_set_default_param(it_param_set);
  25 
%
  26 
% @seealso
  27 
%
  28 
% * initialize paramters *az*: <https://fanwangecon.github.io/CodeDynaAsset/m_az/paramfunc/html/ffs_az_set_default_param.html ffs_az_set_default_param>
  29 
% * initialize paramters *abz*: <https://fanwangecon.github.io/CodeDynaAsset/m_abz/paramfunc/html/ffs_abz_set_default_param.html ffs_abz_set_default_param>
  30 
%
  31 

  32 
%% Default
  33 

< 0.001 
      1 
  34
it_subset = 0; 
< 0.001 
      1 
  35
if (isempty(varargin)) 
  36 
    bl_display_defparam = true;
< 0.001 
      1 
  37
else 
< 0.001 
      1 
  38
    bl_display_defparam = false; 
< 0.001 
      1 
  39
end 
< 0.001 
      1 
  40
default_params = {it_subset bl_display_defparam}; 
< 0.001 
      1 
  41
[default_params{1:length(varargin)}] = varargin{:}; 
< 0.001 
      1 
  42
[it_subset, bl_display_defparam] = default_params{:}; 
  43 

  44 
%% Set Asset Grid Parameters
  45 

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

  48 
% model name
< 0.001 
      1 
  49
param_map('st_model') = 'abz_fibs'; 
  50 

  51 
% Preferences
< 0.001 
      1 
  52
param_map('fl_crra') = 1.5; 
< 0.001 
      1 
  53
param_map('fl_beta') = 0.94; 
< 0.001 
      1 
  54
param_map('fl_nan_replace') = -99999; 
  55 

  56 
%% Set Asset Grid Parameters
  57 
% see
  58 
% <https://fanwangecon.github.io/CodeDynaAsset/m_abz/paramfunc/html/ffs_abz_gen_borrsave_grid.html
  59 
% ffs_abz_gen_borrsave_grid> for how these borrowing/saving grid parameters
  60 
% will be used.
  61 

  62 
% Savings
< 0.001 
      1 
  63
param_map('fl_a_min') = 0; % if there is minimum savings requirement 
< 0.001 
      1 
  64
param_map('fl_a_max') = 50; 
< 0.001 
      1 
  65
param_map('bl_loglin') = false; % log lin threshold structure 
< 0.001 
      1 
  66
param_map('fl_loglin_threshold') = 1; % dense points before 1 
< 0.001 
      1 
  67
param_map('it_a_n') = 750; 
  68 

  69 
% Prices
< 0.001 
      1 
  70
param_map('fl_w') = 1.28; 
  71 

  72 
%% Set Interest Rates non-Shock Parameters
  73 

  74 
% formal informal parameters
  75 
% fl_for_br_block are the formal borrowing grid block sizes.
< 0.001 
      1 
  76
param_map('fl_r_fsv') = 0.025; 
  77 
% param_map('fl_r_inf') = 0.095;
  78 
% param_map('fl_r_inf_bridge') = 0.095;
< 0.001 
      1 
  79
param_map('fl_r_fbr') = 0.065; 
  80 
% see: ffs_for_br_block.m
< 0.001 
      1 
  81
param_map('st_forbrblk_type') = 'seg3'; 
< 0.001 
      1 
  82
param_map('fl_forbrblk_brmost') = -19; 
< 0.001 
      1 
  83
param_map('fl_forbrblk_brleast') = -1; 
< 0.001 
      1 
  84
param_map('fl_forbrblk_gap') = -1.5; 
  85 

  86 
%% Set Borrowing Control Parameters
  87 

  88 
% Borrowing
  89 
% fl_default_aprime is the next period asset level
  90 
% households face if they default.
< 0.001 
      1 
  91
param_map('fl_b_bd') = -20; % borrow bound, = 0 if save only 
< 0.001 
      1 
  92
param_map('fl_default_aprime') = 0; 
  93 

  94 
% Borrowing Setting 1: Default Allowed, Bridge True, bl_rollover does not matter
  95 
% Borrowing Setting 2: Default Allowed, Bridge False, bl_rollover matter
< 0.001 
      1 
  96
param_map('bl_default') = true; % if borrowing is default allowed 
< 0.001 
      1 
  97
param_map('bl_bridge') = true; 
< 0.001 
      1 
  98
param_map('bl_rollover') = true; 
  99 

 100 
% is save/borr choice principle or principle + interest, matters for
 101 
% borrowing grid generation program. the *abz* problem is written with
 102 
% asset choice as principle only, the _abz_fibs_ problems are written as
 103 
% priniple + interest as the state, so there this should be false.
< 0.001 
      1 
 104
param_map('bl_b_is_principle') = false; 
 105 
% Minimum Consumption, c_min is for default, when c < 0, replace utility
 106 
% with fl_nan_replace.
< 0.001 
      1 
 107
param_map('fl_c_min') = 0.02; 
 108 

 109 
%% Set Shock 1 Borrowing Interest Rate Parameters
 110 
% See
 111 
% <https://fanwangecon.github.io/CodeDynaAsset/tools/html/fft_gen_discrete_var.html
 112 
% fft_gen_discrete_var> for how these parameters will be used to generate a
 113 
% discrete random variable for the interest rate. And also various formal
 114 
% and informal files.
 115 

 116 
% Borrowing Interest rate
< 0.001 
      1 
 117
param_map('st_z_r_borr_drv_ele_type') = 'unif'; 
< 0.001 
      1 
 118
param_map('st_z_r_borr_drv_prb_type') = 'poiss'; 
< 0.001 
      1 
 119
param_map('fl_z_r_borr_poiss_mean') = 20; 
< 0.001 
      1 
 120
param_map('fl_z_r_borr_max') = 0.095; 
< 0.001 
      1 
 121
param_map('fl_z_r_borr_min') = 0.025; 
< 0.001 
      1 
 122
param_map('fl_z_r_borr_n') = 5; 
 123 
% param_map('fl_z_r_borr_max') = 0.095;
 124 
% param_map('fl_z_r_borr_min') = 0.095;
 125 
% param_map('fl_z_r_borr_n') = 1;
 126 

 127 
%% Set Shock 2 Wage Shock Parameters
 128 
% See
 129 
% <https://github.com/FanWangEcon/CodeDynaAsset/blob/master/tools/ffto_gen_tauchen_jhl.m
 130 
% ffto_gen_tauchen_jhl> for standard implementation of ar1 shock process
 131 
% using these parameters.
 132 

 133 
% Shock Parameters
< 0.001 
      1 
 134
param_map('it_z_wage_n') = 15; 
< 0.001 
      1 
 135
param_map('fl_z_wage_mu') = 0; 
< 0.001 
      1 
 136
param_map('fl_z_wage_rho') = 0.8; 
< 0.001 
      1 
 137
param_map('fl_z_wage_sig') = 0.2; 
 138 

 139 
%% Set Overall Shock Grid Count
 140 

< 0.001 
      1 
 141
param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n'); 
 142 

 143 
%% Set Solution Control Parameters
 144 

 145 
% Solution Accuracy
< 0.001 
      1 
 146
param_map('it_maxiter_val') = 1000; 
< 0.001 
      1 
 147
param_map('it_maxiter_dist') = 1000; 
< 0.001 
      1 
 148
param_map('it_trans_power_dist') = 1000; 
< 0.001 
      1 
 149
param_map('st_analytical_stationary_type') = 'eigenvector'; % could be eigenvector, projection, power 
< 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 
% root directory
< 0.001 
      1 
 159
[st_root_path] = preamble(false); 
< 0.001 
      1 
 160
st_matimg_path_root = [st_root_path '/m_fibs/']; 
< 0.001 
      1 
 161
support_map('st_matimg_path_root') = st_matimg_path_root; 
 162 
% timer
< 0.001 
      1 
 163
support_map('bl_time') = true; 
 164 
% Print Controls
< 0.001 
      1 
 165
support_map('bl_display_defparam') = false; 
< 0.001 
      1 
 166
support_map('bl_display') = true; 
< 0.001 
      1 
 167
support_map('bl_display_dist') = false; 
< 0.001 
      1 
 168
support_map('it_display_every') = 5; % how often to print results 
 169 
% Profile Controls
< 0.001 
      1 
 170
support_map('bl_profile') = false; 
< 0.001 
      1 
 171
support_map('bl_profile_dist') = false; % distribution profile 
< 0.001 
      1 
 172
support_map('st_profile_path') = [st_matimg_path_root '/m_abz_solve/profile/']; 
< 0.001 
      1 
 173
support_map('st_profile_prefix') = ['']; 
< 0.001 
      1 
 174
support_map('st_profile_name_main') = ['_default']; 
  0.003 
      1 
 175
support_map('st_profile_suffix') = ['_p' num2str(it_subset)]; 
 176 

< 0.001 
      1 
 177
support_map('bl_post') = false; 
 178 
% Final Print
< 0.001 
      1 
 179
support_map('bl_display_final') = false; % print finalized results 
< 0.001 
      1 
 180
support_map('bl_display_final_dist') = false; % print finalized results 
< 0.001 
      1 
 181
support_map('bl_display_final_dist_detail') = false; % print finalized results 
< 0.001 
      1 
 182
support_map('it_display_final_rowmax') = 100; % max row to print (states/iters) 
< 0.001 
      1 
 183
support_map('it_display_final_colmax') = 15; % max col to print (shocks) 
 184 
% Mat File Controls
< 0.001 
      1 
 185
support_map('bl_mat') = false; 
< 0.001 
      1 
 186
support_map('st_mat_path') = [st_matimg_path_root '/m_abz_solve/mat/']; 
< 0.001 
      1 
 187
support_map('st_mat_prefix') = ['']; 
< 0.001 
      1 
 188
support_map('st_mat_name_main') = ['_default']; 
< 0.001 
      1 
 189
support_map('st_mat_suffix') = ['_p' num2str(it_subset)]; 
 190 
% Graphing Controls
< 0.001 
      1 
 191
support_map('bl_graph') = false; 
< 0.001 
      1 
 192
support_map('bl_graph_onebyones') = true; 
< 0.001 
      1 
 193
support_map('bl_graph_val') = true; 
< 0.001 
      1 
 194
support_map('bl_graph_pol_lvl') = true; 
< 0.001 
      1 
 195
support_map('bl_graph_pol_pct') = true; 
< 0.001 
      1 
 196
support_map('bl_graph_coh_t_coh') = true; 
< 0.001 
      1 
 197
support_map('bl_graph_discrete') = true; 
 198 
% Formal Informal Specific Graphs
< 0.001 
      1 
 199
support_map('bl_graph_forinf_discrete') = true; 
< 0.001 
      1 
 200
support_map('bl_graph_forinf_pol_lvl') = true; 
< 0.001 
      1 
 201
support_map('bl_graph_forinf_pol_pct') = true; 
 202 

 203 

 204 
% Image Saving Controls (given graphing)
< 0.001 
      1 
 205
support_map('st_title_prefix') = ''; 
< 0.001 
      1 
 206
support_map('bl_img_save') = false; 
< 0.001 
      1 
 207
support_map('st_img_path') = [st_matimg_path_root '/m_abz_solve/img/']; 
< 0.001 
      1 
 208
support_map('st_img_prefix') = ['']; 
< 0.001 
      1 
 209
support_map('st_img_name_main') = ['_default']; 
< 0.001 
      1 
 210
support_map('st_img_suffix') = ['_p' num2str(it_subset) '.png']; 
 211 

 212 
% Sub-function graphing controls
< 0.001 
      1 
 213
support_map('bl_graph_funcgrids') = false; 
< 0.001 
      1 
 214
support_map('bl_display_funcgrids') = false; 
< 0.001 
      1 
 215
support_map('bl_display_minccost') = false; 
< 0.001 
      1 
 216
support_map('bl_display_infbridge') = false; 
 217 

 218 
%% Subset Options
 219 
%
 220 
% # it_subset = 1 is basic invoke quick test
 221 
% # it_subset = 2 is main invoke
 222 
% # it_subset = 3 is profiling invoke
 223 
% # it_subset = 4 is matlab publish.
 224 
%
 225 

  0.004 
      1 
 226
if (ismember(it_subset, [1,2,3,4])) 
  0.003 
      1 
 227
    if (ismember(it_subset, [1])) 
 228 
        % TEST quick
 229 
        param_map('it_a_n') = 25;
 230 
        param_map('it_z_wage_n') = 3;
 231 
        param_map('fl_z_r_borr_n') = 2;
 232 
        param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n');
 233 
        param_map('it_maxiter_val') = 50;
 234 
        param_map('it_tol_pol_nochange') = 1000;
 235 
        support_map('bl_display') = true;
 236 
        support_map('it_display_every') = 1;
 237 
    end
< 0.001 
      1 
 238
    if (ismember(it_subset, [2, 4])) 
 239 
        % close figures
  0.010 
      1 
 240
        close all; 
 241 
        % Main Run
< 0.001 
      1 
 242
        support_map('bl_time') = true; 
< 0.001 
      1 
 243
        support_map('bl_display_defparam') = true; 
< 0.001 
      1 
 244
        support_map('bl_display') = true; 
< 0.001 
      1 
 245
        support_map('it_display_every') = 5; 
 246 

< 0.001 
      1 
 247
        support_map('bl_post') = true; 
< 0.001 
      1 
 248
        support_map('bl_display_final') = true; 
< 0.001 
      1 
 249
        support_map('bl_mat') = false; 
< 0.001 
      1 
 250
        support_map('bl_graph') = true; 
< 0.001 
      1 
 251
        support_map('bl_graph_onebyones') = false; 
< 0.001 
      1 
 252
        support_map('bl_img_save') = true; 
< 0.001 
      1 
 253
        if (ismember(it_subset, [4])) 
< 0.001 
      1 
 254
            support_map('bl_time') = false; 
< 0.001 
      1 
 255
            support_map('bl_display') = false; 
< 0.001 
      1 
 256
            support_map('bl_graph_onebyones') = true; 
< 0.001 
      1 
 257
            support_map('bl_img_save') = false; 
< 0.001 
      1 
 258
        end 
< 0.001 
      1 
 259
    end 
< 0.001 
      1 
 260
    if (ismember(it_subset, [3])) 
 261 
        % Profile run
 262 
        support_map('bl_profile') = true;
 263 
        support_map('bl_display') = false; % don't print
 264 
        support_map('bl_time') = true;
 265 
    end
< 0.001 
      1 
 266
end 
 267 

 268 
%% Subset Options for Distribution solutions
 269 
%
 270 
% # it_subset = 5 is basic invoke quick test
 271 
% # it_subset = 6 is invoke full test
 272 
% # it_subset = 7 is profiling invoke
 273 
% # it_subset = 8 is matlab publish
 274 
% # it_subset = 9 is invoke operational (only final stats) and coh graph
 275 
%
 276 

< 0.001 
      1 
 277
if (ismember(it_subset, [5,6,7,8,9])) 
 278 
    if (ismember(it_subset, [5]))
 279 
        % TEST quick (need to enough to have distribution)
 280 
        param_map('it_a_n') = 100;
 281 
        param_map('it_z_wage_n') = 5;
 282 
        param_map('fl_z_r_borr_n') = 2;
 283 
        param_map('it_z_n') = param_map('it_z_wage_n') * param_map('fl_z_r_borr_n');
 284 
        param_map('it_maxiter_val') = 50;
 285 
        param_map('it_maxiter_dist') = 50;
 286 
        param_map('it_tol_pol_nochange') = 1000;
 287 
        support_map('bl_display_dist') = true;
 288 
    end
 289 
    if (ismember(it_subset, [6, 8, 9]))
 290 
        % close all
 291 
        close all;
 292 
        % Main Run
 293 
        support_map('bl_time') = true;
 294 
        support_map('bl_display_defparam') = true;
 295 
        support_map('bl_display') = false;
 296 
        support_map('bl_display_dist') = true;
 297 
        support_map('it_display_every') = 20;
 298 

 299 
        support_map('bl_post') = true;
 300 
        support_map('bl_display_final_dist') = true;
 301 
        support_map('bl_mat') = false;
 302 
        support_map('bl_graph') = true;
 303 
        support_map('bl_graph_onebyones') = false;
 304 
        support_map('bl_img_save') = true;
 305 

 306 
        % do not generate all graphs when solving for distribution
 307 
        support_map('bl_graph_val') = false;
 308 
        support_map('bl_graph_pol_lvl') = false;
 309 
        support_map('bl_graph_pol_pct') = false;
 310 
        support_map('bl_graph_coh_t_coh') = true;
 311 
        support_map('bl_graph_forinf_discrete') = false;
 312 
        support_map('bl_graph_forinf_pol_lvl') = false;
 313 
        support_map('bl_graph_forinf_pol_pct') = true;
 314 

 315 
        if (ismember(it_subset, [8, 9]))
 316 
            support_map('bl_time') = false;
 317 
            support_map('bl_display') = false;
 318 
            support_map('bl_display_dist') = false;
 319 
            support_map('bl_display_final_dist_detail') = true;
 320 
            support_map('bl_graph_onebyones') = true;
 321 
            support_map('bl_img_save') = false;
 322 
            if (ismember(it_subset, [9]))
 323 
                support_map('bl_display_final_dist_detail') = false;
 324 
                support_map('bl_display_defparam') = false;
 325 
                support_map('bl_graph_coh_t_coh') = false;
 326 
                support_map('bl_graph_forinf_pol_pct') = false;
 327 
            end
 328 
        end
 329 

 330 
    end
 331 
    if (ismember(it_subset, [7]))
 332 
        % Profile run
 333 
        support_map('bl_profile_dist') = true;
 334 
        support_map('bl_display') = false; % don't print
 335 
        support_map('bl_display_dist') = false; % don't print
 336 
        support_map('bl_time') = true;
 337 
    end
 338 
end
 339 

 340 
%% Display
 341 

< 0.001 
      1 
 342
if (bl_display_defparam) 
 343 
    disp('param_map');
 344 
    disp(param_map);
 345 
    param_map_keys = keys(param_map);
 346 
    param_map_vals = values(param_map);
 347 
    for i = 1:length(param_map)
 348 
        st_display = strjoin(['pos =' num2str(i) '; key =' string(param_map_keys{i}) '; val =' string(param_map_vals{i})]);
 349 
        disp(st_display);
 350 
    end
 351 

 352 
    disp('support_map')
 353 
    disp(support_map);
 354 
    param_map_keys = keys(support_map);
 355 
    param_map_vals = values(support_map);
 356 
    for i = 1:length(support_map)
 357 
        st_display = strjoin(['pos =' num2str(i) '; key =' string(param_map_keys{i}) '; val =' string(param_map_vals{i})]);
 358 
        disp(st_display);
 359 
    end
 360 
end
 361 

< 0.001 
      1 
 362
end 

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