Example #1
0
                 e=e,
                 w=w)

# Deterministic Steady-State
kstar = ((1 - delta * gamma) / (delta * beta))**(
    1 / (beta - 1))  # determistic steady-state capital investment
sstar = gamma * kstar + kstar**beta  # deterministic steady-state wealth

# Check Model Derivatives
# dpcheck(model,sstar,kstar)

## SOLUTION

# Solve Bellman Equation
growth.solve()
resid, s, v, k = growth.solution()

# Plot Optimal Policy
demo.figure('Optimal Investment Policy', 'Wealth', 'Investment')
plt.plot(s, k.T)

# Plot Value Function
demo.figure('Value Function', 'Wealth', 'Value')
plt.plot(s, v.T)

# Plot Shadow Price Function
demo.figure('Shadow Price Function', 'Wealth', 'Shadow Price')
plt.plot(s, growth.Value(s, order=1).T)

# Plot Residual
demo.figure('Bellman Equation Residual', 'Wealth', 'Residual')
model = DPmodel(basis, reward, transition, bounds,
                i=['Low price', 'Average price', 'High Price'],
                x=['Current production'],
                discount=delta, q=q)


# Check Model Derivatives
# dpcheck(model,sstar,sstar)


## SOLUTION

# Solve Bellman Equation
model.solve()
resid, s, v, x = model.solution()

"""





# Plot Optimal Policy
figure
plot(s,x)
legend('Low Price','Average Price','High Price')
legend('Location','Best')
legend('boxoff')
title('Optimal Production Policy')
xlabel('Lagged Production')
Example #3
0
                reward,
                transition,
                bounds,
                i=['Low price', 'Average price', 'High Price'],
                x=['Current production'],
                discount=delta,
                q=q)

# Check Model Derivatives
# dpcheck(model,sstar,sstar)

## SOLUTION

# Solve Bellman Equation
model.solve()
resid, s, v, x = model.solution()
"""





# Plot Optimal Policy
figure
plot(s,x)
legend('Low Price','Average Price','High Price')
legend('Location','Best')
legend('boxoff')
title('Optimal Production Policy')
xlabel('Lagged Production')
ylabel('Production')
qstar = sstar - (delta * alpha - 1) / (delta * beta) 	# steady-state action

# Print Steady-States
print('Steady States')
print('\tStock   = %5.2f' % sstar)
print('\tHarvest = %5.2f' % qstar)

# Check Model Derivatives
# dpcheck(model,sstar,qstar)


## SOLUTION

# Solve Bellman Equation
model.solve()
resid, s, v, q = model.solution()

# Plot Optimal Policy
demo.figure('Optimal Harvest Policy', 'Stock', 'Harvest')
plt.plot(s, q.T)

# Plot Value Function
demo.figure('Value Function', 'Stock', 'Value')
plt.plot(s, v.T)

# Plot Shadow Price Function
demo.figure('Shadow Price Function', 'Stock', 'Shadow Price')
plt.plot(s, model.Value(s, 1).T)

# Plot Residual
demo.figure('Bellman Equation Residual','Stock', 'Residual')
sstar = (alpha**2 - 1 / delta**2) / (2 * beta)  # steady-state stock
qstar = sstar - (delta * alpha - 1) / (delta * beta)  # steady-state action

# Print Steady-States
print('Steady States')
print('\tStock   = %5.2f' % sstar)
print('\tHarvest = %5.2f' % qstar)

# Check Model Derivatives
# dpcheck(model,sstar,qstar)

## SOLUTION

# Solve Bellman Equation
model.solve()
resid, s, v, q = model.solution()

# Plot Optimal Policy
demo.figure('Optimal Harvest Policy', 'Stock', 'Harvest')
plt.plot(s, q.T)

# Plot Value Function
demo.figure('Value Function', 'Stock', 'Value')
plt.plot(s, v.T)

# Plot Shadow Price Function
demo.figure('Shadow Price Function', 'Stock', 'Shadow Price')
plt.plot(s, model.Value(s, 1).T)

# Plot Residual
demo.figure('Bellman Equation Residual', 'Stock', 'Residual')
                 x=['investment'], discount=delta, e=e, w=w)


# Deterministic Steady-State
kstar = ((1 - delta * gamma) / (delta * beta)) ** (1 / (beta - 1))  # determistic steady-state capital investment
sstar = gamma * kstar + kstar ** beta       	# deterministic steady-state wealth

# Check Model Derivatives
# dpcheck(model,sstar,kstar)


## SOLUTION

# Solve Bellman Equation
growth.solve()
resid, s, v, k = growth.solution()

# Plot Optimal Policy
demo.figure('Optimal Investment Policy',  'Wealth', 'Investment')
plt.plot(s, k.T)

# Plot Value Function
demo.figure('Value Function', 'Wealth', 'Value')
plt.plot(s, v.T)

# Plot Shadow Price Function
demo.figure('Shadow Price Function', 'Wealth', 'Shadow Price')
plt.plot(s, growth.Value(s, order=1).T)