Restore the resource-constraint check on interior periods - #75
Open
vahid-ahmadi wants to merge 1 commit into
Open
Restore the resource-constraint check on interior periods#75vahid-ahmadi wants to merge 1 commit into
vahid-ahmadi wants to merge 1 commit into
Conversation
_build_specs sets RC_TPI = 0.2 so TPI can complete despite a known boundary discontinuity at t = T-1. OG-Core compares RC_TPI against every period at once (np.any, TPI.py:1839), so that also waives interior violations up to 0.2 -- the same order as the terminal error the setting was written to accommodate. A transition path that goes wrong mid-path returns numbers instead of raising. RC_TPI also carries a paramtools validator of range [1e-13, 0.01], so 0.2 is 20x the schema maximum and only takes effect because it is set by attribute assignment after update_specifications. There is no in-contract value that accommodates the terminal artifact. Adds _check_interior_resource_constraint, run after both the baseline and reform TPI solves, which checks RC_error[:-1] against 1e-4 and leaves the terminal period exempt. Trailing axes are collapsed so the reported index is a period. Refs PSLmodels#72, PSLmodels/OG-Core#1210 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XCKMb1aicxYaeUC1us2nvF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
_build_specssetsRC_TPI = 0.2so TPI can finish despite a known boundary discontinuity at the final period. But OG-Core comparesRC_TPIagainst every period at once (np.any,TPI.py:1839), so that also waives interior violations up to 0.2 — the same order as the ~0.109 terminal error it was written for. A transition path that goes wrong mid-path returns numbers instead of raising.RC_TPIalso has a paramtools validator ofrange: [1e-13, 0.01].0.2is 20x the schema maximum and only takes effect because it's assigned directly afterupdate_specifications. There is no in-contract value that accommodates the terminal artifact, which is why this is handled after the solve rather than by tuning the parameter.What changes after merging
A resource-constraint violation anywhere except the final period raises instead of passing silently, naming the magnitude and the period. Runs that are actually fine are unaffected — the terminal period stays exempt and
RC_TPI = 0.2is unchanged. In practice: bad transition paths stop reaching your results.Change
_check_interior_resource_constraint, called after both the baseline and reform TPI solves. ChecksRC_error[:-1]against 1e-4.resource_constraint_erroris(T, M), so trailing axes are collapsed and the reported index is a period. Missing key,None, and single-period inputs are no-ops.Evidence
9 tests, 7s: terminal-only violation passes; an interior violation of the same magnitude raises and names the right period; sign ignored; interior within tolerance passes; trailing axes collapse correctly; label appears; no-op cases.
Full suite 18 passed, 3 skipped.
ruffclean. CI green.Fixes #72. This is the interim option — if PSLmodels/OG-Core#1210 adds a separate terminal tolerance upstream, this can be replaced by setting it and restoring a tight
RC_TPI.