L = nvec.sum() #Firm parameters A = 1.0 alpha = 0.35 delta_annual = 0.05 delta = 1 - ((1 - delta_annual)**20) ''' Problem 1: Checking if feasible () works properly ''' b_guess_1 = np.array([1.0, 1.2]) b_guess_2 = np.array([0.06, -0.001]) b_guess_3 = np.array([0.1, 0.1]) f_params = (nvec, A, alpha, delta) results1 = np.array(ss.feasible(f_params, b_guess_1)) results2 = np.array(ss.feasible(f_params, b_guess_2)) results3 = np.array(ss.feasible(f_params, b_guess_3)) print(results1) print(results2) print(results3) ''' Problem 2: Solving steady state ''' # SS parameters SS_tol = 1e-13 SS_graphs = False bvec_guess = np.array([0.1, 0.1]) f_params = (nvec, A, alpha, delta) b_cnstr, c_cnstr, K_cnstr = ss.feasible(f_params, bvec_guess)
bvec_guess1 = (2,) vector, guess for steady-state bvec (b1, b2) b_cnstr = (2,) Boolean vector, =True if b_s causes negative consumption c_s <= 0 or negative aggregate capital stock K <= 0 c_cnstr = (3,) Boolean vector, =True for elements of negative consumption c_s <= 0 K_cnstr = Boolean, =True if K <= 0 bvec_guess2 = (2,) vector, guess for steady-state bvec (b1, b2) bvec_guess3 = (2,) vector, guess for steady-state bvec (b1, b2) ------------------------------------------------------------------------ ''' f_params = (nvec, A, alpha, delta) bvec_guess1 = np.array([1.0, 1.2]) b_cnstr, c_cnstr, K_cnstr = ss.feasible(f_params, bvec_guess1) print('bvec_guess1', bvec_guess1) print('c_cnstr', c_cnstr) print('K_cnstr', K_cnstr) bvec_guess2 = np.array([0.06, -0.001]) b_cnstr, c_cnstr, K_cnstr = ss.feasible(f_params, bvec_guess2) print('bvec_guess2', bvec_guess2) print('c_cnstr', c_cnstr) print('K_cnstr', K_cnstr) bvec_guess3 = np.array([0.1, 0.1]) b_cnstr, c_cnstr, K_cnstr = ss.feasible(f_params, bvec_guess3) print('bvec_guess3', bvec_guess3) print('c_cnstr', c_cnstr) print('K_cnstr', K_cnstr)
cur_path = os.path.split(os.path.abspath(__file__))[0] ss_output_fldr = 'OUTPUT/SS' ss_output_dir = os.path.join(cur_path, ss_output_fldr) if not os.access(ss_output_dir, os.F_OK): os.makedirs(ss_output_dir) ss_outputfile = os.path.join(ss_output_dir, 'ss_vars.pkl') ss_paramsfile = os.path.join(ss_output_dir, 'ss_args.pkl') # Compute steady-state solution if SS_solve: print('BEGIN EQUILIBRIUM STEADY-STATE COMPUTATION') # Make initial guess for b_ss and make sure it is feasible # (K >= epsilon) bss_guess = 0.05 * np.ones(S - 1) f_params = (nvec, A, alpha, delta) cg_cstr, Kg_cstr, bg_cstr = ss.feasible(bss_guess, f_params) if Kg_cstr or cg_cstr.max(): if Kg_cstr: err_msg = ('ERROR: Initial guess for b_ss (bss_guess) ' + 'caused an infeasible value for K ' + '(K < epsilon)') raise RuntimeError(err_msg) elif not Kg_cstr and cg_cstr.max(): err_msg = ('ERROR: Initial guess for b_ss (bss_guess) ' + 'caused infeasible value(s) for c_s ' + '(c_s <= 0)') print('cg_cstr: ', cg_cstr) raise RuntimeError(err_msg) else: ss_args = (nvec, beta, sigma, A, alpha, delta, SS_tol, SS_EulDiff) ss_output = ss.get_SS(bss_guess, ss_args, SS_graphs) # Save ss_output as pickle