From 4a6f09550574e08b8aa842ba6e7262594455eb51 Mon Sep 17 00:00:00 2001 From: steffenaxer <26229392+steffenaxer@users.noreply.github.com> Date: Fri, 23 Aug 2024 16:16:42 +0200 Subject: [PATCH] Bypass Fleet object in schedule interface --- .../operations/shifts/dispatcher/DefaultShiftScheduler.java | 3 ++- .../shifts/dispatcher/DrtShiftDispatcherImpl.java | 6 +++--- .../operations/shifts/dispatcher/ShiftScheduler.java | 4 +++- .../shifts/run/RunOnTheFlyShiftDrtScenarioIT.java | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DefaultShiftScheduler.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DefaultShiftScheduler.java index f512ec3a6d1..e51d7e01ec3 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DefaultShiftScheduler.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/DefaultShiftScheduler.java @@ -3,6 +3,7 @@ import com.google.common.collect.ImmutableMap; import org.matsim.api.core.v01.Id; import org.matsim.contrib.drt.extension.operations.shifts.shift.*; +import org.matsim.contrib.dvrp.fleet.Fleet; import java.util.Collections; import java.util.List; @@ -32,7 +33,7 @@ public DefaultShiftScheduler(DrtShiftsSpecification shiftsSpecification) { this.shiftsSpecification = shiftsSpecification; } @Override - public List schedule(double time) { + public List schedule(double time, Fleet fleet) { return Collections.emptyList(); } 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 c2ed2b8acec..198401f4526 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 @@ -141,7 +141,7 @@ public void dispatch(double timeStep) { if (timeStep % (drtShiftParams.updateShiftEndInterval) == 0) { updateShiftEnds(timeStep); } - scheduleShifts(timeStep); + scheduleShifts(timeStep, this.fleet); assignShifts(timeStep); startShifts(timeStep); checkBreaks(); @@ -172,8 +172,8 @@ private void checkBreaks() { } - private void scheduleShifts(double timeStep) { - List scheduled = shiftScheduler.schedule(timeStep); + private void scheduleShifts(double timeStep, Fleet fleet) { + List scheduled = shiftScheduler.schedule(timeStep, fleet); unAssignedShifts.addAll(scheduled); } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/ShiftScheduler.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/ShiftScheduler.java index 2d7c6993e59..e5f74f8b75e 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/ShiftScheduler.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/dispatcher/ShiftScheduler.java @@ -6,6 +6,8 @@ import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftsSpecification; import jakarta.inject.Provider; +import org.matsim.contrib.dvrp.fleet.Fleet; + import java.util.List; /** @@ -13,7 +15,7 @@ */ public interface ShiftScheduler extends Provider { - List schedule(double time); + List schedule(double time, Fleet fleet); ImmutableMap, DrtShift> initialSchedule(); } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunOnTheFlyShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunOnTheFlyShiftDrtScenarioIT.java index d7852ef1ac5..07c9a0b793b 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunOnTheFlyShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunOnTheFlyShiftDrtScenarioIT.java @@ -21,6 +21,7 @@ import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; +import org.matsim.contrib.dvrp.fleet.Fleet; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.zone.skims.DvrpTravelTimeMatrixParams; @@ -182,7 +183,7 @@ public DrtShiftsSpecification get() { } @Override - public List schedule(double time) { + public List schedule(double time, Fleet fleet) { List shifts = new ArrayList<>(); if (time > 4 * 3600 && time < 15 * 3600 && time % 3600 == 0) { for (int i = 0; i < iteration + 1 ; i++) {