This is a static copy of a profile report

Home

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

Home

ffs_ipwkbz_set_default_param (Calls: 1, Time: 0.027 s)
Generated 13-Jul-2019 20:42:28 using performance time.
function in file C:\Users\fan\CodeDynaAsset\m_ipwkbz\paramfunc\ffs_ipwkbz_set_default_param.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ff_ipwkbz_vf_vecsvfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
228
close all;
10.009 s35.5%
173
support_map('st_profile_suffix...
10.005 s18.5%
230
if (ismember(it_subset, [3]))
10.004 s14.3%
236
elseif (ismember(it_subset, [1...
10.003 s12.4%
155
[st_root_path] = preamble(fals...
10.001 s4.1%
All other lines  0.004 s15.1%
Totals  0.027 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
closefunction10.009 s34.8%
ismemberfunction60.007 s26.5%
num2strfunction30.005 s17.6%
preamblefunction10.001 s3.2%
Self time (built-ins, overhead, etc.)  0.005 s17.9%
Totals  0.027 s100% 
Code Analyzer results
Line numberMessage
171Use of brackets [] is unnecessary. Use parentheses to group, if needed.
172Use of brackets [] is unnecessary. Use parentheses to group, if needed.
191Use of brackets [] is unnecessary. Use parentheses to group, if needed.
192Use of brackets [] is unnecessary. Use parentheses to group, if needed.
207Use of brackets [] is unnecessary. Use parentheses to group, if needed.
208Use of brackets [] is unnecessary. Use parentheses to group, if needed.
230Use of brackets [] is unnecessary. Use parentheses to group, if needed.
251Use of brackets [] is unnecessary. Use parentheses to group, if needed.
269Use of brackets [] is unnecessary. Use parentheses to group, if needed.
288Use of brackets [] is unnecessary. Use parentheses to group, if needed.
319Use of brackets [] is unnecessary. Use parentheses to group, if needed.
347Use of brackets [] is unnecessary. Use parentheses to group, if needed.
Coverage results
Show coverage for parent directory
Total lines in function357
Non-code lines (comments, blank lines)174
Code lines (lines that can run)183
Code lines that did run111
Code lines that did not run72
Coverage (did run/can run)60.66 %
Function listing
time 
Calls 
 line
   7 
function [param_map, support_map] = ffs_ipwkbz_set_default_param(varargin)
   8 
%% FFS_IPKBZ_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_ipwkbz_set_default_param(it_param_set);
  29 
%
  30 

  31 
%% Default
  32 

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

  43 
%% Setting param_map container
  44 

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

  47 
% model name
< 0.001 
      1 
  48
param_map('st_model') = 'ipwkbz'; 
  49 

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

  55 
%% 1b. Production Function Parameters
  56 

  57 
% CD Production Function Parameters
< 0.001 
      1 
  58
param_map('fl_Amean') = 1; 
< 0.001 
      1 
  59
param_map('fl_alpha') = 0.36; 
< 0.001 
      1 
  60
param_map('fl_delta') = 0.08; 
  61 

  62 
%% 2a. Set Borrowing Control Parameters
  63 

  64 
% Borrowing Parameters
< 0.001 
      1 
  65
param_map('fl_b_bd') = -20; % borrow bound, = 0 if save only 
< 0.001 
      1 
  66
param_map('fl_default_wprime') = 0; % wprime not a prime 
< 0.001 
      1 
  67
param_map('bl_default') = true; % if borrowing is default allowed 
  68 

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

  76 
%% 2b. Set Asset Grid Parameters
  77 

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

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

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

 102 
%% 2c. Set Asset Interpolation Parameters
 103 

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

 113 
% param_map('it_coh_interp_n') = 500;
< 0.001 
      1 
 114
param_map('it_c_interp_grid_gap') = 10^-4; 
 115 

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

 123 
%% 3. Set Interest Rates non-Shock Parameters
 124 
% Prices
 125 
% shock is on k, not on labor, fl_w is fixed wage income
 126 

< 0.001 
      1 
 127
param_map('fl_w') = 1.28*0.3466; % min(z*w) from benchmark az model 
< 0.001 
      1 
 128
param_map('fl_r_save') = 0.025; 
< 0.001 
      1 
 129
param_map('fl_r_borr') = 0.095; 
 130 

 131 
%% 4. Set Shock 2 Productivity Shock Parameters
 132 

 133 
% Production Function
 134 
% Productivity Shock Parameters
< 0.001 
      1 
 135
param_map('it_z_n') = 15; 
< 0.001 
      1 
 136
param_map('fl_z_mu') = 0; 
< 0.001 
      1 
 137
param_map('fl_z_rho') = 0.8; 
< 0.001 
      1 
 138
param_map('fl_z_sig') = 0.2; 
 139 

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

 150 
%% Setting support_map container
 151 

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

 154 
% root directory
  0.001 
      1 
 155
[st_root_path] = preamble(false); 
< 0.001 
      1 
 156
st_matimg_path_root = [st_root_path '/m_ipwkbz/']; 
< 0.001 
      1 
 157
support_map('st_matimg_path_root') = st_matimg_path_root; 
 158 

 159 
% timer
< 0.001 
      1 
 160
support_map('bl_time') = true; 
 161 

 162 
% Print Controls
< 0.001 
      1 
 163
support_map('bl_display') = true; 
< 0.001 
      1 
 164
support_map('bl_display_dist') = false; 
< 0.001 
      1 
 165
support_map('it_display_every') = 5; % how often to print results 
 166 

 167 
% Profile Controls
< 0.001 
      1 
 168
support_map('bl_profile') = false; 
< 0.001 
      1 
 169
support_map('bl_profile_dist') = false; % distribution profile 
< 0.001 
      1 
 170
support_map('st_profile_path') = [st_matimg_path_root '/solve/profile/']; 
< 0.001 
      1 
 171
support_map('st_profile_prefix') = ['']; 
< 0.001 
      1 
 172
support_map('st_profile_name_main') = ['_default']; 
  0.005 
      1 
 173
support_map('st_profile_suffix') = ['_p' num2str(it_subset)]; 
 174 

< 0.001 
      1 
 175
support_map('bl_post') = false; 
 176 

 177 
% Final Print
< 0.001 
      1 
 178
support_map('bl_display_final') = false; % print finalized results 
< 0.001 
      1 
 179
support_map('bl_display_final_dist') = false; % print finalized results 
< 0.001 
      1 
 180
support_map('bl_display_final_dist_detail') = false; 
< 0.001 
      1 
 181
support_map('it_display_final_rowmax') = 100; % max row to print (states/iters) 
< 0.001 
      1 
 182
support_map('it_display_final_colmax') = 12; % max col to print (shocks) 
< 0.001 
      1 
 183
it_display_summmat_rowmax = 5; 
< 0.001 
      1 
 184
it_display_summmat_colmax = 5; 
< 0.001 
      1 
 185
support_map('it_display_summmat_rowmax') = it_display_summmat_rowmax; 
< 0.001 
      1 
 186
support_map('it_display_summmat_colmax') = it_display_summmat_colmax; 
 187 

 188 
% Mat File Controls
< 0.001 
      1 
 189
support_map('bl_mat') = false; 
< 0.001 
      1 
 190
support_map('st_mat_path') = [st_matimg_path_root '/solve/mat/']; 
< 0.001 
      1 
 191
support_map('st_mat_prefix') = ['']; 
< 0.001 
      1 
 192
support_map('st_mat_name_main') = ['_default']; 
< 0.001 
      1 
 193
support_map('st_mat_suffix') = ['_p' num2str(it_subset)]; 
 194 

 195 
% Graphing Controls
< 0.001 
      1 
 196
support_map('bl_graph') = false; 
< 0.001 
      1 
 197
support_map('bl_graph_onebyones') = true; 
< 0.001 
      1 
 198
support_map('bl_graph_val') = true; 
< 0.001 
      1 
 199
support_map('bl_graph_pol_lvl') = true; 
< 0.001 
      1 
 200
support_map('bl_graph_pol_pct') = true; 
< 0.001 
      1 
 201
support_map('bl_graph_coh_t_coh') = true; 
 202 

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

 211 
% Sub-function graphing controls
< 0.001 
      1 
 212
support_map('bl_graph_funcgrids') = false; 
< 0.001 
      1 
 213
support_map('bl_graph_funcgrids_detail') = false; 
< 0.001 
      1 
 214
support_map('bl_display_funcgrids') = false; 
< 0.001 
      1 
 215
support_map('bl_graph_evf') = false; 
< 0.001 
      1 
 216
support_map('bl_display_evf') = false; 
< 0.001 
      1 
 217
support_map('bl_display_defparam') = false; 
 218 

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

 227 
% close figures
  0.009 
      1 
 228
close all; 
 229 

  0.004 
      1 
 230
if (ismember(it_subset, [3])) 
 231 
    % Profile run
 232 
    support_map('bl_profile') = true;
 233 
    support_map('bl_display') = false; % don't print
 234 
    support_map('bl_time') = true;
 235 

  0.003 
      1 
 236
elseif (ismember(it_subset, [1,2,4])) 
 237 

 238 
    % Main Run
< 0.001 
      1 
 239
    support_map('bl_time') = true; 
< 0.001 
      1 
 240
    support_map('bl_display_defparam') = true; 
< 0.001 
      1 
 241
    support_map('bl_display') = true; 
< 0.001 
      1 
 242
    support_map('it_display_every') = 5; 
 243 

< 0.001 
      1 
 244
    support_map('bl_post') = true; 
< 0.001 
      1 
 245
    support_map('bl_display_final') = true; 
< 0.001 
      1 
 246
    support_map('bl_mat') = false; 
< 0.001 
      1 
 247
    support_map('bl_graph') = true; 
< 0.001 
      1 
 248
    support_map('bl_graph_onebyones') = false; 
< 0.001 
      1 
 249
    support_map('bl_img_save') = true; 
 250 

< 0.001 
      1 
 251
    if (ismember(it_subset, [1])) 
 252 
        % TEST quick
 253 
        param_map('it_w_perc_n') = 20;
 254 
        param_map('it_ak_perc_n') = param_map('it_w_perc_n');
 255 
        param_map('it_z_n') = 5;
 256 

 257 
        param_map('fl_coh_interp_grid_gap') = 0.25;
 258 
        param_map('it_c_interp_grid_gap') = 0.001;
 259 
        param_map('fl_w_interp_grid_gap') = 1;
 260 

 261 
        param_map('it_maxiter_val') = 50;
 262 
        param_map('it_tol_pol_nochange') = 1000;
 263 
        support_map('bl_display') = true;
 264 
        support_map('it_display_every') = 1;
 265 

 266 
        support_map('bl_graph') = false;
 267 
    end
 268 

< 0.001 
      1 
 269
    if (ismember(it_subset, [4])) 
 270 
        support_map('bl_time') = false;
 271 
        support_map('bl_display') = false;
 272 
        support_map('bl_graph_onebyones') = true;
 273 
        support_map('bl_img_save') = false;
 274 
    end
 275 

< 0.001 
      1 
 276
end 
 277 

 278 

 279 
%% Subset Options for Distribution solutions
 280 
%
 281 
% # it_subset = 5 is basic invoke quick test
 282 
% # it_subset = 6 is invoke full test
 283 
% # it_subset = 7 is profiling invoke
 284 
% # it_subset = 8 is matlab publish
 285 
% # it_subset = 9 is invoke operational (only final stats) and coh graph
 286 
%
 287 

< 0.001 
      1 
 288
if (ismember(it_subset, [7])) 
 289 
    % Profile run
 290 
    support_map('bl_profile_dist') = true;
 291 
    support_map('bl_display') = false; % don't print
 292 
    support_map('bl_display_dist') = false; % don't print
 293 
    support_map('bl_time') = true;
 294 

< 0.001 
      1 
 295
elseif (ismember(it_subset, [5,6,8,9])) 
 296 
    % close all
 297 
    close all;
 298 

 299 
    % Main Run
 300 
    support_map('bl_time') = true;
 301 
    support_map('bl_display_defparam') = true;
 302 
    support_map('bl_display') = true;
 303 
    support_map('bl_display_dist') = true;
 304 
    support_map('it_display_every') = 20;
 305 

 306 
    support_map('bl_post') = true;
 307 
    support_map('bl_display_final_dist') = true;
 308 
    support_map('bl_mat') = false;
 309 
    support_map('bl_graph') = true;
 310 
    support_map('bl_graph_onebyones') = false;
 311 
    support_map('bl_img_save') = true;
 312 

 313 
    % do not generate all graphs when solving for distribution
 314 
    support_map('bl_graph_val') = false;
 315 
    support_map('bl_graph_pol_lvl') = false;
 316 
    support_map('bl_graph_pol_pct') = false;
 317 
    support_map('bl_graph_coh_t_coh') = true;
 318 

 319 
    if (ismember(it_subset, [5]))
 320 
        % TEST quick (need to enough to have distribution)
 321 
        param_map('it_w_perc_n') = 40;
 322 
        param_map('it_ak_perc_n') = param_map('it_w_perc_n');
 323 
        param_map('it_z_n') = 5;
 324 

 325 
        param_map('fl_coh_interp_grid_gap') = 0.25;
 326 
        param_map('it_c_interp_grid_gap') = 0.001;
 327 
        param_map('fl_w_interp_grid_gap') = 1;
 328 

 329 
        param_map('it_maxiter_val') = 50;
 330 
        param_map('it_tol_pol_nochange') = 1000;
 331 
        support_map('bl_display') = true;
 332 
        support_map('it_display_every') = 1;
 333 

 334 
        support_map('bl_display_dist') = true;
 335 
        support_map('bl_graph') = false;
 336 
    end
 337 

 338 
    if (ismember(it_subset, [8, 9]))
 339 

 340 
        support_map('bl_time') = false;
 341 
        support_map('bl_display') = false;
 342 
        support_map('bl_display_dist') = false;
 343 
        support_map('bl_display_final_dist_detail') = true;
 344 
        support_map('bl_graph_onebyones') = true;
 345 
        support_map('bl_img_save') = false;
 346 

 347 
        if (ismember(it_subset, [9]))
 348 
            % quietly turn off all graphs, only tables
 349 
            support_map('bl_display_defparam') = false;
 350 
            support_map('bl_display_final_dist_detail') = false;
 351 
            support_map('bl_graph_coh_t_coh') = false;
 352 
        end
 353 
    end
 354 
end
 355 

 356 
%% Display
 357 

< 0.001 
      1 
 358
if (bl_display_defparam) 
 359 
    fft_container_map_display(param_map, it_display_summmat_rowmax, it_display_summmat_colmax);
 360 
    fft_container_map_display(support_map, it_display_summmat_rowmax, it_display_summmat_colmax);
 361 
end
 362 

< 0.001 
      1 
 363
end 

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