Skip to content

fix(drt): Compute sharing metrics per DRT mode#4844

Merged
nkuehnel merged 1 commit into
matsim-org:mainfrom
samuelhoenle:fix/drt/multimodedrt-sharingmetrics
Apr 7, 2026
Merged

fix(drt): Compute sharing metrics per DRT mode#4844
nkuehnel merged 1 commit into
matsim-org:mainfrom
samuelhoenle:fix/drt/multimodedrt-sharingmetrics

Conversation

@samuelhoenle

Copy link
Copy Markdown
Contributor

Problem

When multiple DRT modes are configured, SharingMetricsTracker – although instantiated once per mode – performed no mode filtering on the events it received, so every tracker processed trips from all modes and produced identical output regardless of mode.

Solution

SharingMetricsTracker now accepts a mode constructor argument and guards all three handleEvent methods with an event.getMode().equals(mode) check, following the same pattern used by DrtEventSequenceCollector and other modal handlers; SharingMetricsModule passes getMode() to the constructor.

A unit test is also added.

Tagging the original author @nkuehnel for review

@Janekdererste Janekdererste requested a review from nkuehnel April 7, 2026 06:24
@nkuehnel

nkuehnel commented Apr 7, 2026

Copy link
Copy Markdown
Member

Thanks, didn't have the multi drt use case in mind back then. Looks good to me

@nkuehnel nkuehnel added this pull request to the merge queue Apr 7, 2026
Merged via the queue into matsim-org:main with commit 8400d12 Apr 7, 2026
50 checks passed
@samuelhoenle samuelhoenle deleted the fix/drt/multimodedrt-sharingmetrics branch April 7, 2026 13:12
Copilot AI pushed a commit to steffenaxer/matsim-libs that referenced this pull request Apr 7, 2026
steffenaxer added a commit to steffenaxer/matsim-libs that referenced this pull request Apr 8, 2026
* feat(router): Add time-dependent CATCHUp bidirectional CH router (SpeedyCH) (#48)

* build(deps): bump the all-dependencies group across 1 directory with 3 updates (matsim-org#4845)

Bumps the all-dependencies group with 3 updates in the / directory: [org.codehaus.woodstox:stax2-api](https://github.com/FasterXML/stax2-api), [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) and software.amazon.awssdk:bom.


Updates `org.codehaus.woodstox:stax2-api` from 4.2.2 to 4.3.0
- [Commits](FasterXML/stax2-api@stax2-api-4.2.2...stax2-api-4.3.0)

Updates `net.bytebuddy:byte-buddy` from 1.18.7 to 1.18.8
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.18.7...byte-buddy-1.18.8)

Updates `software.amazon.awssdk:bom` from 2.42.23 to 2.42.25

---
updated-dependencies:
- dependency-name: org.codehaus.woodstox:stax2-api
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: net.bytebuddy:byte-buddy
  dependency-version: 1.18.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.42.25
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(drt): Compute sharing metrics per DRT mode (matsim-org#4844)

* feat(drt): Enable SpeedyCH time-dependent router for DRT insertion search (#49)

* feat(router): add build statistics tracking for CH contraction process

* feat(benchmark): enhance DRT benchmark with request inserter types and insertion search strategies

* fix(dvrp): fix ArrayIndexOutOfBoundsException in CHRouter + OneToManyPathCalculator (#50)

* feat(benchmark): update insertion search strategy to RepeatedSelective

* fix test

* fix: translate colored node indices through spatial reorder mapping and fix tests

- Add SpeedyGraph.getInternalIndex(int) for raw external index translation
- Fix LeastCostPathTree colored node index in forward/backward search
- Fix SpeedyDijkstra, SpeedyALT, CHRouter, CHRouterTimeDep colored node indices
- Fix SpeedyMultiSourceALT to use graph.getNodeIndex() instead of node.getId().index()
- Fix LeastCostPathTreeTurnRestrictionsTest to use tree.getNodeIndex()
- Update ReRoutingIT CH test: verify simulation succeeds instead of golden reference
  (CH construction is non-deterministic with spatial node ordering)

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: deterministic Morton code tie-breaking and restore ReRoutingIT CH golden reference test

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: make CH router fully deterministic and regenerate golden reference

Two sources of non-determinism fixed:

1. InertialFlowCutter: Replace shared AtomicInteger levelCounter in
   parallel recursion with a two-phase approach: Phase 1 builds a
   deterministic NDCell tree (parallel), Phase 2 assigns levels via
   sequential depth-first walk.

2. CHBuilder: Disable parallel contraction (pool=null) because cells
   in the same round share adjacency structures — shortcuts from one
   cell can affect another cell's witness search, creating different
   shortcut sets per run. Additionally, sort each node's CSR edges by
   (neighborNode, origLink) in buildCHGraph() for deterministic edge
   iteration order.

Verified deterministic across multiple runs:
- ReRoutingIT: 4/4 pass (3 consecutive runs identical)
- CH/Speedy tests: 81/81 pass
- dvrp tests: 79/79 pass

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/ea70a0e9-8db0-4344-99a7-1895ad33d191

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Hönle <samuel.hoenle@ait.ac.at>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
steffenaxer added a commit to steffenaxer/matsim-libs that referenced this pull request Apr 8, 2026
* feat(router): Add time-dependent CATCHUp bidirectional CH router (SpeedyCH) (#48)

* build(deps): bump the all-dependencies group across 1 directory with 3 updates (matsim-org#4845)

Bumps the all-dependencies group with 3 updates in the / directory: [org.codehaus.woodstox:stax2-api](https://github.com/FasterXML/stax2-api), [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) and software.amazon.awssdk:bom.


Updates `org.codehaus.woodstox:stax2-api` from 4.2.2 to 4.3.0
- [Commits](FasterXML/stax2-api@stax2-api-4.2.2...stax2-api-4.3.0)

Updates `net.bytebuddy:byte-buddy` from 1.18.7 to 1.18.8
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.18.7...byte-buddy-1.18.8)

Updates `software.amazon.awssdk:bom` from 2.42.23 to 2.42.25

---
updated-dependencies:
- dependency-name: org.codehaus.woodstox:stax2-api
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: net.bytebuddy:byte-buddy
  dependency-version: 1.18.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.42.25
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(drt): Compute sharing metrics per DRT mode (matsim-org#4844)

* feat(drt): Enable SpeedyCH time-dependent router for DRT insertion search (#49)

* feat(router): add build statistics tracking for CH contraction process

* feat(benchmark): enhance DRT benchmark with request inserter types and insertion search strategies

* fix(dvrp): fix ArrayIndexOutOfBoundsException in CHRouter + OneToManyPathCalculator (#50)

* feat(benchmark): update insertion search strategy to RepeatedSelective

* fix test

* fix: translate colored node indices through spatial reorder mapping and fix tests

- Add SpeedyGraph.getInternalIndex(int) for raw external index translation
- Fix LeastCostPathTree colored node index in forward/backward search
- Fix SpeedyDijkstra, SpeedyALT, CHRouter, CHRouterTimeDep colored node indices
- Fix SpeedyMultiSourceALT to use graph.getNodeIndex() instead of node.getId().index()
- Fix LeastCostPathTreeTurnRestrictionsTest to use tree.getNodeIndex()
- Update ReRoutingIT CH test: verify simulation succeeds instead of golden reference
  (CH construction is non-deterministic with spatial node ordering)

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: deterministic Morton code tie-breaking and restore ReRoutingIT CH golden reference test

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: make CH router fully deterministic and regenerate golden reference

Two sources of non-determinism fixed:

1. InertialFlowCutter: Replace shared AtomicInteger levelCounter in
   parallel recursion with a two-phase approach: Phase 1 builds a
   deterministic NDCell tree (parallel), Phase 2 assigns levels via
   sequential depth-first walk.

2. CHBuilder: Disable parallel contraction (pool=null) because cells
   in the same round share adjacency structures — shortcuts from one
   cell can affect another cell's witness search, creating different
   shortcut sets per run. Additionally, sort each node's CSR edges by
   (neighborNode, origLink) in buildCHGraph() for deterministic edge
   iteration order.

Verified deterministic across multiple runs:
- ReRoutingIT: 4/4 pass (3 consecutive runs identical)
- CH/Speedy tests: 81/81 pass
- dvrp tests: 79/79 pass

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/ea70a0e9-8db0-4344-99a7-1895ad33d191

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Hönle <samuel.hoenle@ait.ac.at>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Apr 14, 2026
* feat(router): implement customizable CCH router with CATCHUp extension for time-dependent routing

* feat(router): Add time-dependent CATCHUp bidirectional CH router (SpeedyCH) (#48)

* build(deps): bump the all-dependencies group across 1 directory with 3 updates (#4845)

Bumps the all-dependencies group with 3 updates in the / directory: [org.codehaus.woodstox:stax2-api](https://github.com/FasterXML/stax2-api), [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) and software.amazon.awssdk:bom.


Updates `org.codehaus.woodstox:stax2-api` from 4.2.2 to 4.3.0
- [Commits](FasterXML/stax2-api@stax2-api-4.2.2...stax2-api-4.3.0)

Updates `net.bytebuddy:byte-buddy` from 1.18.7 to 1.18.8
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.18.7...byte-buddy-1.18.8)

Updates `software.amazon.awssdk:bom` from 2.42.23 to 2.42.25

---
updated-dependencies:
- dependency-name: org.codehaus.woodstox:stax2-api
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: net.bytebuddy:byte-buddy
  dependency-version: 1.18.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.42.25
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(drt): Compute sharing metrics per DRT mode (#4844)

* feat(drt): Enable SpeedyCH time-dependent router for DRT insertion search (#49)

* feat(router): add build statistics tracking for CH contraction process

* feat(benchmark): enhance DRT benchmark with request inserter types and insertion search strategies

* fix(dvrp): fix ArrayIndexOutOfBoundsException in CHRouter + OneToManyPathCalculator (#50)

* feat(benchmark): update insertion search strategy to RepeatedSelective

* fix test

* fix(router): Make CH router fully deterministic (#51)

* feat(router): Add time-dependent CATCHUp bidirectional CH router (SpeedyCH) (#48)

* build(deps): bump the all-dependencies group across 1 directory with 3 updates (#4845)

Bumps the all-dependencies group with 3 updates in the / directory: [org.codehaus.woodstox:stax2-api](https://github.com/FasterXML/stax2-api), [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) and software.amazon.awssdk:bom.


Updates `org.codehaus.woodstox:stax2-api` from 4.2.2 to 4.3.0
- [Commits](FasterXML/stax2-api@stax2-api-4.2.2...stax2-api-4.3.0)

Updates `net.bytebuddy:byte-buddy` from 1.18.7 to 1.18.8
- [Release notes](https://github.com/raphw/byte-buddy/releases)
- [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md)
- [Commits](raphw/byte-buddy@byte-buddy-1.18.7...byte-buddy-1.18.8)

Updates `software.amazon.awssdk:bom` from 2.42.23 to 2.42.25

---
updated-dependencies:
- dependency-name: org.codehaus.woodstox:stax2-api
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: net.bytebuddy:byte-buddy
  dependency-version: 1.18.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: software.amazon.awssdk:bom
  dependency-version: 2.42.25
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix(drt): Compute sharing metrics per DRT mode (#4844)

* feat(drt): Enable SpeedyCH time-dependent router for DRT insertion search (#49)

* feat(router): add build statistics tracking for CH contraction process

* feat(benchmark): enhance DRT benchmark with request inserter types and insertion search strategies

* fix(dvrp): fix ArrayIndexOutOfBoundsException in CHRouter + OneToManyPathCalculator (#50)

* feat(benchmark): update insertion search strategy to RepeatedSelective

* fix test

* fix: translate colored node indices through spatial reorder mapping and fix tests

- Add SpeedyGraph.getInternalIndex(int) for raw external index translation
- Fix LeastCostPathTree colored node index in forward/backward search
- Fix SpeedyDijkstra, SpeedyALT, CHRouter, CHRouterTimeDep colored node indices
- Fix SpeedyMultiSourceALT to use graph.getNodeIndex() instead of node.getId().index()
- Fix LeastCostPathTreeTurnRestrictionsTest to use tree.getNodeIndex()
- Update ReRoutingIT CH test: verify simulation succeeds instead of golden reference
  (CH construction is non-deterministic with spatial node ordering)

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: deterministic Morton code tie-breaking and restore ReRoutingIT CH golden reference test

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/934c5dff-2a0c-4f13-9449-51662b958f4e

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: make CH router fully deterministic and regenerate golden reference

Two sources of non-determinism fixed:

1. InertialFlowCutter: Replace shared AtomicInteger levelCounter in
   parallel recursion with a two-phase approach: Phase 1 builds a
   deterministic NDCell tree (parallel), Phase 2 assigns levels via
   sequential depth-first walk.

2. CHBuilder: Disable parallel contraction (pool=null) because cells
   in the same round share adjacency structures — shortcuts from one
   cell can affect another cell's witness search, creating different
   shortcut sets per run. Additionally, sort each node's CSR edges by
   (neighborNode, origLink) in buildCHGraph() for deterministic edge
   iteration order.

Verified deterministic across multiple runs:
- ReRoutingIT: 4/4 pass (3 consecutive runs identical)
- CH/Speedy tests: 81/81 pass
- dvrp tests: 79/79 pass

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/ea70a0e9-8db0-4344-99a7-1895ad33d191

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Hönle <samuel.hoenle@ait.ac.at>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* feat(router): optimize subgraph refinement thresholds and enhance logging for benchmarks

* fix(test)

* feat(router): Improve CHRouter

* Update plans_CH.xml.gz to match

* fix(SpeedyGraphBuilder): scope Z-order node reordering to CHRouter only (#52)

* feat(router): set default locale to US for consistent number formatting in benchmarks

* feat(router): enhance CHBuilder to support configurable thread count for parallel contraction

* fix(CHRouterFactory): add no-arg constructor for backward compatibility (#53)

The CHRouterFactory constructor was changed to require GlobalConfigGroup,
but SingleInsertionDetourPathCalculator uses a no-arg new CHRouterFactory().
This broke compilation of drt and all its dependents (taxi,
commercialTrafficApplications, accessibility, integration, av, vsp,
simwrapper).

Add a no-arg constructor that delegates to the injected constructor with
default GlobalConfigGroup (nThreads=2), preserving backward compatibility.

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/a7a83643-0bb5-4cff-8f3b-6193cd701ab6

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: revert SpeedyALTData.java to upstream/main (NodeMinHeap) for retrofit compatibility

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/e1a1e82f-b09c-41cd-9319-42406ce7ec6d

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* fix: restore test reference files from upstream/main after SpeedyALTData revert

Agent-Logs-Url: https://github.com/steffenaxer/matsim-libs/sessions/cf1afc12-dd97-4e8d-9e31-f35d2246886f

Co-authored-by: steffenaxer <26229392+steffenaxer@users.noreply.github.com>

* refactor(benchmark): move RouterBenchmark to benchmark module

* refactor(benchmark): move RouterBenchmark (real-network, CH+ALT) to benchmark module

- Replace synthetic-grid version with the real RouterBenchmark from speedy package
- Make SpeedyALTData public, add CHGraph.getTotalEdgeCount() and SpeedyGraph.getNodeCount()
- Use SpeedyGraphBuilder.buildWithSpatialOrdering() instead of deprecated build()

* Add some more stats

* Fix SpeedyALTData

* refactor: update routing algorithm configuration and remove deprecated methods

* refactor: enhance OD pair generation with new modes and statistics

* Refactor InertialFlowCutter

* Update config

* refactor: improve CHRouter test suite and enhance turn restriction handling

* refactor: enhance CHRouter with turn restriction handling and add static test suite

* Delete dev. code

* fix: update reference file to check determinism

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Hönle <samuel.hoenle@ait.ac.at>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants