Skip to content

saba-rsl/od-matrix-estimation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Origin-Destination (OD) Matrix Estimation

Project Description

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.

Project Structure

OD/
│
├── generator.py
├── estimator.py
├── main.py
├── README.md
└── requirements.txt

Requirements

  • Python 3.10+
  • NumPy
  • SciPy
  • NetworkX

Install dependencies:

pip install -r requirements.txt

or

pip install numpy scipy networkx

Files

generator.py

Responsible 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

estimator.py

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

main.py

Runs the complete workflow:

  1. Generate synthetic data.
  2. Estimate the OD matrix.
  3. Display the results.

Mathematical Model

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.


Example Workflow

Transportation Network
        │
        ▼
Generate True OD Matrix
        │
        ▼
Compute Shortest Paths
        │
        ▼
Build Assignment Matrix (P)
        │
        ▼
Generate Link Counts
        │
        ▼
Estimate OD Matrix (NNLS)
        │
        ▼
Evaluation

Output

The program prints:

  • True OD Matrix
  • Estimated OD Matrix
  • Observed Link Counts
  • Reconstructed Link Counts
  • RMSE
  • Residual Error

Author

Origin-Destination Matrix Estimation using NNLS

About

Python implementation of Origin-Destination Matrix Estimation using Non-Negative Least Squares (NNLS).

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages