Skip to content

Resource-constraint check cannot exempt the terminal period without waiving the whole path #1210

Description

@vahid-ahmadi

Summary

RC_TPI is a single scalar compared against the resource-constraint error at every period with np.any, so there is no way to exempt the terminal period without simultaneously waiving the check across the whole path.

https://github.com/PSLmodels/OG-Core/blob/master/ogcore/TPI.py#L1839

if (np.any(np.absolute(RC_error) >= p.RC_TPI)) and ENFORCE_SOLUTION_CHECKS:
    raise RuntimeError("Transition path equlibrium not found " + "(RC_error)")

Why this matters

The last period of a truncated transition path is not a true steady state, so RC_error[T-1] is routinely larger than the interior periods by orders of magnitude. Country packages that hit this have no expressive option other than raising the global tolerance.

A concrete example downstream: OG-UK sets p.RC_TPI = 0.2 with an in-code comment stating that only t = T-1 fails and "all other periods are well within 1e-4" (oguk/api.py:979-983). The effect is that a mid-path violation of up to 0.2 — the same order as the terminal error the setting was written to route around — now passes silently on every transition run.

Suggested change

Check the interior and terminal periods separately, e.g.

  • compare RC_error[:-1] against a tight tolerance (RC_TPI, default unchanged), and
  • handle RC_error[-1] under a separate, looser RC_TPI_terminal parameter (or exclude it and note the truncation in the docs).

This is backwards compatible for anyone currently passing the check, and it restores the diagnostic for the interior path.

Happy to open a PR if the approach looks right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions