This is a static copy of a profile report

Home

hhsave_util_3OC (Calls: 1, Time: 2.281 s)
Generated 18-Jul-2020 08:10:34 using performance time.
function in file /Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Households/hhsave_util_3OC.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
hhsave_VFI_3OCfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
69
it_zgridno, it_agridno, it_ngr...
11.836 s80.5%
25
addpath(genpath('/Users/sidhan...
10.420 s18.4%
92
mt_util= (mt_con.^(1-fl_risk) ...
10.010 s0.4%
32
fl_alpha,fl_theta,fl_delta,fl_...
10.002 s0.1%
18
close all;
10.002 s0.1%
All other lines  0.011 s0.5%
Totals  2.281 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
OC3function11.833 s80.4%
genpathfunction10.313 s13.7%
addpathfunction10.107 s4.7%
closefunction10.001 s0.1%
Self time (built-ins, overhead, etc.)  0.026 s1.1%
Totals  2.281 s100% 
Code Analyzer results
Line numberMessage
21This statement (and possibly following ones) cannot be reached.
63The value assigned to variable 'fl_R' might be unused.
94If 'mt_util' is an array or cell array, performance can be improved using logical indexing instead of FIND.
95If 'mt_util' is an array or cell array, performance can be improved using logical indexing instead of FIND.
112This statement (and possibly following ones) cannot be reached.
Coverage results
Show coverage for parent directory
Total lines in function101
Non-code lines (comments, blank lines)35
Code lines (lines that can run)66
Code lines that did run32
Code lines that did not run34
Coverage (did run/can run)48.48 %
Function listing
time 
Calls 
 line
  16 
function [mt_util,mt_coh, mt_k, mt_l, mt_o]=hhsave_util_3OC(varargin)
  17 

  0.002 
      1 
  18
close all; 
< 0.001 
      1 
  19
bl_profile = false;      % Switch off profile if running a tester/calling from another function 
< 0.001 
      1 
  20
if(bl_profile) 
  21 
profile off;
  22 
profile on;
< 0.001 
      1 
  23
end 
  24 

  0.420 
      1 
  25
addpath(genpath('/Users/sidhantkhanna/Documents/GitHub/BKS modified/')); 
  26 

  27 
%% Assigning parameters
  28 

< 0.001 
      1 
  29
if ~isempty(varargin) 
  30 
    
  0.004 
      1 
  31
    [ar_a,ar_z,ar_n, ... 
      1 
  32
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  33
         fl_risk,it_zgridno, it_agridno,it_ngridno ... 
      1 
  34
        ] = varargin{:}; 
  35 
    
< 0.001 
      1 
  36
    bl_print  = false; 
  37 

  38 
    
  39 
else
  40 
    close all;
  41 
    
  42 
    fl_ahi         = 5;
  43 
    fl_zhi         = 2.2;
  44 
    it_agridno     = 4;
  45 
    it_zgridno     = 5;
  46 
    it_ngridno     = 2;
  47 
    ar_a = linspace(0,fl_ahi,it_agridno);
  48 
    ar_z = linspace(1,fl_zhi,it_zgridno);
  49 
    fl_phi         = 0;
  50 
    fl_risk        = 1;
  51 
    ar_n          = [0,1];
  52 
    fl_alpha = 0.4;
  53 
    fl_theta = 0.79-fl_alpha;
  54 
    fl_delta = 0.05;
  55 
    fl_kappa = 0;
  56 
        
  57 
    [fl_r,fl_w] = ...
  58 
        deal(0.05,1.5);
  59 
    bl_print       = true;
  60 
    
< 0.001 
      1 
  61
end 
  62 

< 0.001 
      1 
  63
fl_R = fl_r + fl_delta; 
  64 

  65 
%% Calling OC3
  66 

  1.836 
      1 
  67
[mt_o, mt_coh, mt_k, mt_l] = OC3(ar_a,ar_z,ar_n, ... 
      1 
  68
        fl_alpha,fl_theta,fl_delta,fl_kappa,fl_r,fl_w,fl_phi,fl_ahi,fl_zhi, ... 
      1 
  69
         it_zgridno, it_agridno, it_ngridno); 
  70 

  71 
%% Computing consumption     
  72 

< 0.001 
      1 
  73
mt4_coh= repmat (mt_coh, [1 1 1 it_agridno]); 
  74 
%Projecting COH matrix to a 4th dimension of size of asset grid which will be used for evaluating optimal future assets
  75 

  0.001 
      1 
  76
mt_futassets=ones(it_agridno, it_zgridno, it_ngridno, it_agridno).*ar_a'; 
  77 
% 4d asset matrix to subtract future assets from COH to compute consumption
  78 

  0.001 
      1 
  79
mt_futassets=permute(mt_futassets,[4 2 3 1]);         
  80 
        
< 0.001 
      1 
  81
mt_con = mt4_coh-mt_futassets;                       % Consumption Matrix for each a, z, future a 
  82 

  0.002 
      1 
  83
neg = find(mt_con<0); 
< 0.001 
      1 
  84
zero = find(mt_con==0); 
  85 

  86 

  87 
%mt_con(neg) = NaN;
  88 

< 0.001 
      1 
  89
if(fl_risk==1) 
  90 
    mt_util=log(mt_con);
< 0.001 
      1 
  91
else 
  0.010 
      1 
  92
mt_util= (mt_con.^(1-fl_risk) -1)/(1-fl_risk);    % Utility Part of value function 
< 0.001 
      1 
  93
end 
  0.001 
      1 
  94
mt_util(neg) = -10^20; 
< 0.001 
      1 
  95
mt_util(zero) = -100; 
  96 

  97 

  98 
%% Printing outputs 
  99 

< 0.001 
      1 
 100
if(bl_print) 
 101 
    disp('Below is the COH matrix for for all combinations of a, z, n and future a');
 102 
    disp(mt4_coh);
 103 
    disp('Below is the future assets matrix for each combination of a, z, n and future a');
 104 
    disp(mt_futassets);
 105 
    disp('Below is the consumption matrix for for all combinations of a, z, n and future a');
 106 
    disp(mt_con);
 107 
    disp('Below is the utility matrix for for all combinations of a, z, n and future a');
 108 
    disp(mt_util);
< 0.001 
      1 
 109
 end 
 110 

< 0.001 
      1 
 111
if(bl_profile) 
 112 
profile off;
 113 
profile viewer;
 114 
st_file_name = '/Users/sidhantkhanna/Documents/GitHub/BKS modified/code/Profile/Households/hhsave_util_2OC';
 115 
profsave(profile('info'), st_file_name);
< 0.001 
      1 
 116
end