From 70dbb7b8ff49a68c69f9e7c8c220c5749b923dab Mon Sep 17 00:00:00 2001 From: Joschka Bischoff Date: Tue, 6 Feb 2024 15:42:12 +0100 Subject: [PATCH] improve traveltime calculation on last link of a route in NetworkRoutingInclAccessEgressModule --- .../NetworkRoutingInclAccessEgressModule.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java index 49da68730c1..1a24567b1dd 100644 --- a/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java +++ b/matsim/src/main/java/org/matsim/core/router/NetworkRoutingInclAccessEgressModule.java @@ -82,7 +82,7 @@ public final class NetworkRoutingInclAccessEgressModule implements RoutingModule private final Config config; private static boolean hasWarnedAccessEgress = false; - private RoutingConfigGroup.AccessEgressType accessEgressType; + private final RoutingConfigGroup.AccessEgressType accessEgressType; private final TimeInterpretation timeInterpretation; private final MultimodalLinkChooser multimodalLinkChooser; @@ -102,7 +102,7 @@ public final class NetworkRoutingInclAccessEgressModule implements RoutingModule final MultimodalLinkChooser multimodalLinkChooser) { this.multimodalLinkChooser = multimodalLinkChooser; Gbl.assertNotNull(scenario.getNetwork()); - Gbl.assertIf(scenario.getNetwork().getLinks().size() > 0); // otherwise network for mode probably not defined + Gbl.assertIf(!scenario.getNetwork().getLinks().isEmpty()); // otherwise network for mode probably not defined this.filteredNetwork = filteredNetwork; this.invertedNetwork = invertedNetwork; this.routeAlgo = routeAlgo; @@ -314,9 +314,7 @@ private List computeAccessTripFromFacilityToLinkIfNecessa } private static Activity createInteractionActivity(final Coord interactionCoord, final Id interactionLink, final String mode) { - Activity act = PopulationUtils.createStageActivityFromCoordLinkIdAndModePrefix(interactionCoord, interactionLink, mode); -// act.setMaximumDuration(0.0); // obsolete since this is hard-coded in InteractionActivity - return act; + return PopulationUtils.createStageActivityFromCoordLinkIdAndModePrefix(interactionCoord, interactionLink, mode); } private static void routeBushwhackingLeg(Person person, Leg leg, Coord fromCoord, Coord toCoord, double depTime, @@ -410,9 +408,16 @@ public String toString() { NetworkRoute route = this.populationFactory.getRouteFactories().createRoute(NetworkRoute.class, fromLink.getId(), toLink.getId()); route.setLinkIds(fromLink.getId(), NetworkUtils.getLinkIds(path.links), toLink.getId()); - route.setTravelTime((int) path.travelTime); + + double relPosOnDepartureLink = 1.0; + double relPosOnArrivalLink = 1.0; + + double maxSpeedOnToLink = Math.min(vehicle.getType().getMaximumVelocity(),toLink.getFreespeed()); + double travelTimeEstimateOnToLink = (toLink.getLength() / maxSpeedOnToLink) * relPosOnArrivalLink; + route.setTravelTime((int) (path.travelTime+travelTimeEstimateOnToLink)); + route.setTravelCost(path.travelCost); - route.setDistance(RouteUtils.calcDistance(route, 1.0, 1.0, this.filteredNetwork)); + route.setDistance(RouteUtils.calcDistance(route, relPosOnDepartureLink, relPosOnArrivalLink, this.filteredNetwork)); route.setVehicleId(vehicleId); leg.setRoute(route); travTime = (int) path.travelTime;