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:
pgmst.pgnn.PGNN— packaged SGCN pipeline (half-life OD weights + spatial glue on contiguity edges).embed()appendsEmb_X/Emb_Yto your zone table.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87776fe5799c6ae2d528adcb0797d743c86cdd95757c6be9bec12fd704e337b0
|
|
| MD5 |
98753bf9d6141d8cc4d2851dfc557c9f
|
|
| BLAKE2b-256 |
b9dae14d4c6a6aa098134e3ff0fef11f3ae8063d0a1d7455f069b8b7ea29eded
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e69ac664728e224a2961ab33e133254c2fde33622d753703296eab955f8ece9b
|
|
| MD5 |
3b214f434c37e57b00fc9d0fbba449e2
|
|
| BLAKE2b-256 |
13f7d1c3659d812685a739d896aaf976d00aec197abdd0e8dddc9fc0015d26f2
|