Simplify McCall model: Compute reservation wage directly from value function#695
Simplify McCall model: Compute reservation wage directly from value function#695
Conversation
…unction This commit simplifies the job search model by eliminating the intermediate policy array and computing the reservation wage directly from the value function. Key changes: - Removed `get_greedy` function entirely - Modified `get_reservation_wage` to compute directly from value function v_u - Updated `update_agent` to use reservation wage (scalar) instead of policy array - Updated all simulation functions to work with reservation wage Benefits: - Simpler, more intuitive code - More efficient (no need to store full policy array) - Clearer conceptually (directly compute and use the threshold) The reservation wage is now computed by finding the lowest wage where: accept value >= reject value, which directly implements the optimal policy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
📖 Netlify Preview Ready! Preview URL: https://pr-695--sunny-cactus-210e3e.netlify.app (fd20ea1) 📚 Changed Lecture Pages: mccall_model_with_sep_markov |
Remove @jax.jit from the update_agent function. When a top-level function is already JIT-compiled (like _simulate_cross_section_compiled), adding @jax.jit to intermediate functions creates nested compilation boundaries that can prevent optimizations. Performance benchmarks show this change provides 0-16% speedup for typical problem sizes, as the top-level JIT compilation traces through the entire computation graph more efficiently without the nested decorator. This follows JAX best practices: only JIT-compile top-level functions and let them trace through intermediate functions naturally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Performance optimization: Removed nested @jax.jit decoratorI've removed the Why this change?In JAX, when a top-level function is already JIT-compiled (like Performance impactI ran benchmarks comparing both versions:
For typical problem sizes (medium/large), removing the nested JIT provides 5-16% speedup. JAX best practiceThis follows the JAX pattern: only JIT-compile top-level functions and let them trace through intermediate functions naturally. The top-level JIT compilation traces through the entire computation graph and optimizes it holistically. The code is now simpler and faster! 🚀 |
|
📖 Netlify Preview Ready! Preview URL: https://pr-695--sunny-cactus-210e3e.netlify.app (34a3c62) 📚 Changed Lecture Pages: mccall_model_with_sep_markov |
Summary
This PR simplifies the job search model with separation and Markov wages by eliminating unnecessary intermediate computations and directly computing the reservation wage from the value function.
Motivation
The original code computed an optimal policy array using
get_greedy, then extracted the reservation wage from that policy. Since the optimal policy is a reservation wage strategy (accept all wages above a threshold), we can compute this threshold directly without the intermediate step.Key changes
1. Removed
get_greedyfunction2. Modified
get_reservation_wagefunctionσand extracted the reservation wagev_udirectly and computes the reservation wage by finding where acceptance becomes optimalaccept >= reject3. Updated
update_agentfunctionσand looked upσ[wage_idx]to make decisionsw_star(scalar) and comparesw_vals[wage_idx] >= w_star4. Updated all simulation functions
simulate_employment_path: Now takesw_starinstead ofσ_simulate_cross_section_compiled: Now takesw_starinstead ofσplot_cross_sectional_unemployment: Computesw_stardirectlyBenefits
Testing
🤖 Generated with Claude Code