% Find an optimal fixed policy: returns
% fraction of wealth consumed, fraction of saving to risky asset
% average IN-SAMPLE utility across scenarios
function [fractCons, fractRisky, aveUtil] = ...
    FindFixedPolicy(W0, empl0, utilFun, gamma, incomeValues, ...
        riskFree, retPaths, emplPaths)
% the objective function is in-sample performance of a given policy    
objFun = @(X) -RunFixedPolicy(X, W0, empl0, utilFun, gamma, incomeValues, ...
        riskFree, retPaths, emplPaths);
X0 = [0.5; 0.5]; % starting point for fmincon
options = optimoptions(@fmincon,'Display','off');
[bestX, bestVal] = fmincon(objFun, X0, [], [], [], [], zeros(2,1), ...
    ones(2,1), [], options);
fractCons = bestX(1);
fractRisky = bestX(2);
aveUtil = -bestVal;


