Systematic comparison of trip distribution laws and models
Project description
PyTDLM: Systematic comparison of trip distribution laws and models
A Python port of the TDLM R package, with numpy-based implementations and parallel processing support for multiple exponent values.
Overview
PyTDLM provides implementations of several trip distribution models commonly used in transportation planning and spatial analysis:
Available Laws
- GravExp: Gravity model with exponential distance decay
- NGravExp: Normalized gravity model with exponential decay
- GravPow: Gravity model with power distance decay
- NGravPow: Normalized gravity model with power decay
- Schneider: Schneider's intervening opportunities model
- Rad: Radiation model
- RadExt: Extended radiation model
- Rand: Random model (baseline)
Available Models
- UM: Unconstrained Model
- PCM: Production Constrained Model
- ACM: Attraction Constrained Model
- DCM: Doubly Constrained Model
Installation
Using conda
conda install -c conda-forge pytdlm
Using pip
pip install PyTDLM
From source
git clone https://github.com/PyTDLM/TDLM.git
cd TDLM
pip install -e .
Quick Start
import numpy as np
from TDLM import tdlm
# Prepare your data
mi = np.array([100, 200, 150]) # Origin masses
mj = np.array([80, 180, 120]) # Destination masses
dij = np.array([[0, 10, 15], # Distance matrix
[10, 0, 8],
[15, 8, 0]])
Oi = np.array([50, 80, 60]) # Out-trips
Dj = np.array([40, 90, 50]) # In-trips
Tij_observed = np.array([[0, 25, 25], # Observed trip matrix
[30, 0, 50],
[35, 35, 0]])
# Run simulation
exponent = np.arange(0.1, 1.01, 0.01)
results = tdlm.run_law_model(
law='NGravExp',
mass_origin=mi,
mass_destination=mj,
distance=dij,
exponent=exponent,
model='DCM',
out_trips=Oi,
in_trips=Dj,
repli=100
)
# Calculate goodness-of-fit
gof_results = tdlm.gof(sim=results, obs=Tij_observed, distance=dij)
# Print results for a given exponent
print(gof_results[0.1].to_markdown(index=False))
Documentation
For detailed documentation and examples, visit: https://rtdlm.github.io/PyTDLM/
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Citation
If you use this library in your research, please cite:
@software{lenormand2024tdlm,
title={TDLM: Trip Distribution Law Models},
author={Lenormand, Maxime},
year={2024},
url={https://github.com/RTDLM/PyTDLM}
}
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
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 pytdlm-0.1.0.tar.gz.
File metadata
- Download URL: pytdlm-0.1.0.tar.gz
- Upload date:
- Size: 79.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d86da31869a65d763e83113feef200475a18f7960f798a9b36a2783a16862ae6
|
|
| MD5 |
a018517e5dd5a4b5e27560134c9620e5
|
|
| BLAKE2b-256 |
d3af852ed9099cb0e0ff5e8fbc3cc55cde3a275cf1835c919f94f98abb5a36d4
|
File details
Details for the file pytdlm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytdlm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34faa61c2942b2bc26291d1ecc9aa496f37bc69ac1c8fa4d8026e09ed8c1a162
|
|
| MD5 |
b0cd4f0506bda88b8f31262d564a9b52
|
|
| BLAKE2b-256 |
d9d8fd9067ac5d930eafc3df63081fe16fe67617005c029e89830f2ba21823ad
|