All Projects → pysal → spopt

pysal / spopt

Licence: BSD-3-Clause license
Spatial Optimization

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to spopt

Osmnx
OSMnx: Python for street networks. Retrieve, model, analyze, and visualize street networks and other spatial data from OpenStreetMap.
Stars: ✭ 3,357 (+1704.84%)
Mutual labels:  transportation, spatial-analysis
routing-py
🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.
Stars: ✭ 106 (-43.01%)
Mutual labels:  routing, spatial-analysis
Urbansprawl
Open framework for calculating spatial urban sprawl indices and performing disaggregated population estimates using open data
Stars: ✭ 48 (-74.19%)
Mutual labels:  transportation, spatial-analysis
Pgrouting
Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
Stars: ✭ 804 (+332.26%)
Mutual labels:  routing, spatial-analysis
Stplanr
Sustainable transport planning with R
Stars: ✭ 352 (+89.25%)
Mutual labels:  transportation, routing
Sota Py
A discrete-time Python-based solver for the Stochastic On-Time Arrival routing problem
Stars: ✭ 381 (+104.84%)
Mutual labels:  transportation, routing
Ppd599
USC urban data science course series with Python and Jupyter
Stars: ✭ 1,062 (+470.97%)
Mutual labels:  transportation, spatial-analysis
react-layer-stack
Layering system for React. Useful for popover/modals/tooltip/dnd application
Stars: ✭ 158 (-15.05%)
Mutual labels:  transportation
router-example
Use React Router DOM to create a Single Page Application (SPA).
Stars: ✭ 50 (-73.12%)
Mutual labels:  routing
maas-schemas
Mobility as a Service API - data model, tests, and validation
Stars: ✭ 17 (-90.86%)
Mutual labels:  transportation
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (-22.58%)
Mutual labels:  routing
rrx
⚛️ Minimal React router using higher order components
Stars: ✭ 69 (-62.9%)
Mutual labels:  routing
angular-httpclient
Angular 15 Example HttpClient
Stars: ✭ 21 (-88.71%)
Mutual labels:  routing
torchtrajectory
The World's First Search Engine for Trajectory Data
Stars: ✭ 28 (-84.95%)
Mutual labels:  transportation
pocketinternet
A Pocket Internet for teaching how the Internet really works.
Stars: ✭ 28 (-84.95%)
Mutual labels:  routing
klrfome
Kernel Logistic Regression on Focal Mean Embeddings
Stars: ✭ 16 (-91.4%)
Mutual labels:  spatial-analysis
transam core
Core Rails engine for the TransAM open source software platform for managing transportation assets.
Stars: ✭ 13 (-93.01%)
Mutual labels:  transportation
router
An Fully Automatic RESTful PHP Router
Stars: ✭ 51 (-72.58%)
Mutual labels:  routing
realtime-bus-sms
Text back current arrival time for buses given a texted in bus stop number for People Mover. AddressLookup branch would allow texting "Arctic and Fireweed"
Stars: ✭ 15 (-91.94%)
Mutual labels:  transportation
Mignis
Mignis is a semantic based tool for firewall configuration.
Stars: ✭ 43 (-76.88%)
Mutual labels:  routing

spopt: Spatial Optimization

Regionalization, facility location, and transportation-oriented modeling

tag Continuous Integration codecov Documentation License Code style: black status DOI

Spopt is an open-source Python library for solving optimization problems with spatial data. Originating from the region module in PySAL (Python Spatial Analysis Library), it is under active development for the inclusion of newly proposed models and methods for regionalization, facility location, and transportation-oriented solutions.

Regionalization

import spopt, libpysal, geopandas, numpy
mexico = geopandas.read_file(libpysal.examples.get_path("mexicojoin.shp"))
mexico["count"] = 1
attrs = [f"PCGDP{year}" for year in range(1950, 2010, 10)]
w = libpysal.weights.Queen.from_dataframe(mexico)
mexico["count"], threshold_name, threshold, top_n = 1, "count", 4, 2
numpy.random.seed(123456)
model = spopt.MaxPHeuristic(mexico, w, attrs, threshold_name, threshold, top_n)
model.solve()
mexico["maxp_new"] = model.labels_
mexico.plot(column="maxp_new", categorical=True, figsize=(12,8), ec="w");

Locate

from spopt.locate import MCLP
from spopt.locate.util import simulated_geo_points
import numpy, geopandas, pulp, spaghetti

solver = pulp.PULP_CBC_CMD(msg=False, warmStart=True)
lattice = spaghetti.regular_lattice((0, 0, 10, 10), 9, exterior=True)
ntw = spaghetti.Network(in_data=lattice)
street = spaghetti.element_as_gdf(ntw, arcs=True)
street_buffered = geopandas.GeoDataFrame(
    geopandas.GeoSeries(street["geometry"].buffer(0.5).unary_union),
    crs=street.crs,
    columns=["geometry"],
)
client_points = simulated_geo_points(street_buffered, needed=100, seed=5)
ntw.snapobservations(client_points, "clients", attribute=True)
clients_snapped = spaghetti.element_as_gdf(
    ntw, pp_name="clients", snapped=True
)
facility_points = simulated_geo_points(street_buffered, needed=10, seed=6)
ntw.snapobservations(facility_points, "facilities", attribute=True)
facilities_snapped = spaghetti.element_as_gdf(
    ntw, pp_name="facilities", snapped=True
)
cost_matrix = ntw.allneighbordistances(
    sourcepattern=ntw.pointpatterns["clients"],
    destpattern=ntw.pointpatterns["facilities"],
)
numpy.random.seed(0)
ai = numpy.random.randint(1, 12, 100)
mclp_from_cost_matrix = MCLP.from_cost_matrix(cost_matrix, ai, 4, p_facilities=4)
mclp_from_cost_matrix = mclp_from_cost_matrix.solve(solver)

see notebook for plotting code

Examples

More examples can be found in the Tutorials section of the documentation.

All examples can be run interactively by launching this repository as a Binder.

Requirements

Installation

spopt is available on the Python Package Index. Therefore, you can either install directly with pip from the command line:

$ pip install -U spopt

or download the source distribution (.tar.gz) and decompress it to your selected destination. Open a command shell and navigate to the decompressed folder. Type:

$ pip install .

You may also install the latest stable spopt via conda-forge channel by running:

$ conda install --channel conda-forge spopt

Related packages

Contribute

PySAL-spopt is under active development and contributors are welcome.

If you have any suggestions, feature requests, or bug reports, please open new issues on GitHub. To submit patches, please review PySAL's documentation for developers, the PySAL development guidelines, the spopt contributing guidelines before opening a pull request. Once your changes get merged, you’ll automatically be added to the Contributors List.

Support

If you are having trouble, please create an issue, start a discussion, or talk to us in the gitter room.

Code of Conduct

As a PySAL-federated project, spopt follows the Code of Conduct under the PySAL governance model.

License

The project is licensed under the BSD 3-Clause license.

Citation

If you use PySAL-spopt in a scientific publication, we would appreciate using the following citations:

@misc{spopt2021,
    author    = {Feng, Xin, and Gaboardi, James D. and Knaap, Elijah and
                Rey, Sergio J. and Wei, Ran},
    month     = {jan},
    year      = {2021},
    title     = {pysal/spopt},
    url       = {https://github.com/pysal/spopt},
    doi       = {10.5281/zenodo.4444156},
    keywords  = {python,regionalization,spatial-optimization,location-modeling}
}

@article{spopt2022,
    author    = {Feng, Xin and Barcelos, Germano and Gaboardi, James D. and
                Knaap, Elijah and Wei, Ran and Wolf, Levi J. and
                Zhao, Qunshan and Rey, Sergio J.},
    year      = {2022},
    title     = {spopt: a python package for solving spatial optimization problems in PySAL},
    journal   = {Journal of Open Source Software},
    publisher = {The Open Journal},
    volume    = {7},
    number    = {74},
    pages     = {3330},
    url       = {https://doi.org/10.21105/joss.03330},
    doi       = {10.21105/joss.03330},
}

Funding

This project is/was partially funded through:

National Science Foundation Award #1831615: RIDIR: Scalable Geospatial Analytics for Social Science Research

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].