PyTorch implementations of route choice models for transportation networks. Sparse operations via PyTorch Geometric and implicit differentiation via torchdeq.
- RecursiveLogitRouteChoice (aliased as
MarkovRouteChoice): link-based network route choice (Fosgerau et al., 2013), can also implement Maximum Entropy IRL (Ziebart et al., 2008). - NestedRecursiveLogitRouteChoice: nested recursive logit with link-specific scale parameters (Mai et al., 2015).
- PerturbedUtilityRouteChoice: perturbed utility route choice (Fosgerau et al., 2022).
pip install git+https://github.com/ben-hudson/pytorch-route-choice
| Example | Description |
|---|---|
| recursive_logit_example.py | Learn edge rewards from sampled paths via maximum likelihood |
| maxent_irl_example.py | Maximum Entropy IRL by matching observed feature counts |
| purc_example.py | Learn utility rates from observed edge flows |
| markov_traffic_example.py | Traffic equilibrium on the Sioux Falls network using deep equilibrium models |
pip install -e .
pytest tests
- The core computation solves linear fixed-point problems
x = Ax + bvia message passing on sparse graphs, usingtorchdeqfor implicit differentiation. - Graph data uses PyTorch Geometric's
edge_index(COO format) convention:[2, num_edges]tensor. MarkovRouteChoiceis aliased toRecursiveLogitRouteChoice.RecursiveLogitRouteChoicerequires batch dimensions for inputs (use.unsqueeze(0)for single instances).node_dimis specified as a negative offset (default-1) to support batched operations.
