Skip to main content

Physics-informed graph embedding (SGCN) and multi-objective MST zoning (PGNN + MST).

Project description

PGMST

Physics-informed Graph embedding + Multi-objective ST (MST-based) regionalization.

Two-stage API:

  1. pgmst.pgnn.PGNN — packaged SGCN pipeline (half-life OD weights + spatial glue on contiguity edges). embed() appends Emb_X / Emb_Y to your zone table.
  2. pgmst.mst.MST — build an MST on the spatial adjacency graph with edge costs from embedding distance, then modularity- and constraint-driven partitioning (population / hospital / custom caps, minimum localization index).

Optional: GCN-style embedding via pgmst.physics_graph + PyTorch Geometric (see example notebook).

Install

pip install pgmst

For a development editable install from a clone:

pip install -e ".[dev]"

Quick start

from pgmst import PGNN, MST

coords_emb = PGNN(
    coords_df,
    df_flow,
    id_column="ZoneID",
    w=df_adj,
    k_hops=5,
    w_adj_percentile=75.0,
    coordxy="XCoord,YCoord",
).embed()

pr = MST(
    coords_emb,
    df_flow,
    id_column="ZoneID",
    emb=("Emb_X", "Emb_Y"),
    w=df_adj,
    constraints=[("POPU", "min", 10_000), ("POPU", "max", 500_000), ("hosp", "min", 1)],
    min_local_index=0.3,
).partition()

print(pr.modularity)
print(pr.cluster.head())

Example notebook

After installation, the Florida demo notebook is shipped inside the package:

  • pgmst/examples/PGMST_Florida_demo.ipynb

You can copy it to your working directory or open it from site-packages/pgmst/examples/.
The notebook expects OD/adjacency/shapefile paths: point REPO at a checkout of GNNGeoCommunity (or your own data) where data/OD_All_Flows30K.csv, data/FLAdjUpdate.csv, and data/Florida_2011.zip live.

PyPI release

See docs/PYPI.md for local builds (python -m build / twine) and GitHub Actions publishing (Trusted Publisher on PyPI).

Requirements

Python 3.10+, PyTorch, PyTorch Geometric, GeoPandas, NetworkX, SciPy, pandas, NumPy. Queen/Rook contiguity needs libpysal.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgmst-0.2.0.tar.gz (10.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgmst-0.2.0-py3-none-any.whl (144.2 kB view details)

Uploaded Python 3

File details

Details for the file pgmst-0.2.0.tar.gz.

File metadata

  • Download URL: pgmst-0.2.0.tar.gz
  • Upload date:
  • Size: 10.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pgmst-0.2.0.tar.gz
Algorithm Hash digest
SHA256 87776fe5799c6ae2d528adcb0797d743c86cdd95757c6be9bec12fd704e337b0
MD5 98753bf9d6141d8cc4d2851dfc557c9f
BLAKE2b-256 b9dae14d4c6a6aa098134e3ff0fef11f3ae8063d0a1d7455f069b8b7ea29eded

See more details on using hashes here.

File details

Details for the file pgmst-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pgmst-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 144.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pgmst-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e69ac664728e224a2961ab33e133254c2fde33622d753703296eab955f8ece9b
MD5 3b214f434c37e57b00fc9d0fbba449e2
BLAKE2b-256 13f7d1c3659d812685a739d896aaf976d00aec197abdd0e8dddc9fc0015d26f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page