This project estimates an Origin-Destination (OD) matrix from observed traffic link counts using a Non-Negative Least Squares (NNLS) approach.
The project is divided into two independent modules:
- Generator: Creates synthetic transportation network data, including the true OD matrix, assignment matrix, and observed link counts.
- Estimator: Estimates the OD matrix using the assignment matrix and observed link counts.
OD/
│
├── generator.py
├── estimator.py
├── main.py
├── README.md
└── requirements.txt
- Python 3.10+
- NumPy
- SciPy
- NetworkX
Install dependencies:
pip install -r requirements.txtor
pip install numpy scipy networkxResponsible for generating synthetic traffic data.
Functions include:
- Generate transportation network
- Generate true OD matrix
- Compute shortest paths
- Build assignment matrix (P)
- Compute observed link counts
Outputs:
- Assignment Matrix (P)
- True OD Matrix
- Link Counts
Implements the OD estimation algorithm.
Input:
- Assignment Matrix (P)
- Observed Link Counts
Method:
- Non-Negative Least Squares (NNLS)
Output:
- Estimated OD Matrix
- Reconstructed Link Counts
- RMSE
- Residual Error
Runs the complete workflow:
- Generate synthetic data.
- Estimate the OD matrix.
- Display the results.
The estimation problem is formulated as
P × x ≈ y
where
- P : Assignment Matrix
- x : Unknown OD demand vector
- y : Observed link counts
The optimization problem is
min ||P x - y||²
subject to
x ≥ 0
which is solved using the Non-Negative Least Squares (NNLS) algorithm provided by SciPy.
Transportation Network
│
▼
Generate True OD Matrix
│
▼
Compute Shortest Paths
│
▼
Build Assignment Matrix (P)
│
▼
Generate Link Counts
│
▼
Estimate OD Matrix (NNLS)
│
▼
Evaluation
The program prints:
- True OD Matrix
- Estimated OD Matrix
- Observed Link Counts
- Reconstructed Link Counts
- RMSE
- Residual Error
Origin-Destination Matrix Estimation using NNLS