Skip to content

Commit 79c9099

Browse files
jstacclaude
andcommitted
Adjust parameters: y_size=100 and m=50 for better OPI speedup demonstration
- Change y_size back to 100 in both ifp_discrete.md and ifp_opi.md - Change OPI timing comparison to use m=50 instead of m=10 - With these settings, OPI shows 6.7x speedup vs VFI (compared to 3.9x with m=10) - Provides better demonstration of OPI's performance advantage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 84943bc commit 79c9099

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lectures/ifp_discrete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def create_consumption_model(
170170
a_min=0.01, # Min assets
171171
a_max=10.0, # Max assets
172172
a_size=150, # Grid size
173-
ρ=0.9, ν=0.1, y_size=12 # Income parameters
173+
ρ=0.9, ν=0.1, y_size=100 # Income parameters
174174
):
175175
"""
176176
Creates an instance of the consumption-savings model.

lectures/ifp_opi.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def create_consumption_model(
9090
a_min=0.01, # Min assets
9191
a_max=10.0, # Max assets
9292
a_size=150, # Grid size
93-
ρ=0.9, ν=0.1, y_size=12 # Income parameters
93+
ρ=0.9, ν=0.1, y_size=100 # Income parameters
9494
):
9595
"""
9696
Creates an instance of the consumption-savings model.
@@ -324,9 +324,9 @@ print(f"VFI completed in {vfi_time:.2f} seconds.")
324324
Now let's time OPI with different values of m:
325325

326326
```{code-cell} ipython3
327-
print("Starting OPI with m=10.")
327+
print("Starting OPI with m=50.")
328328
start = time()
329-
v_star_opi, σ_star_opi = optimistic_policy_iteration(model, m=10)
329+
v_star_opi, σ_star_opi = optimistic_policy_iteration(model, m=50)
330330
v_star_opi.block_until_ready()
331331
opi_time_with_compile = time() - start
332332
print(f"OPI completed in {opi_time_with_compile:.2f} seconds.")
@@ -336,7 +336,7 @@ Run it again:
336336

337337
```{code-cell} ipython3
338338
start = time()
339-
v_star_opi, σ_star_opi = optimistic_policy_iteration(model, m=10)
339+
v_star_opi, σ_star_opi = optimistic_policy_iteration(model, m=50)
340340
v_star_opi.block_until_ready()
341341
opi_time = time() - start
342342
print(f"OPI completed in {opi_time:.2f} seconds.")

0 commit comments

Comments
 (0)