def _new_solution(sp, f, grp): "gets a new set of solution objects and updates the data file" # compute value function and policy rule using vfi v_init = np.zeros(len(sp.grid_points)) + sp.c / (1 - sp.beta) v = compute_fixed_point(sp.bellman_operator, v_init, error_tol=_tol, max_iter=5000) phi_vfi = sp.get_greedy(v) # also run v through bellman so I can test if it is a fixed point # bellman_operator takes a long time, so store result instead of compute new_v = sp.bellman_operator(v) # compute policy rule using pfi phi_init = np.ones(len(sp.pi_grid)) phi_pfi = compute_fixed_point(sp.res_wage_operator, phi_init, error_tol=_tol, max_iter=5000) # write all arrays to file write_array(f, grp, v, "v") write_array(f, grp, phi_vfi, "phi_vfi") write_array(f, grp, phi_pfi, "phi_pfi") write_array(f, grp, new_v, "new_v") # return data return v, phi_vfi, phi_pfi, new_v
def _new_solution(gm, f, grp): "gets a new set of solution objects and updates the data file" # compute value function and policy rule using vfi v_init = 5 * gm.u(gm.grid) - 25 v = compute_fixed_point(gm.bellman_operator, v_init, error_tol=_tol, max_iter=5000) # sigma = gm.get_greedy(v) # write all arrays to file write_array(f, grp, v, "v") # return data return v
def _new_solution(tree, f, grp): "gets a new set of prices and updates the file" prices = tree.compute_lt_price(error_tol=_tol, max_iter=5000) write_array(f, grp, prices, "prices") return prices
def _new_solutions(cp, f, grp, which="both"): v_init, c_init = cp.initialize() if which == "both": v_vfi, c_vfi = _solve_via_vfi(cp, v_init, return_both=True) c_pfi = _solve_via_pfi(cp, c_init) # Store solutions in chunked arrays... write_array(f, grp, c_vfi, "c_vfi") write_array(f, grp, v_vfi, "v_vfi") write_array(f, grp, c_pfi, "c_pfi") return v_vfi, c_vfi, c_pfi elif which == "vfi": v_vfi, c_vfi = _solve_via_vfi(cp, v_init, return_both=True) write_array(f, grp, c_vfi, "c_vfi") write_array(f, grp, v_vfi, "v_vfi") return v_vfi, c_vfi elif which == "pfi": c_pfi = _solve_via_pfi(cp, c_init) write_array(f, grp, c_pfi, "c_pfi") return c_pfi
def _new_solution(jv, f, grp): "gets new solution and updates data file" V = _solve_via_vfi(jv) write_array(f, grp, V, v_nm) return V