spopt

spopt: a python package for solving spatial optimization problems in PySAL - Published in JOSS (2022)

https://github.com/pysal/spopt

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    2 of 21 committers (9.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

facility-location location-allocation location-modeling python regionalization resource-planning routing spatial-analysis spatial-optimization transportation

Keywords from Contributors

graph-theory network-analysis pysal spatial-network topology meshing hydrology standardization wavelets networks

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 83% confidence
Political Science Social Sciences - 43% confidence
Last synced: 4 months ago · JSON representation

Repository

Spatial Optimization

Basic Info
  • Host: GitHub
  • Owner: pysal
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Homepage: https://pysal.org/spopt/
  • Size: 160 MB
Statistics
  • Stars: 339
  • Watchers: 12
  • Forks: 55
  • Open Issues: 30
  • Releases: 19
Topics
facility-location location-allocation location-modeling python regionalization resource-planning routing spatial-analysis spatial-optimization transportation
Created almost 7 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing License

README.md

spopt: Spatial Optimization

Regionalization, facility location, and transportation-oriented modeling

tag Continuous Integration codecov Documentation License Ruff status DOI Discord

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

python 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.region.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

```python from spopt.locate import MCLP from spopt.locate.util import simulatedgeopoints import numpy, geopandas, pulp, spaghetti

solver = pulp.PULPCBCCMD(msg=False, warmStart=True) lattice = spaghetti.regularlattice((0, 0, 10, 10), 9, exterior=True) ntw = spaghetti.Network(indata=lattice) street = spaghetti.elementasgdf(ntw, arcs=True) streetbuffered = geopandas.GeoDataFrame( geopandas.GeoSeries(street["geometry"].buffer(0.5).unaryunion), crs=street.crs, columns=["geometry"], ) clientpoints = simulatedgeopoints(streetbuffered, needed=100, seed=5) ntw.snapobservations(clientpoints, "clients", attribute=True) clientssnapped = spaghetti.elementasgdf( ntw, ppname="clients", snapped=True ) facilitypoints = simulatedgeopoints(streetbuffered, needed=10, seed=6) ntw.snapobservations(facilitypoints, "facilities", attribute=True) facilitiessnapped = spaghetti.elementasgdf( ntw, ppname="facilities", snapped=True ) costmatrix = ntw.allneighbordistances( sourcepattern=ntw.pointpatterns["clients"], destpattern=ntw.pointpatterns["facilities"], ) numpy.random.seed(0) ai = numpy.random.randint(1, 12, 100) mclpfromcostmatrix = MCLP.fromcostmatrix(costmatrix, ai, 4, pfacilities=4) mclpfromcostmatrix = mclpfromcostmatrix.solve(solver) ``` see notebook for plotting code

Examples

More examples can be found in the Tutorials section of the documentation. - Max-p-regions problem - Skater - Region K means - Facility Location Real World Problem

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 PySAL's Discord channel.

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

Owner

  • Name: Python Spatial Analysis Library
  • Login: pysal
  • Kind: organization

JOSS Publication

spopt: a python package for solving spatial optimization problems in PySAL
Published
June 14, 2022
Volume 7, Issue 74, Page 3330
Authors
Xin Feng ORCID
Center for Geospatial Sciences, University of California Riverside, Department of Geography and Environmental Sustainability, University of Oklahoma
Germano Barcelos ORCID
Federal University of Vi\c{c}osa
James D. Gaboardi ORCID
Oak Ridge National Laboratory, The Peter R. Gould Center for Geography Education and Outreach, Penn State
Elijah Knaap ORCID
Center for Geospatial Sciences, University of California Riverside
Ran Wei
Center for Geospatial Sciences, University of California Riverside
Levi J. Wolf ORCID
University of Bristol
Qunshan Zhao ORCID
Urban Big Data Centre, School of Social & Political Sciences, University of Glasgow
Sergio J. Rey ORCID
Center for Geospatial Sciences, University of California Riverside
Editor
Vissarion Fisikopoulos ORCID
Tags
spatial optimization PySAL

Papers & Mentions

Total mentions: 1

Using the max-p regions problem algorithm to define regions for energy system modelling
Last synced: 2 months ago

GitHub Events

Total
  • Create event: 3
  • Release event: 1
  • Issues event: 23
  • Watch event: 39
  • Delete event: 2
  • Issue comment event: 52
  • Push event: 14
  • Pull request review comment event: 27
  • Pull request review event: 22
  • Pull request event: 28
  • Fork event: 6
Last Year
  • Create event: 3
  • Release event: 1
  • Issues event: 23
  • Watch event: 39
  • Delete event: 2
  • Issue comment event: 52
  • Push event: 14
  • Pull request review comment event: 27
  • Pull request review event: 22
  • Pull request event: 28
  • Fork event: 6

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 856
  • Total Committers: 21
  • Avg Commits per committer: 40.762
  • Development Distribution Score (DDS): 0.583
Past Year
  • Commits: 13
  • Committers: 6
  • Avg Commits per committer: 2.167
  • Development Distribution Score (DDS): 0.462
Top Committers
Name Email Commits
James Gaboardi j****i@g****m 357
Erin Olson r****o@g****m 206
Germano Barcelos g****s@g****m 70
Serge Rey s****y@g****m 65
Xin Feng x****g@X****l 43
pre-commit-ci[bot] 6****] 24
eli knaap ek@k****m 23
Xin (Selena) Feng a****g@g****m 15
rongboxu r****1@u****k 14
ljwolf l****f@g****m 10
dependabot[bot] 4****] 7
rwei5 r****i@a****u 6
Timothy Ellersiek t****m@g****m 6
Martin Fleischmann m****n@m****t 2
github-actions[bot] 4****] 2
Abhishek Dimri 1****i 1
Emmanuel Ferdman e****n@g****m 1
Krasen Samardzhiev k****m@g****m 1
Nick Bearman n****k@g****k 1
Patrick Roddy p****y@g****m 1
Pedro Camargo c@m****o 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 117
  • Total pull requests: 128
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 10 days
  • Total issue authors: 23
  • Total pull request authors: 17
  • Average comments per issue: 1.88
  • Average comments per pull request: 1.71
  • Merged pull requests: 110
  • Bot issues: 0
  • Bot pull requests: 28
Past Year
  • Issues: 19
  • Pull requests: 33
  • Average time to close issues: 15 days
  • Average time to close pull requests: 9 days
  • Issue authors: 7
  • Pull request authors: 10
  • Average comments per issue: 1.47
  • Average comments per pull request: 1.76
  • Merged pull requests: 22
  • Bot issues: 0
  • Bot pull requests: 4
Top Authors
Issue Authors
  • jGaboardi (87)
  • ljwolf (5)
  • iboates (2)
  • orlandombaa (1)
  • xf37 (1)
  • sjsrey (1)
  • mbforr (1)
  • nilason (1)
  • swongraphy (1)
  • samueltoro7 (1)
  • Abhishek-Dimri (1)
  • benjaminrhoyle (1)
  • martinfleis (1)
  • Anran0716 (1)
  • Dekermanjian (1)
Pull Request Authors
  • jGaboardi (66)
  • pre-commit-ci[bot] (23)
  • ljwolf (4)
  • rongboxu (4)
  • nightcoder26 (4)
  • gegen07 (3)
  • speco29 (3)
  • xf37 (3)
  • dependabot[bot] (3)
  • emmanuel-ferdman (2)
  • fengzixin0617 (2)
  • Abhishek-Dimri (2)
  • martinfleis (2)
  • github-actions[bot] (2)
  • u3ks (2)
Top Labels
Issue Labels
locate (33) maintenance (16) rough edge (15) CI (13) docs (12) region (11) bug (9) notebooks/binders (9) enhancement (9) testing (8) dependencies (7) GSOC2023 (3) solvers & solver apis (3) needs attention (3) release (3) github_actions (3) discussion (3) installation (2) codecov (2) conda-forge (1) requirements (1) WIP (1) priority: high (1) tutorials (1) transport/route (1) good first issue (1)
Pull Request Labels
maintenance (27) locate (24) docs (21) CI (15) notebooks/binders (9) bug (8) rough edge (8) dependencies (7) testing (7) region (6) GSOC2023 (4) enhancement (3) python (3) github_actions (3) good first issue (2) solvers & solver apis (1) GSoC2022 (1) conda-forge (1) needs attention (1) priority: high (1) release (1) GSoC2025 (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 27,990 last-month
  • Total docker downloads: 189
  • Total dependent packages: 5
    (may contain duplicates)
  • Total dependent repositories: 43
    (may contain duplicates)
  • Total versions: 30
  • Total maintainers: 3
pypi.org: spopt

Spatial Optimization in PySAL

  • Versions: 21
  • Dependent Packages: 3
  • Dependent Repositories: 35
  • Downloads: 27,990 Last month
  • Docker Downloads: 189
Rankings
Docker downloads count: 2.0%
Downloads: 2.3%
Dependent packages count: 2.4%
Dependent repos count: 2.5%
Average: 3.3%
Stargazers count: 4.5%
Forks count: 6.3%
Maintainers (3)
Last synced: 4 months ago
conda-forge.org: spopt

Spopt is an open-source Python library for solving optimization problems with spatial data. Originating from the `region` module in [PySAL](http://pysal.org) (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.

  • Homepage: http://pysal.org/
  • License: BSD-3-Clause
  • Latest release: 0.4.1
    published over 3 years ago
  • Versions: 8
  • Dependent Packages: 2
  • Dependent Repositories: 8
Rankings
Dependent repos count: 12.1%
Dependent packages count: 19.6%
Average: 21.9%
Stargazers count: 26.4%
Forks count: 29.8%
Last synced: 4 months ago
anaconda.org: spopt

Spopt is an open-source Python library for solving optimization problems with spatial data. Originating from the `region` module in [PySAL](http://pysal.org) (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.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 42.3%
Average: 44.4%
Dependent repos count: 46.5%
Last synced: 4 months ago

Dependencies

.github/workflows/build_docs.yml actions
  • actions/checkout v3 composite
  • ad-m/github-push-action master composite
  • mamba-org/provision-with-micromamba main composite
.github/workflows/release_and_publish.yml actions
  • actions/checkout v3 composite
  • actions/github-script v6 composite
  • actions/setup-python v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/testing.yml actions
  • actions/checkout v3 composite
  • codecov/codecov-action v3 composite
  • mamba-org/provision-with-micromamba main composite
pyproject.toml pypi
  • geopandas >=0.10
  • libpysal *
  • mapclassify *
  • networkx >=2.6
  • numpy >=1.21
  • pandas >=1.3,!=1.5.0
  • pointpats >=2.3.0
  • pulp *
  • scikit-learn >=1.0
  • scipy >=1.7
  • shapely >=2
  • spaghetti *
  • tqdm >=4.27.0
environment.yml conda
  • folium
  • geopandas
  • glpk
  • inequality
  • jupyterlab
  • libpysal
  • mapclassify
  • matplotlib
  • matplotlib-scalebar
  • networkx
  • numpy
  • overpy
  • pandas
  • pip
  • pointpats
  • pulp
  • python 3.12.*
  • scikit-learn
  • scipy
  • seaborn
  • shapely
  • spaghetti
  • tqdm
  • watermark