-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Problem
The matrix builder precomputes entity values with all takeup variables set to True (including would_file_taxes_voluntarily). For target variables affected by non-target "state" variables like would_file, the precomputed values don't account for the simulation state change when would_file=False.
In the H5, would_file draws are applied as inputs, changing is_filer and any downstream variables. This created a mismatch between X@w (matrix path) and sim.calculate (H5 path).
Fix
Precompute a second set of entity values (entity_wf_false) with would_file_taxes_voluntarily=False for tax_unit-level targets. In the clone worker, compute would_file draws first, then blend between the two precomputed branches per tax unit before applying the target's own takeup draw.
This handles the general pattern of "state variables" — non-target takeup variables that change the simulation environment rather than linearly gating a benefit.
Key insight
8 of 9 takeup variables are "gate" variables (eligible_amount × draw). The 9th (would_file) is a "state" variable that changes upstream simulation state. You can't post-multiply a state change; you have to pre-branch it.