From 735413a7ac9f52930111286f9fea09ce3e828d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=B6rl?= Date: Mon, 27 May 2024 10:53:43 +0200 Subject: [PATCH] fix: prebooked drt with variable stop durations and group sizes --- .../prebooking/PrebookingStopActivity.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java index 268521d4ada..dc8a1ae9346 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/PrebookingStopActivity.java @@ -129,21 +129,21 @@ private boolean updatePickupRequests(double now) { } var enterIterator = enterTimes.entrySet().iterator(); + int availableCapacity = vehicle.getCapacity() - onboard; while (enterIterator.hasNext()) { - if (onboard >= vehicle.getCapacity()) { - // only let people enter if there is currently free capacity - break; - } - var entry = enterIterator.next(); if (entry.getValue() <= now) { - // let agent enter now - Verify.verify(passengerHandler.tryPickUpPassengers(this, driver, entry.getKey(), now)); - enteredRequests.add(entry.getKey()); - onboard += pickupRequests.get(entry.getKey()).getPassengerCount(); - enterIterator.remove(); + int requiredCapacity = pickupRequests.get(entry.getKey()).getPassengerCount(); + + if (requiredCapacity <= availableCapacity) { + // let agent enter now + Verify.verify(passengerHandler.tryPickUpPassengers(this, driver, entry.getKey(), now)); + enteredRequests.add(entry.getKey()); + onboard += requiredCapacity; + enterIterator.remove(); + } } }