[x] Create the examples in both access.access and access.raam
The basic idea here is to iteratively move patients from the maximum cost location to the minimum cost location.
This should be fairly straightforward in python.
Start with a df with columns for origin, destination, travel_cost (which may have undergone a transformation -- perhaps just τ, perhaps also a function), the congestion_cost, and the current (integer) assignment level
Assign all patients to the nearest location (lowest travel cost)
Index on origins and destination. For each origin, find the lowest and highest cost physician locations. Transfer some over.
Reaggregate the congestion costs and merge that back on. Repeat 2-4.
You should do all this without:
Moving more than are needed to equalize costs.
Moving more than are actually there
Moving them too fast, generally
Unit tests:
[ ] The total number of patients at an origin should not ever change.
[ ] If there is no disaffinity for travel (τ = ∞), the ultimate solution should have "quite" demand (how even?).
[ ] If you create an artificial, zero cost link between some rural spot and Chicago, that rural tract should have the same cost of care as Chicago.
[x] Do everything in numpy: find the minimum cost location etc.
[x] Use masking to turn off the columns with no available supply, or for which no travel cost is available (these would be na's in the pivot).
[x] That can be accomplished easily in pandas or numpy. Your pandas df is really just a numpy array (df.values()). But ALSO note that when you convert IT SHOULD BE SPARSE and otherwise it will be very inefficient.
[x] First test with your 3 × 4 data with two special cases.
Each origin is linked to exactly one destination, with 0 (or a fixed cost). The RAAM cost will be either just the ratio of demand and the (unique) associated supply, or that plus the fixed cost.
Each origin is linked to all other destinations, with equal or zero travel time. The costs should now be basically equally (barring integers left over in the optimization/equalization, i.e. can't divide 1000 patients among three doctors equally...).
[x] Test using the Illinois data: read in origins, destinations, costs. Costs are now of the form o, d, c; these need to be pivoted to an o × d matrix (with c's in the cells).
[x] At the end, correlate the RAAM values with those from the 2SFCA. The correlations will be (or should be!?) >ish than 0.6.
Create the "nominal" version of the RAAM optimization.
access.access
andaccess.raam
The basic idea here is to iteratively move patients from the maximum cost location to the minimum cost location.
This should be fairly straightforward in python.
origin
,destination
,travel_cost
(which may have undergone a transformation -- perhaps just τ, perhaps also a function), thecongestion_cost
, and the current (integer) assignment levelYou should do all this without:
Unit tests: