Skip to content

Refactoring Shortest travel times journey chain using OD Matrix algorithm #784

@louisgreiner

Description

@louisgreiner

Description

Note

The "Shortest travel times journey chain" is also refered as "Analytics" feature (which is actually the name used in the application).

The current "Analytics" feature:

  • uses a separate, slower, and unreliable algorithm,
  • produces different results than the OD Matrix,
  • loses its rendered results when the user pans/zooms the network - the rendering integration is poor - just quick & dirty implemented.

The "Analytics" feature should be refactored to display to travel times and the connections given by the OD Matrix algorithm. Unify the “Analytics” shortest‑path feature with the OD Matrix algorithm so both features use the same computation logic, produce identical travel‑time results, and behave consistently in the UI. The current code should be totally replaced by this, to use a single algorithm for the both features.

The next version of Netzgrafik "Analytics" will only support interactions based on clicking a node.

The following screenshots have been made using this network: analytics.json. When clicking on the "Analytics" button, the view changes, highlighting the departure minutes:

Image

Then we can click on any node (here on node A), and this shows the shortest path to other nodes. Using this shortest path, (1) represents the number of connections to this node and (2) represents the travel time to this node.

Image

However, when we look at the Origin-Destination Matrix for the same network, the results are not the same. For instance, if we click on node F:

Image

The OD Matrix does not output the same result (⚠️ make sure to click on "Temps de parcours", to observe only the travel times, and not the "cost", which is travel time + connections * penality)

Image

As we have a better trust on the OD Matrix algorithm, we need both features to use the same algorithm, then displaying the same results. The goal is then to refactor the OD Matrix algorithm, to be able to use it elsewhere and generate the shortest path from the clicked node to all other nodes (and not from all nodes to all nodes, which is currently what the OD Matrix algorithm doing).

Mock-ups

The rendering should not be affected by this refactoring, except that the color of the nodes after computation should be based on the travel time, using the same color scale as the OD Matrix does.

Acceptance Criteria

  • The OD Matrix feature works the same and display the same results as before the refactoring
  • The "Analytics" feature works the same as before and display the same results as the OD Matrix feature, without taking connection penality into account
    • Clicking on a node compute "one‑to‑all shortest paths computation"
      • In the nodes, the "Total travel time" and "Connections" are displayed:
        • "Connections" (number of transfers): displayed on the left side of the node as #n
        • "Total travel time" (travel time without any penalty): displayed on the right side of the node, formatted as hh:mm.
      • The nodes then are colored, using the same color scale as the OD Matrix does, based on the "Total travel time" value
    • The trainrun sections part of the computed shortest paths are highlighted (as it is already the case with old "Analytics" feature)
    • The transitions part of the computed shortest paths are highlighted (as it is already the case with old "Analytics" feature)
  • "Analytics" feature should take active filters into account (as it is already the case for OD Matrix feature)
  • Once the "Analytics" is activated and a result is there, it remains visible until another node is clicked, or "Analytics" is explicitly deactivated
  • "Analytics" only supports interactions based on clicking a node
  • Paning and zooming don't affect the results rendering
  • Exports (.png and .svg) allow rendered results to be exported

Implementation Plan

  • Refactor the OD Matrix algorithm service to make it possible to generate the shortest path from a node to all other nodes (and not from all nodes to all other nodes) and make it available from a service.
  • Remove all the existing "Analytics" algorithm code, and use the above service instead
  • Populate the "Analytics" rendered values with the OD Matrix algorithm service
  • Update the tests (or create new ones) to test the unified algorithm and both endpoints

Tests

Definition of Ready

  • PO/UX-UI

    • Mock-ups are complete and validated
    • ACs are clear and have been reviewed by another refiner
  • Technical

    • Implementation plan has been written and validated by another maintainer
  • General

    • Validated by Adrian

Outscope TODOs

This will need to create another issue:

  • Extended UI
    • such as checkboxes or switches, for the "value" fields and "color" parameter
  • Prepare Analytics component for future extension (difficult to imagine from that)

Metadata

Metadata

Labels

area:servicesServices, helpers, utils and i18n ("logical" stuff)design-documentThis is the main document that a developer uses to implement a featurefeature-requestA request of a new feature of the enhancement of an existing one

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions