Move the engine's random draws into the data build

Aperta
#2,874 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@MaxGhenis ci sta già lavorando.

Dal 5/11/2026.

  • #2877 di @MaxGhenis — aperta

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
numpy, python
Ambito
backend, data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
53
Fork
34
Merge medio
3g 8h
PR unite (30g)
322

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PolicyEngine/policyengine-uk

Tutte le issue di PolicyEngine/policyengine-uk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.