From a821e9f772f512b41ec02c7fe8fa75f9dfbc209c Mon Sep 17 00:00:00 2001 From: Tom-Erik Kuhlen Date: Thu, 28 Dec 2023 15:17:12 +0100 Subject: [PATCH 1/4] add maxShiftStartDelay and log message when a shift is deleted due to start time delay (shift start time + maxShiftStartDelay < timestep) --- .../extension/operations/shifts/config/ShiftsParams.java | 4 ++++ .../shifts/dispatcher/DrtShiftDispatcherImpl.java | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java index d51712bd996..b1556e9ee6b 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java @@ -30,6 +30,10 @@ public class ShiftsParams extends ReflectiveConfigGroupWithConfigurableParameter @Comment("changeover duration in [seconds]") public double changeoverDuration = 900; + @Parameter + @Comment("maximum delay of shifts start in [seconds]") + public double maxShiftStartDelay = 0; + @Parameter @Comment("Time of shift assignment (i.e. which vehicle carries out a specific shift) before start of shift in [seconds]") public double shiftScheduleLookAhead = 1800; diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java index 12545d7a675..9eb1ef56fcd 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java @@ -177,7 +177,13 @@ private void startShifts(double timeStep) { private void assignShifts(double timeStep) { // Remove elapsed shifts - unscheduledShifts.removeIf(shift -> shift.getStartTime() < timeStep); + unscheduledShifts.removeIf(shift -> { + if (shift.getStartTime() + drtShiftParams.maxShiftStartDelay < timeStep ) { + logger.warn("Shift with ID " + shift.getId() + " is being removed as start time is longer in the past than defined by maxShiftStartDelay."); + return true; + } + return false; + }); // Assign shifts Set assignableShifts = new LinkedHashSet<>(); From dff1441f823ad47c6f272166c24da75146519be4 Mon Sep 17 00:00:00 2001 From: Tom-Erik Kuhlen Date: Thu, 28 Dec 2023 16:02:09 +0100 Subject: [PATCH 2/4] change name of parameter "maxUnscheduledShiftDelay" --- .../drt/extension/operations/shifts/config/ShiftsParams.java | 5 ++--- .../operations/shifts/dispatcher/DrtShiftDispatcherImpl.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java index b1556e9ee6b..3d55811f0bc 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java @@ -13,7 +13,6 @@ import org.matsim.core.config.ConfigGroup; import java.net.URL; -import java.util.Map; /** * @author nkuehnel / MOIA @@ -31,8 +30,8 @@ public class ShiftsParams extends ReflectiveConfigGroupWithConfigurableParameter public double changeoverDuration = 900; @Parameter - @Comment("maximum delay of shifts start in [seconds]") - public double maxShiftStartDelay = 0; + @Comment("maximum delay of shift assignment after start time has passed in [seconds]") + public double maxUnscheduledShiftDelay = 0; @Parameter @Comment("Time of shift assignment (i.e. which vehicle carries out a specific shift) before start of shift in [seconds]") diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java index 9eb1ef56fcd..cc78776007b 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java @@ -178,7 +178,7 @@ private void startShifts(double timeStep) { private void assignShifts(double timeStep) { // Remove elapsed shifts unscheduledShifts.removeIf(shift -> { - if (shift.getStartTime() + drtShiftParams.maxShiftStartDelay < timeStep ) { + if (shift.getStartTime() + drtShiftParams.maxUnscheduledShiftDelay < timeStep ) { logger.warn("Shift with ID " + shift.getId() + " is being removed as start time is longer in the past than defined by maxShiftStartDelay."); return true; } From e925b4201aaef98a7ffaf568bb2c5d3cc81b7796 Mon Sep 17 00:00:00 2001 From: Tom-Erik Kuhlen Date: Thu, 28 Dec 2023 16:11:18 +0100 Subject: [PATCH 3/4] change comment of parameter "maxUnscheduledShiftDelay" --- .../drt/extension/operations/shifts/config/ShiftsParams.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java index 3d55811f0bc..2f7944d5b9d 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/config/ShiftsParams.java @@ -30,7 +30,7 @@ public class ShiftsParams extends ReflectiveConfigGroupWithConfigurableParameter public double changeoverDuration = 900; @Parameter - @Comment("maximum delay of shift assignment after start time has passed in [seconds]") + @Comment("maximum delay of shift assignment after start time has passed in [seconds]. If a shift can not be assigned to a vehicle until the planned start of the shift plus the defined max delay, the shift is discarded. Defaults to 0") public double maxUnscheduledShiftDelay = 0; @Parameter From 21966353f477fa1a0818e084f98d96640188341b Mon Sep 17 00:00:00 2001 From: Tom-Erik Kuhlen Date: Thu, 28 Dec 2023 16:17:19 +0100 Subject: [PATCH 4/4] change log warning message --- .../operations/shifts/dispatcher/DrtShiftDispatcherImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java index cc78776007b..4c070bc1ebf 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DrtShiftDispatcherImpl.java @@ -179,7 +179,7 @@ private void assignShifts(double timeStep) { // Remove elapsed shifts unscheduledShifts.removeIf(shift -> { if (shift.getStartTime() + drtShiftParams.maxUnscheduledShiftDelay < timeStep ) { - logger.warn("Shift with ID " + shift.getId() + " is being removed as start time is longer in the past than defined by maxShiftStartDelay."); + logger.warn("Shift with ID " + shift.getId() + " could not be assigned and is being removed as start time is longer in the past than defined by maxUnscheduledShiftDelay."); return true; } return false;