You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimise Simulation() init: ~10x speedup on warm loads (#1497)
* Add changelog entry
* Update test expected values
* Optimise Simulation() init: parameter cache, URL dataset cache, vectorised interpolation
Three performance changes that give ~10x speedup on warm Simulation() calls:
1. Cache the fully-processed parameter tree in CountryTaxBenefitSystem.__init__().
convert_to_fiscal_year_parameters() (22,538 param.update() calls, ~0.5s) now only
runs once per process. Subsequent inits clone the cached tree. Reforms still go
through the full pipeline via apply_parameter_changes() -> reset_parameters() ->
process_parameters(), so correctness is preserved.
2. Cache the loaded, uprated and enum-pre-encoded UKMultiYearDataset per URL.
_pre_encode_enum_columns() converts string enum columns to int16 before caching
so subsequent build_from_multi_year_dataset calls use encode()'s fast integer
path. Saves ~2.2s (HDF5 read + uprating + string encoding) on every warm load.
3. Vectorise attends_private_school.interpolate_percentile. Replace the Python list
comprehension over ~115k households with a 21-point parameter lookup, np.interp
and numpy array indexing.
Benchmark: 2nd+ Simulation() drops from ~3.7s to ~0.38s.
Co-Authored-By: Claude <noreply@anthropic.com>
* Add microsimulation tests to CI
Removes the -m "not microsimulation" exclusion from make test, so reform
impact and salary sacrifice cap tests run in CI. Updates stale expected
values in reforms_config.yaml and test_salary_sacrifice_cap_reform.py to
match current model output.
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments