Skip to content

fix(shared_mobility): set initialSoc on EV-typed dummy routing vehicles#4899

Merged
nkuehnel merged 1 commit into
matsim-org:mainfrom
marecabo:fix/npe-in-shared-routing-vehicle-for-ev
Apr 29, 2026
Merged

fix(shared_mobility): set initialSoc on EV-typed dummy routing vehicles#4899
nkuehnel merged 1 commit into
matsim-org:mainfrom
marecabo:fix/npe-in-shared-routing-vehicle-for-ev

Conversation

@marecabo

Copy link
Copy Markdown
Contributor

When a sharing service uses an electric vehicle type (HbefaTechnology="electricity"), getOrCreateAndAddDummyVehicle() creates a routing-only dummy vehicle with that type but without setting the initialSoc attribute.

Since #4834, GlobalElectricFleet picks up all EV-typed vehicles from scenario.getVehicles() and wraps them via ElectricVehicleSpecificationDefaultImpl, whose constructor reads initialSoc. The missing attribute causes an NPE (null → double unboxing).

Fix: Use ElectricFleetUtils.isElectricVehicleType() and setInitialSoc() to set initialSoc = 1.0 on the dummy vehicle when its type is electric. Adds ev contrib as a dependency of shared_mobility. The dummy is only used for replanning route calculations and never participates in the EV simulation, so the value has no functional impact.

@nkuehnel nkuehnel added this pull request to the merge queue Apr 29, 2026
Merged via the queue into matsim-org:main with commit cccd232 Apr 29, 2026
51 checks passed
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