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

improve traveltime calculation on last link of a route #3092

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -314,9 +314,7 @@ private List<? extends PlanElement> computeAccessTripFromFacilityToLinkIfNecessa
}

private static Activity createInteractionActivity(final Coord interactionCoord, final Id<Link> 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,
Expand Down Expand Up @@ -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;
Expand Down
Loading