Skip to content

Make the model horizon a constructor argument; shorten CI - #25

Draft
hmgaudecker wants to merge 7 commits into
feat/did-2014-pylcm604from
feat/model-horizon
Draft

hmgaudecker wants to merge 7 commits into
feat/did-2014-pylcm604from
feat/model-horizon

Conversation

@hmgaudecker

Copy link
Copy Markdown
Member

What changes

  • create_model (baseline and ACA) and create_benchmark_model take final_age, the first age at which everybody is dead. It defaults to MODEL_CONFIG.end_age (96), so existing callers build the same model as before.
  • config.model_ages(final_age=...) returns the ages from 51 through final_age. It rejects a final age that leaves no living period or goes past 96, because the age-indexed data stop at 96.
  • Nothing that depends on the ages is fixed at import time any more. The age stages, the default entry initial nodes, the next-age lookup inside the regime transitions, the transition ages, and the edges toward dead are all computed from the ages passed in. INITIAL_NODES is replaced by build_entry_initial_nodes(ages=...). initial_nodes=None (the new default) admits the entry regimes at ages 51–60 that come before the final age.
  • Age-indexed parameters are not trimmed in aca-model. pylcm drops Series rows for ages that are not on the grid. Arrays indexed by period are read only for the periods the model has, and a shorter horizon uses a prefix of them.
  • Regimes whose stage starts at or after the final age cannot be reached. Their schedule is a ByAge that holds only the dead cell as a default, and no period reads it.
  • tests/test_medical_cost_timing.py builds ages 51–53 instead of the full horizon. Its assertions are unchanged.
  • New tests:
    • a model with final_age=53 has n_periods == 3;
    • model_ages(final_age=53) == (51, 52, 53), and out-of-range final ages are rejected;
    • a survivor of age 52 moves to dead when the model ends at 53;
    • entry regimes have transition ages (51, 52).
  • tests/test_nbegm_model_creation.py is marked long_running.
  • CI installs pytest-xdist and runs pytest -n 4 --durations=20 tests. The -m "not long_running" addopts setting is unchanged.

https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW

hmgaudecker and others added 7 commits October 23, 2026 08:16
`create_model` (baseline and ACA) and `create_benchmark_model` take
`final_age`, the first age at which everybody is dead, defaulting to the
full horizon. The age stages, entry initial nodes, next-age lookup,
transition ages and edges toward `dead` are functions of the ages instead
of import-time constants. The medical-cost timing test builds ages 51-53,
the NB-EGM wiring tests are long-running, and CI runs pytest on four
workers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
A horizon that ends before every regime is reached prunes those regimes
from the params template, so their fixed params and the model-level
params only they read are dropped before the model is built.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
The benchmark model, the baseline model on unfolded and folded grids,
and the ACA model per policy are built once per pytest worker and
shared by every test that builds them with the same arguments.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
The AIME points per PIA segment become a GridConfig field with the
current counts as default. The timing test keeps the two health-cost
shock grids and shrinks AIME, wage residual and consumption.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
The model takes fixed params as given. `select_horizon_params` keeps the
regime-level entries of the regimes the age stages reach, and the
claiming-only params when a claiming regime is reachable. The benchmark
params follow it, so a short horizon builds once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
`--dist loadscope` sends a module's tests to one worker, so a
module-scoped fixture is built once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant