Skip to content

Declare regime transitions by age - #19

Draft
hmgaudecker wants to merge 18 commits into
mainfrom
feat/dated-regime-declarations
Draft

hmgaudecker wants to merge 18 commits into
mainfrom
feat/dated-regime-declarations

Conversation

@hmgaudecker

Copy link
Copy Markdown
Member

Stage transitions are declared with pylcm's ByAge schedules over AgeRange constants taken from the config, and the Regime field is regime_transitions. The dead regime is terminal (regime_transitions=None). A new coverage test checks the exact set of (age, regime) nodes. CI installs the matching pylcm (OpenSourceEconomics/pylcm#475).

On CPU in fp64, all 182 value arrays are bit-identical to the model before the change, and the 230 parameter paths are unchanged.

The branch starts from 3bc89f7, which is behind main.

https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW

hmgaudecker and others added 18 commits August 14, 2026 21:16
`build_actions` and the nongroup builder narrowed the M1 regime for NBEGM,
dropping `buy_private` and `labor_supply` as actions and fixing their former
outputs to constants. That made the solved model a different model from the one
brute force solves: the household lost its coverage and hours choices.

The regime now declares whichever choices its structure affords under every
solver. pylcm's ride-along discrete envelope is written over a single action's
grid and refuses a regime declaring several, so model build under NBEGM raises
until that arity widens. The refusal is the honest outcome — a solver that
cannot carry a choice refuses the regime rather than being handed a narrower
one.

Tests split accordingly: the regime-level and solver-config assertions stay
green, model-build assertions become strict xfails naming the arity, and one
green test pins the refusal itself so the xfails flip when the arity widens.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yHhuFzqsDw1MhdB1i2Ljm
The M1 regime declares both buy_private and labor_supply, and pylcm's envelope
now branches over the Cartesian product of a regime's discrete action grids, so
the eight strict xfails pinned to the old single-action refusal all XPASS.
Removes them and converts the refusal test into the capability it replaced: the
model builds with both actions live.

25 passed where 15 had failed. Every one of the 15 was a stale expectation --
including the five policy-variant builds, which are reported as FAILED rather
than XPASS under strict=True and so read like real build failures until the
XPASS(strict) marker is inspected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yHhuFzqsDw1MhdB1i2Ljm
`solver="nbegm"` attached the solver to one regime and left the other 17 on
brute force, so the model's stated solver was not the one that produced most
of its result. Every living regime now gets the NBEGM config, and the retiree
and tied builders carry the savings-form budget (`resources`, `savings`) that
the solver's contract reads -- without it those regimes cannot be built at all.

The build-time affinity and interval-constancy probes cannot run on the added
regimes: they differentiate the budget on scalar inputs and
`assets_and_income.capital_income` declares `rate_of_return: ScalarFloat`,
which the probe's one-element array violates. The probes fall back to
`assume_declared` and warn, so NB-EGM's exactness precondition is asserted
rather than checked there, and the solve needs validating against an
independent reference.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yHhuFzqsDw1MhdB1i2Ljm
The probes run on the first solve against the model's complete parameter
vector, so the tax tables and threshold schedules the budget reads are
the model's own rather than synthesized stand-ins. Affinity and
constancy are checked rather than asserted.
pylcm takes the liquid roles from the regime: a `ConsumptionSavingsRegime`
names the liquid state, the action paid from resources, the resources node
and the post-decision state, and the solver carries numerical configuration
only. `ACA_LIQUID_MARGIN` states that once for the three living-regime
builders, which now route through `build_alive_regime`; a brute-force regime
has no `resources` or `savings` node to name and stays a plain `Regime`.

The role assertions move with the declaration: they read `regime.liquid`,
which is public API, rather than the bound solver's attributes.
Both callers of `build_model_constraints` still said DC-EGM gets no
broadcast constraint. It is declared under every solver: the EGM solve
enforces the limit through the savings grid's lower bound, but forward
simulation re-decides consumption by an argmax over the consumption grid
and needs the explicit feasibility mask.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yHhuFzqsDw1MhdB1i2Ljm
The xfail reason described the assets-law chain, but the build stops
earlier: pylcm's DC-EGM refuses the broadcast borrowing constraint for
reading continuous variables. Both blockers are now listed in the order
they fire.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018yHhuFzqsDw1MhdB1i2Ljm
pylcm's `Model.solve` returns a `SolutionResult` and `Model.simulate`
takes `solution=` in place of `period_to_regime_to_V_arr=`. The value
mapping these tests read is `SolutionResult.values`; passing `None` for the
old keyword meant "solve inside simulate", which is the new default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y7QCx9tkGD3TqwNw681QwD
Forward ExecutionConfig through baseline, ACA and benchmark factories. Derive omitted accelerator budgets from selected JAX allocator limits and reject retired GridConfig execution fields. Preserve economic grids and numerical solver settings.

Validation against pylcm f6d41d54: exact ASV CPU preflight, focused compatibility tests, Ruff, ty and repository hooks pass. DC-EGM construction still exposes an upstream continuation-template placement failure on three CPU devices.
…te (#18)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Stage transitions use `ByAge` schedules over `AgeRange` constants from the
config, the dead regime is terminal with `regime_transitions=None`, and a
coverage test checks every (age, regime) node. CI installs the matching pylcm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hs8mfXPYyEa24KaAp6BwCW
Co-Authored-By: Claude Opus 5.5 <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