Skip to content

Commit

Permalink
simplified constraint checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-magnusson committed Jul 17, 2015
1 parent 9840bf3 commit 1602cf6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Python/CURRENT_DEBUGGED_VERSION/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ def Steady_state_TPI_solver(guesses, winit, rinit, BQinit, T_H_init, factor, j,

print'Checking time path for violations of constaints.'
for t in xrange(T):
house.constraint_checker_TPI(b_mat[t, :-1, :], n_mat[
t], c_path[t], t, parameters, N_tilde)
house.constraint_checker_TPI(b_mat[t], n_mat[t], c_path[t], t, parameters)

eul_savings = euler_errors[:, :S, :].max(1).max(1)
eul_laborleisure = euler_errors[:, S:, :].max(1).max(1)
Expand Down
11 changes: 2 additions & 9 deletions Python/CURRENT_DEBUGGED_VERSION/household_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,8 @@ def constraint_checker_SS(bssmat, nssmat, cssmat, params):
'''
print 'Checking constraints on capital, labor, and consumption.'
J, S, T, beta, sigma, alpha, Z, delta, ltilde, nu, g_y, g_n_ss, tau_payroll, retire, mean_income_data, a_tax_income, b_tax_income, c_tax_income, d_tax_income, h_wealth, p_wealth, m_wealth, b_ellipse, upsilon = params
flag1 = False
if bssmat.sum() <= 0:
print '\tWARNING: Aggregate capital is less than or equal to zero.'
flag1 = True
if (bssmat < 0).any():
print '\tWARNING: There is negative capital stock'
if flag1 is False:
print '\tThere were no violations of the borrowing constraints.'
flag2 = False
if (nssmat < 0).any():
print '\tWARNING: Labor supply violates nonnegativity constraints.'
Expand All @@ -228,21 +222,20 @@ def constraint_checker_SS(bssmat, nssmat, cssmat, params):
print '\tThere were no violations of the constraints on consumption.'


def constraint_checker_TPI(b_dist, n_dist, c_dist, t, params, N_tilde):
def constraint_checker_TPI(b_dist, n_dist, c_dist, t, params):
'''
Inputs:
b_dist = distribution of capital (SxJ array)
n_dist = distribution of labor (SxJ array)
c_dist = distribution of consumption (SxJ array)
t = time period (scalar)
params = list of parameters (list)
N_tilde = population size in time period (Tx1 array)
Output:
Prints warnings for violations of capital, labor, and
consumption constraints.
'''
J, S, T, beta, sigma, alpha, Z, delta, ltilde, nu, g_y, g_n_ss, tau_payroll, retire, mean_income_data, a_tax_income, b_tax_income, c_tax_income, d_tax_income, h_wealth, p_wealth, m_wealth, b_ellipse, upsilon = params
if b_dist.sum() / N_tilde[t] <= 0:
if (b_dist <= 0).any():
print '\tWARNING: Aggregate capital is less than or equal to ' \
'zero in period %.f.' % t
if (n_dist < 0).any():
Expand Down

0 comments on commit 1602cf6

Please sign in to comment.