Example #1
0
def retirementChoiceSolver(solution_tp1,income_distrib,p_zero_income,survival_prob,beta,rho,R,Gamma,constrained,a_grid,calc_vFunc,cubic_splines,solution_retired):
    '''
    Solves one period of an infinite horizon retirement choice problem.
    '''
    # Solve the period when we're working
    solution_working = consumptionSavingSolverENDG(solution_tp1,income_distrib,p_zero_income,survival_prob,beta,rho,R,Gamma,constrained,a_grid,calc_vFunc,cubic_splines)
    
    # Determine which choice is best at "infinity"
    large_m = 1000.0*np.max(a_grid)
    v_check = np.asarray([solution_working.vFunc(large_m),solution_retired.vFunc(large_m)])
    v_best = np.argmax(v_check)
    
    # Construct and return the solution for this period    
    vFunc = [solution_working.vFunc,solution_retired.vFunc]
    vPfunc = [solution_working.vPfunc,solution_retired.vPfunc]
    solution_t = DiscreteChoiceSolution(vFunc,vPfunc)
    solution_t.cFunc = [solution_working.cFunc,solution_retired.cFunc]
    solution_t.m_underbar = 0
    solution_t.kappa_max = np.min(solution_working.kappa_max,solution_retired.kappa_max)
    if v_best < -1:
        solution_t.kappa_min = solution_working.kappa_min
        solution_t.gothic_h = solution_working.gothic_h
    else:
        solution_t.kappa_min = solution_retired.kappa_min
        solution_t.gothic_h = solution_retired.gothic_h
    solution_t.v_lim_slope = solution_t.kappa_min**(-rho/(1.0-rho))
    solution_t.v_lim_intercept = solution_t.gothic_h*solution_t.v_lim_slope
    return solution_t
Example #2
0
def occupationalChoiceSolver(solution_tp1,income_distrib,p_zero_income,survival_prob,beta,rho,R,Gamma,constrained,a_grid,calc_vFunc,cubic_splines):
    '''
    Need to write a real description here.
    '''
    # Initialize lists to hold the solution for each occupation
    vFunc = []
    vPfunc = []
    cFunc = []
    m_underbar = []
    gothic_h = []
    kappa_min = []
    kappa_max = []
    v_check = []
    
    # Solve the consumption-saving problem for each possible occupation
    job_count = len(Gamma)
    large_m = 100.0*np.max(a_grid)
    for j in range(job_count):
        solution_temp = consumptionSavingSolverENDG(solution_tp1,income_distrib[j],p_zero_income[j],survival_prob,beta,rho,R,Gamma[j],constrained,a_grid,calc_vFunc,cubic_splines)
        vFunc.append(deepcopy(solution_temp.vFunc))
        vPfunc.append(deepcopy(solution_temp.vPfunc))
        cFunc.append(deepcopy(solution_temp.cFunc))
        m_underbar.append(solution_temp.m_underbar)
        gothic_h.append(solution_temp.gothic_h)
        kappa_min.append(solution_temp.kappa_min)
        kappa_max.append(solution_temp.kappa_max)
        v_check.append(solution_temp.vFunc(large_m))
    
    # Find the best job at "infinity" resources
    v_check = np.asarray(v_check)
    v_best = np.argmax(v_check)
    
    # Construct the solution for this phase
    solution_t = DiscreteChoiceSolution(vFunc,vPfunc)
    solution_t.cFunc = cFunc
    solution_t.m_underbar = np.max(m_underbar)
    solution_t.kappa_min = kappa_min[v_best]
    solution_t.kappa_max = np.min(kappa_max)
    solution_t.gothic_h = gothic_h[v_best]
    solution_t.v_lim_slope = solution_t.kappa_min**(-rho/(1.0-rho))
    solution_t.v_lim_intercept = solution_t.gothic_h*solution_t.v_lim_slope
    
    return solution_t
Example #3
0
 def preSolve(self):
     '''
     Before using time iteration, the retired solution can be found in closed
     form.  It is stored here in scaled form, then unscaled in postSolve.
     '''
     self.value_scale = (1.0-self.labor_supply)**(self.alpha*(1.0-self.rho))
     
     temp_beta = self.survival_prob*self.beta
     kappa_PF = 1.0 - (self.R*temp_beta)**(1.0/self.rho)/self.R
     cFunc_retired = lambda m : kappa_PF*m
     vPfunc_retired = lambda m : CRRAutilityP(m,gam=self.rho)/self.value_scale
     vFunc_retired = lambda m: CRRAutility(kappa_PF**(-self.rho/(1.0-self.rho))*m,gam=self.rho)/self.value_scale
     
     solution_retired = DiscreteChoiceSolution(vFunc_retired,vPfunc_retired)
     solution_retired.cFunc = cFunc_retired
     solution_retired.kappa_min = kappa_PF
     solution_retired.kappa_max = kappa_PF
     solution_retired.gothic_h = 0.0
     
     self.solution_retired = solution_retired
     self.updateSolutionTerminal()