From 3386d41b6962dc8977d116942a32c27d406324dd Mon Sep 17 00:00:00 2001 From: tschlenther Date: Thu, 31 Aug 2023 12:10:07 +0200 Subject: [PATCH] fix: no ptOnlyPlan for riders with inner trips only --- .../matsim/run/replaceCarByDRT/ReplaceCarByDRT.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/matsim/run/replaceCarByDRT/ReplaceCarByDRT.java b/src/main/java/org/matsim/run/replaceCarByDRT/ReplaceCarByDRT.java index 15ccd29..bab1a49 100644 --- a/src/main/java/org/matsim/run/replaceCarByDRT/ReplaceCarByDRT.java +++ b/src/main/java/org/matsim/run/replaceCarByDRT/ReplaceCarByDRT.java @@ -177,16 +177,19 @@ static void prepareInputPlansForCarProhibitionWithPRLogic(Scenario scenario, long nrOfOutsideTripsWithModesToReplace = tripsToReplace.stream() .filter(trip -> trip.getTripAttributes().getAttribute(TRIP_TYPE_ATTR_KEY).equals(TripType.outsideTrip)) .count(); + long nrOfInnerTripsToWithModesToReplace = tripsToReplace.stream() + .filter(trip -> trip.getTripAttributes().getAttribute(TRIP_TYPE_ATTR_KEY).equals(TripType.innerTrip)) + .count(); if(nrOfOutsideTripsWithModesToReplace == tripsToReplace.size()){ plan.setType("not-affected"); continue; //this agent is not affected by the prohibition zone. } - //create and add a plan, where all the trips to replace are NOT split up with P+R logic but are just replaced by a pt trip if(extraPTPlan){ - if(nrOfBorderCrossingCarTrips != 0){ -// we have checked whether the plan contains only external trips, above. So if we have no border-crossing trips, here, the plan only consists of inner trips. -// if we have only inner trips, we do not want to create ptOnly plan because it will be the same as a pt plan (when pt is configured as replacing mode) and thus increase the chance of choosing pt naturally. +// if we have only inner trips, we do not want to create ptOnly plan because it will be the same as a pt plan (when pt is configured as replacing mode) and thus increase the chance of choosing pt naturally. + if(nrOfInnerTripsToWithModesToReplace != tripsToReplace.size() && + nrOfOutsideTripsWithModesToReplace != tripsToReplace.size()){ //normally we have skipped plans with only outer trips above + //create and add a plan, where all the trips to replace are NOT split up with P+R logic but are just replaced by a pt trip plansToAdd.add(createPTOnlyPlan(plan, enforceMassConservation, mainModeIdentifier, fac)); } }