From 57b300ddc118dc6bfdc5c1af7f579e7b213b2382 Mon Sep 17 00:00:00 2001 From: nkuehnel Date: Mon, 2 Sep 2024 10:10:46 +0200 Subject: [PATCH 1/2] update prebooking rejection handling --- .../contrib/drt/prebooking/PrebookingManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java index 85614dfa225..7e8d739e526 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java @@ -9,10 +9,7 @@ import org.matsim.api.core.v01.events.handler.PersonStuckEventHandler; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Plan; +import org.matsim.api.core.v01.population.*; import org.matsim.contrib.drt.passenger.AcceptedDrtRequest; import org.matsim.contrib.drt.prebooking.unscheduler.RequestUnscheduler; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; @@ -398,10 +395,13 @@ private void processRejections(double now) { if(abortRejectedPrebookings) { for (Id passengerId : item.request.getPassengerIds()) { MobsimAgent agent = internalInterface.getMobsim().getAgents().get(passengerId); - ((Activity) WithinDayAgentUtils.getCurrentPlanElement(agent)).setEndTime(Double.POSITIVE_INFINITY); - ((Activity) WithinDayAgentUtils.getCurrentPlanElement(agent)).setMaximumDurationUndefined(); + PlanElement planElement = WithinDayAgentUtils.getCurrentPlanElement(agent); + if(planElement instanceof Activity activity) { + activity.setEndTime(Double.POSITIVE_INFINITY); + activity.setMaximumDurationUndefined(); + internalInterface.getMobsim().rescheduleActivityEnd(agent); + } ((HasModifiablePlan) agent).resetCaches(); - internalInterface.getMobsim().rescheduleActivityEnd(agent); eventsManager.processEvent(new PersonStuckEvent(now, agent.getId(), agent.getCurrentLinkId(), this.mode)); internalInterface.getMobsim().getAgentCounter().incLost(); From 958577c32811da409045157b998ba852f27400c5 Mon Sep 17 00:00:00 2001 From: nkuehnel Date: Mon, 2 Sep 2024 10:44:46 +0200 Subject: [PATCH 2/2] update prebooking rejection handling --- .../matsim/contrib/drt/prebooking/PrebookingManager.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java index 7e8d739e526..b610ececae7 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingManager.java @@ -395,13 +395,9 @@ private void processRejections(double now) { if(abortRejectedPrebookings) { for (Id passengerId : item.request.getPassengerIds()) { MobsimAgent agent = internalInterface.getMobsim().getAgents().get(passengerId); - PlanElement planElement = WithinDayAgentUtils.getCurrentPlanElement(agent); - if(planElement instanceof Activity activity) { - activity.setEndTime(Double.POSITIVE_INFINITY); - activity.setMaximumDurationUndefined(); - internalInterface.getMobsim().rescheduleActivityEnd(agent); - } ((HasModifiablePlan) agent).resetCaches(); + agent.setStateToAbort(mobsimTimer.getTimeOfDay()); + internalInterface.arrangeNextAgentState(agent); eventsManager.processEvent(new PersonStuckEvent(now, agent.getId(), agent.getCurrentLinkId(), this.mode)); internalInterface.getMobsim().getAgentCounter().incLost();