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

Đang mở
#1,210 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@arihantlodha-cmd đang làm issue này rồi.

Từ ngày 25/9/2026.

  • #1225 của @arihantlodha-cmd — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
numpy, python
Lĩnh vực
backend, testing-qa

Hướng nghiên cứu

The check is in ogcore/TPI.py around line 1839; start by reading that resource-constraint check and how RC_TPI is configured. The issue also cites oguk/api.py lines 979–983 as a downstream example. Done means terminal-period handling no longer masks interior violations, with the behavior covered by relevant tests; a pull request is already open.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
85
Fork
153
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
19

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PSLmodels/OG-Core

Tất cả issue của PSLmodels/OG-Core

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.