Move the engine's random draws into the data build

Abierto
#2,874 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@MaxGhenis ya está trabajando en esto.

Desde el 5/11/2026.

  • #2877 de @MaxGhenis — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
numpy, python
Área
backend, data

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
53
Forks
34
Merge medio
3 d 10 h
PR fusionados (30 d)
321

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de PolicyEngine/policyengine-uk

Todos los issues de PolicyEngine/policyengine-uk

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.