Skip to content

Commit

Permalink
update calvo addon
Browse files Browse the repository at this point in the history
  • Loading branch information
HumphreyYang committed Aug 19, 2024
1 parent 59981b7 commit 0f27284
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lectures/calvo_addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ This function will be an input into solving for a Ramsey plan using a version of

I'll move on to describe that function implicitly as a system of constraints.

```{code-cell} ipython3
!pip install jaxopt
```

```{code-cell} ipython3
from quantecon import LQ
import numpy as np
Expand Down Expand Up @@ -324,11 +320,6 @@ def objective(x, m0, model):
m, p = solve_mp(x, m0, model)
return -jnp.sum(β**jnp.arange(T+1) * (u(f(x)) + j(m - p)))
def penality(x, m0, model):
β, T = model.β, model.T
m, p = solve_mp(x, m0, model)
return -jnp.sum(β**jnp.arange(T+1) * (u(f(x)) + j(m - p)))
grad_objective = grad(lambda x: objective(x, m0=jnp.log(100), model=model))
x_init = jnp.ones(model.T+1)# Initial guess for x
optimized_x = adam_optimizer(grad_objective, x_init)
Expand All @@ -341,6 +332,10 @@ print("Optimized m_t:", optimized_m)
print("Optimized p_t:", optimized_p)
```
```{code-cell} ipython3
xs = np.linespace(0, 100, 1)
```
$$
P(\vec x, \vec m, \vec p) = \lambda_1 \sum_{t=0}^\infty \beta^t \left( m_{t} - p_t + \alpha (p_{t+1} - p_t) \right)^2
+ \lambda_2 \sum_{t=0}^\infty \beta^t \left( \exp(m_{t+1}) - \exp(m_t) + x_t \exp(p_t) \right)^2
Expand Down

0 comments on commit 0f27284

Please sign in to comment.