Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup route search algorithm in RouteChoice class by ~60x #55

Closed
wants to merge 2 commits into from

Commits on Apr 1, 2024

  1. Speedup route_search_all ~20x with Dijkstra's algorithm for sparse gr…

    …aphs
    
    Replaced the Floyd-Warshall algorithm in `route_search_all` with Dijkstra's algorithm using scipy's sparse matrix representation for improved performance in sparse graphs. This change addresses the performance bottleneck by leveraging Dijkstra's inherent efficiency for such structures and direct path reconstruction capabilities, significantly reducing computation time for shortest path routing. Updated relevant data structures and removed unnecessary post-processing steps for next node determination.
    
    In a real-world road graph with 3275 links and 1552 nodes, it reduced the time route_search_all from ~19 seconds to ~0.85 seconds, an over 20x speedup.
    EwoutH authored Apr 1, 2024
    Configuration menu
    Copy the full SHA
    1b9df13 View commit details
    Browse the repository at this point in the history
  2. Speedup route_search_all ~3x with vectorized updates of next matrix

    Refactor the route_search_all method in RouteChoice to utilize NumPy's vectorized operations and boolean indexing, eliminating nested loops for updating the next matrix. This significantly enhances performance by reducing Python loop overhead in sparse graph computations.
    
    In a real-world road graph with 3275 links and 1552 nodes, it reduced the time route_search_all from ~0.85 seconds to ~0.30 seconds, a ~3x speedup.
    
    Together with the previous commit, it reduced the time route_search_all from ~19 seconds to ~0.3 seconds, a ~60x speedup.
    EwoutH committed Apr 1, 2024
    Configuration menu
    Copy the full SHA
    34a3b42 View commit details
    Browse the repository at this point in the history