This is a static copy of a profile report

Home

hhsave_util_3OC (Calls: 1, Time: 4.881 s)
Generated 16-Jul-2020 17:08:28 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
70
it_zgridno, it_agridno, it_ngr...
14.137 s84.8%
25
addpath(genpath('/Users/sidhan...
10.708 s14.5%
18
close all;
10.014 s0.3%
91
mt_util= (mt_con.^(1-fl_risk) ...
10.008 s0.2%
77
mt_futassets=ones(it_agridno, ...
10.002 s0.0%
All other lines  0.012 s0.2%
Totals  4.881 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
OC3function14.135 s84.7%
genpathfunction10.585 s12.0%
addpathfunction10.122 s2.5%
closefunction10.014 s0.3%
Self time (built-ins, overhead, etc.)  0.024 s0.5%
Totals  4.881 s100% 
Code Analyzer results
Line numberMessage
21This statement (and possibly following ones) cannot be reached.
64The value assigned to variable 'fl_R' might be unused.
93If 'mt_util' is an array or cell array, performance can be improved using logical indexing instead of FIND.
109This statement (and possibly following ones) cannot be reached.
Coverage results
Show coverage for parent directory
Total lines in function98
Non-code lines (comments, blank lines)34
Code lines (lines that can run)64
Code lines that did run30
Code lines that did not run34
Coverage (did run/can run)46.88 %
Function listing
time 
Calls 
 line
  16 
function [mt_util,mt_coh, mt_k, mt_l, mt_o]=hhsave_util_3OC(varargin)
  17 

  0.014 
      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.708 
      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.5;
  50 
    fl_risk        = 1;
  51 
    ar_n          = [0,1];
  52 
    
  53 
    fl_alpha = 0.4;
  54 
    fl_theta = 0.79-fl_alpha;
  55 
    fl_delta = 0.05;
  56 
    fl_kappa = 0;
  57 
        
  58 
    [fl_r,fl_w] = ...
  59 
        deal(0.05,1.5);
  60 
    bl_print       = true;
  61 
    
< 0.001 
      1 
  62
end 
  63 

< 0.001 
      1 
  64
fl_R = fl_r + fl_delta; 
  65 

  66 
%% Calling OC3
  67 

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

  72 
%% Computing consumption     
  73 

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

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

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

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

  86 
%mt_con(neg) = NaN;
  87 

< 0.001 
      1 
  88
if(fl_risk==1) 
  89 
    mt_util=log(mt_con);
< 0.001 
      1 
  90
else 
  0.008 
      1 
  91
mt_util= (mt_con.^(1-fl_risk) -1)/(1-fl_risk);    % Utility Part of value function 
< 0.001 
      1 
  92
end 
  0.002 
      1 
  93
mt_util(neg) = -1000; 
  94 

  95 
%% Printing outputs 
  96 

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

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