Impact of Improved Consumable Availability - #1702
Draft
sakshimohan wants to merge 84 commits into
Draft
Conversation
…cript - add heatmaps - add detailed table of average availability by consumable across scenarios
sakshimohan
marked this pull request as draft
September 26, 2025 11:22
…AMC) + Add average row and column
1. only levels 1a and 1b can receive 2. facilities only transfer stock that they have beyond 3 X AMC
- differentiate between tau_donor_keep and tau_max
… included in the optimisation)
and revert to the previous opening balance calculation method based on data for the current month.
- increase opening balance where p based on OB/AMC is lower than observed p - fix errors in pooling which led to LB sometimes being higher than UB, specifically when tau_min X amc > OB for levels 2-4
…t when OB_prime is different from OB.
- to extract scaling_factor from tlo.methods.demography
…unds Split create_consumable_redistribution_scenarios.py into a shorter script and a new redistribution_utils.py holding the travel-time matrix builders, clustering heuristic, the two optimisation models, validation checks, smoke tests, and plotting functions. Model changes: - Pooling LP: drop the tau_min equity floor. LB is now pure donor protection, LB = min(OB, tau_keep*AMC), which makes LB <= UB and sum(LB) <= TotalStock hold by construction instead of needing post-hoc clamping. - Pooling LP: replace the manual "reset p to baseline for ineligible facility levels" patch with an assertion, since the corrected UB already makes that reset unreachable. - Pairwise MILP: restore the t <= M*y edge-activation constraint (previously commented out), without which the minimum-lot-size constraint didn't bind. - Pairwise MILP: make the K_in/K_out exchange-count caps optional (default None = uncapped). The travel-time radius and the minimum-lot size already bound how many counterparties a facility can plausibly trade with in a month, so no separate degree cap is imposed by default; the parameters remain available for a stricter delivery-capacity sensitivity run. - Fix CBC solver numerical wobble (~1e-6) being misread as a real stock movement, which could trip the non-eligible-unchanged check. Add validate_redistribution_output() enforcing five invariants (non-eligible availability unchanged, no-harm, stock conservation, donor protection, ceiling respected), plus run_smoke_tests() against synthetic data covering both models. Add plot_stockout_prevention()/plot_stockout_prevention_by_month() to summarise how much anticipated stock-out risk each scenario averts.
…ing_lp - Add pooling_level="national" (pools across the whole country per item/month). - Fix cluster pooling: build_capacity_clusters_all now keys its cluster map on (district, fac_name) instead of fac_name alone, avoiding a many-to-many merge when a facility name recurs across districts (caused row duplication and conservation/ceiling violations). - Fix write-back: a facility's solved allocation is now split proportionally across any duplicate raw rows for that facility/pool, instead of writing the full amount to each row. - National pooling disambiguates facilities via an internal (district, fac_name) node key, so two differently-located facilities that share a name are never silently merged into one LP node. - Add regression smoke tests for all of the above (cross-district name collisions in both cluster and national pooling, duplicate raw rows).
…y across scenarios - shows mean, median, and IQR
Without the cleaned district names in T_car, districts with spaces in their names are ignored in the pairwise LP
…istribution scenarios
- the RFs were overwritten by master to deal with the conflict resulting from PR #1819.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.