Move the engine's random draws into the data build

オープン
#2,874 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@MaxGhenis がすでに取り組んでいます。

2026年11月5日 から。

  • #2877 @MaxGhenis による — オープン

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
numpy, python
領域
backend, data

調査の方向性

Start with the eight runtime draw sites named in the issue, including scenarios/uc_reform.py, data/economic_assumptions.py, dynamics/participation.py and scenarios/pip_reform.py; read the linked policyengine-core constraint and ratchet issue #2873. The issue lays out four migration steps across policyengine-uk, Microcosm UK and policyengine-uk-data. Done means simulations read stored draws from datasets while preserving outputs at each step, with any measured changes stated in the relevant PR.

索引モデルが issue の本文から書いたものです。

説明

policyengine-core bans randomness in variable formulas, so the data build has to draw each stochastic input and store it (PolicyEngine/policyengine-core#500). policyengine-uk still draws at run time in eight places:

  • uc_deduction_random_draw and uc_deduction_type_random_draw hash the benefit unit id.
  • months_since_last_birthday hashes the person id, then spreads people over the year within each age and sex.
  • warm_home_discount_random_draw hashes the household id.
  • add_universal_credit_reform in scenarios/uc_reform.py draws one value per benefit unit from a seeded generator.
  • uprate_student_loan_plans in data/economic_assumptions.py hashes the person id.
  • apply_participation_responses in dynamics/participation.py draws from a seeded RandomState.
  • scenarios/pip_reform.py seeds numpy's global stream and draws one value per person.

We'll move them in four steps:

  1. A code-health test stops new draws appearing and lists today's as a ratchet (#2873).
  2. policyengine-uk defines stored inputs for the Universal Credit, student loan and PIP draws, and reads them when a dataset supplies them. It runs today's code on a dataset without them.
  3. Microcosm UK and policyengine-uk-data write each missing column, with the value today's code computes for that file.
  4. policyengine-uk stops drawing in simulations built from data and reads only the stored columns.

We keep outputs unchanged at each step, except where that step's PR states and measures a change.

主要言語
Python
スター
53
フォーク
34
平均マージ
3日 10時間
マージ済み PR(30日)
321

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PolicyEngine/policyengine-uk のほかの issue

PolicyEngine/policyengine-uk の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。