Skip to content

Repository files navigation

Environment and Package Dependencies

The code can be successfully run under the following environments:

  • Python: 3.12
  • Pytorch version: 2.4 with CUDA 12
  • Pytorch Geometric: 2.6
  • OS: Ubuntu 20.04

The project will also need following package dependencies:

  • numpy
  • pandas
  • networkx
  • scikit-learn
  • geopandas

Format of the Data

Download the preprocessed data and unzip the downloaded .zip file. For each city (Chengdu, Xi'an, Harbin), there are two types of data:

1. Map-matched trajectory data

The format of map-matched trajectory data like as follows.

300025317,1420450387:300025317,"[[16.802265242420546, 1420450387.0, 126.65103311774592, 45.7878318674776], [239.89418179178656, 1420450763.0, 126.6578089666113, 45.78561232682575]]","[[3964, 1420450372.601, 1.167, 138.136], [8612, 1420450510.736, 1.167, 46.637], [9130, 1420450557.374, 1.167, 3.01], [3939, 1420450560.384, 2.752, 53.701], [3946, 1420450614.084, 2.832, 49.639], [3927, 1420450663.723, 2.376, 36.009], [2138, 1420450699.733, 2.376, 5.036], [11308, 1420450704.769, 4.12, 65.577]]"
...

Each line records four fields to represent a map-matched trajectory, i.e., moving object id, trajectory id, offsets and segment sequence. For example,

offsets: [16.802265242420546, 1420450387.0, 126.65103311774592, 45.7878318674776] means 
         (the distance between the start point of source segment and the source location,
          departure time,
          the longitude of source location,
          the latitude of source location,)
          The destination location has similar information.

segment sequence: [3964, 1420450372.601, 1.167, 138.136] means 
                  [segment id,
                   the timestamp when trajectory enter this segment,
                   the average speed when the trajectory go through this segment,
                   the duration for the trajectory through this segment]

2. OSM map data

The maps used in UNITE is extracted from OpenStreetMap. In the map folder, there are the following files:

  1. nodes.shp : Contains OSM node information with unique node id.
  2. edges.shp : Contains network connectivity information with unique edge id.

Directory Structure

The directory structure is as follows.

codespace
    ├ util.py: helper functions and evaluation metrics for TTE task
    ├ seg_info.py: generate attributes for road segments to support workspace preparation
    ├ prepare_workspace.py: generate the labeled historical trajectories for model training
    ├ train.py: UNITE model training process
    ├ infer_ODTTE.py: estimate travel times under ODTTE setting
    ├ infer_RTTE.py: estimate travel times under RTTE setting
    ├ models
    |   ├ layers.py: ODT Encoding layer, Travel Time Estimation layer and Next Segment Prediction layer
    |   └ tte.py: UNITE model
    └ utils
        └ map.py: Road Network implentation with R-tree
        
workspace (e.g., /data)
    └ dataset_name1 (e.g., xa_data)
        ├ map
        |   ├ nodes.shp
        |   └ edges.shp
        ├ traj_train.csv
        ├ traj_valid.csv
        └ traj_test.csv

Usage

  • Run prepare_workspace.py to generate the labeled historical trajectories for model training. You can also modify the corresponding parameters when preparing your own data workspace.
  • Run train.py to train a UNITE model.
  • Run infer_ODTTE.py to estimate travel times under ODTTE setting.
  • Run infer_RTTE.py to estimate travel times under RTTE setting.

To get the details of the parameters when using UNITE, please refer to the parameters in train.py where each field is described in detail in comments.

Citations

If you use the code or data in this repository, citing our paper as the following will be really appropriate.

@inproceedings{tian2026unite,
  author       = {Wei Tian and
                  Jieming Shi and
                  Man Lung Yiu},
  title        = {UNITE: A Unified Framework for Accurate and Efficient Origin-Destination and Route Travel Time Estimation},
  booktitle    = {{KDD} 2026},
  pages        = {1--12},
  numpages     = {12},
  year         = {2026}
}

About

UNITE: A Unified Framework for Accurate and Efficient Origin-Destination and Route Travel Time Estimation (KDD'26)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages