Skip to content

Commit a7bdc85

Browse files
authored
Merge pull request #193 from gegen07/issue-190-add-locate-docs
Update locate docs
2 parents 6100d84 + b773cd0 commit a7bdc85

15 files changed

+49869
-597
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,54 @@ mexico.plot(column="maxp_new", categorical=True, figsize=(12,8), ec="w");
3737
<img src="docs/_static/images/maxp.svg" height="350" />
3838
</p>
3939

40+
### Locate
41+
```python
42+
from spopt.locate.coverage import MCLP
43+
from spopt.locate.util import simulated_geo_points
44+
import numpy
45+
import geopandas
46+
import pulp
47+
import spaghetti
48+
49+
solver = pulp.PULP_CBC_CMD(msg=False)
50+
lattice = spaghetti.regular_lattice((0, 0, 10, 10), 9, exterior=True)
51+
ntw = spaghetti.Network(in_data=lattice)
52+
street = spaghetti.element_as_gdf(ntw, arcs=True)
53+
street_buffered = geopandas.GeoDataFrame(
54+
geopandas.GeoSeries(street["geometry"].buffer(0.2).unary_union),
55+
crs=street.crs,
56+
columns=["geometry"],
57+
)
58+
client_points = simulated_geo_points(street_buffered, needed=CLIENT_COUNT, seed=CLIENT_SEED)
59+
facility_points = simulated_geo_points(
60+
street_buffered, needed=FACILITY_COUNT, seed=FACILITY_SEED
61+
)
62+
ntw.snapobservations(client_points, "clients", attribute=True)
63+
clients_snapped = spaghetti.element_as_gdf(
64+
ntw, pp_name="clients", snapped=True
65+
)
66+
67+
ntw.snapobservations(facility_points, "facilities", attribute=True)
68+
facilities_snapped = spaghetti.element_as_gdf(
69+
ntw, pp_name="facilities", snapped=True
70+
)
71+
cost_matrix = ntw.allneighbordistances(
72+
sourcepattern=ntw.pointpatterns["clients"],
73+
destpattern=ntw.pointpatterns["facilities"],
74+
)
75+
mclp_from_cost_matrix = MCLP.from_cost_matrix(cost_matrix, ai, MAX_COVERAGE, p_facilities=P_FACILITIES)
76+
mclp_from_cost_matrix = mclp_from_cost_matrix.solve(solver)
77+
```
78+
<p align="center">
79+
<img src="docs/_static/images/mclp.svg" height="350" />
80+
</p>
4081

4182
## Examples
4283
More examples can be found in the [Tutorials](https://pysal.org/spopt/tutorials.html) section of the documentation.
4384
- [Max-p-regions problem](https://pysal.org/spopt/notebooks/maxp.html)
4485
- [Skater](https://pysal.org/spopt/notebooks/skater.html)
4586
- [Region K means](https://pysal.org/spopt/notebooks/reg-k-means.html)
87+
- [Facility Location Real World Problem](https://pysal.org/spopt/notebooks/facloc-real-world.html)
4688

4789
All examples can be run interactively by launching this repository as a [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/pysal/spopt/main).
4890

@@ -54,6 +96,7 @@ All examples can be run interactively by launching this repository as a [![Binde
5496
- [libpysal](https://pysal.org/libpysal/)
5597
- [scikit-learn](https://scikit-learn.org/stable/)
5698
- [geopandas](https://geopandas.org/)
99+
- [pulp](https://coin-or.github.io/pulp/)
57100

58101
## Installation
59102
spopt is available on the [Python Package Index](https://pypi.org/). Therefore, you can either install directly with pip from the command line:

docs/_static/images/mclp.svg

Lines changed: 2474 additions & 0 deletions
Loading
66.6 KB
Loading

docs/_static/references.bib

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,67 @@ @article{wolf2021
8787
doi={10.1080/13658816.2021.1934475},
8888
}
8989

90+
@article{hakimi_1964,
91+
author={Hakimi, S. L.},
92+
title={Optimum Locations of Switching Centers and the Absolute Centers and Medians of a Graph},
93+
journal={Operations Research},
94+
volume={12},
95+
number={3},
96+
pages={450–459},
97+
year={1964},
98+
doi={10.1287/opre.12.3.450},
99+
}
100+
101+
@article{hakimi_1965,
102+
author={Hakimi, S. L.},
103+
title={Optimum Distribution of Switching Centers in a Communication Network and Some Related Graph Theoretic Problems},
104+
journal={Operations Research},
105+
number={3},
106+
volume={13},
107+
pages={462–475},
108+
year={1965},
109+
doi={10.1287/opre.13.3.462},
110+
}
111+
112+
@article{toregas_swain_revelle_bergman_1971,
113+
author={Toregas, Constantine and Swain, Ralph and Revelle, Charles and Bergman, Lawrence},
114+
title={The Location of Emergency Service Facilities}, volume={19},
115+
journal={Operations Research},
116+
number={6},
117+
pages={1363–1373},
118+
year={1971},
119+
doi={10.1287/opre.19.6.1363},
120+
}
121+
122+
@article{calik_labbé_yaman_2015,
123+
author={Calik, Hatice and Labbé, Martine and Yaman, Hande},
124+
title={p-Center Problems},
125+
journal={Location Science},
126+
pages={79–92},
127+
year={2015},
128+
doi={10.1007/978-3-319-13111-5_4},
129+
}
130+
131+
@article{chen_murray_jiang_2021,
132+
author={Chen, Huanfa and Murray, Alan T. and Jiang, Rui},
133+
title={Open-source approaches for location cover models: capabilities and efficiency},
134+
journal={Journal of Geographical Systems},
135+
doi={10.1007/s10109-021-00350-w},
136+
year={2021}
137+
}
138+
139+
@book{daskin_2013,
140+
author={Daskin, Mark S.},
141+
title={Network and discrete location: models, algorithms, and applications},
142+
publisher={John Wiley & Sons, Inc.},
143+
year={2013},
144+
}
145+
146+
@book{church_murray_2018,
147+
author={Church, Richard L. and Murray, Alan T.},
148+
title={Location covering models: history, applications and advancements},
149+
publisher={Springer},
150+
year={2018},
151+
}
152+
90153
%======

docs/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ Regionalization, facility location, and transportation-oriented modeling
4444
</div>
4545
</a>
4646
</div>
47+
<div class="col-sm-4 col-xs-14">
48+
<a href="https://pysal.org/spopt/notebooks/facloc-real-world.html" class="thumbnail">
49+
<img src="_static/images/notebooks-facloc-mclp.png"
50+
class="img-responsive center-block">
51+
<div class="caption text-center">
52+
<h6>Locate Store Sites in San Francisco
53+
</h6>
54+
</div>
55+
</a>
56+
</div>
4757
<div class="col-sm-.5 col-xs-hidden">
4858
</div>
4959
</div>

0 commit comments

Comments
 (0)