diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtOperationsControlerCreator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtOperationsControlerCreator.java index 9a1772ca184..835cc77e9e2 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtOperationsControlerCreator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtOperationsControlerCreator.java @@ -1,5 +1,6 @@ package org.matsim.contrib.drt.extension.operations; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesModeModule; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesQSimModule; import org.matsim.contrib.drt.extension.operations.shifts.analysis.efficiency.DrtShiftEfficiencyModeModule; @@ -33,7 +34,7 @@ public static Controler createControler(Config config, boolean otfvis) { for (DrtConfigGroup drtCfg : multiModeDrtConfig.getModalElements()) { controler.addOverridingModule(new ShiftDrtModeModule(drtCfg)); controler.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg))); - controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithOperationsConfigGroup) drtCfg)); + controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithExtensionsConfigGroup) drtCfg)); controler.addOverridingQSimModule(new OperationFacilitiesQSimModule(drtCfg)); controler.addOverridingModule(new DrtShiftEfficiencyModeModule(drtCfg)); } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtWithOperationsConfigGroup.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtWithOperationsConfigGroup.java deleted file mode 100644 index d33e6c74c2e..00000000000 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/DrtWithOperationsConfigGroup.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 MOIA GmbH - All Rights Reserved - * - * You may use, distribute and modify this code under the terms - * of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - */ -package org.matsim.contrib.drt.extension.operations; - -import jakarta.validation.constraints.NotNull; -import org.matsim.contrib.drt.run.DrtConfigGroup; - -/** - * @author mdziakowski / MOIA - */ -public class DrtWithOperationsConfigGroup extends DrtConfigGroup { - - @NotNull - private DrtOperationsParams drtOperationsParams; - - public DrtWithOperationsConfigGroup() { - addDefinition(DrtOperationsParams.SET_NAME, DrtOperationsParams::new, - () -> drtOperationsParams, - params -> drtOperationsParams = (DrtOperationsParams)params); - } - - public DrtOperationsParams getDrtOperationsParams() { - return drtOperationsParams; - } -} diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/EDrtOperationsControlerCreator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/EDrtOperationsControlerCreator.java index c0b78a1a5bb..da76f73772d 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/EDrtOperationsControlerCreator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/EDrtOperationsControlerCreator.java @@ -1,5 +1,6 @@ package org.matsim.contrib.drt.extension.operations; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.edrt.run.EDrtControlerCreator; import org.matsim.contrib.drt.extension.operations.eshifts.charging.ShiftOperatingVehicleProvider; import org.matsim.contrib.drt.extension.operations.eshifts.fleet.EvShiftDvrpFleetQSimModule; @@ -33,7 +34,7 @@ public static Controler createControler(Config config, boolean otfvis) { controler.addOverridingQSimModule(new DrtModeQSimModule(drtCfg, new ShiftDrtModeOptimizerQSimModule(drtCfg))); controler.addOverridingQSimModule(new ShiftEDrtModeOptimizerQSimModule(drtCfg)); controler.addOverridingQSimModule(new EvShiftDvrpFleetQSimModule(drtCfg.getMode())); - controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithOperationsConfigGroup) drtCfg)); + controler.addOverridingModule(new OperationFacilitiesModeModule((DrtWithExtensionsConfigGroup) drtCfg)); controler.addOverridingQSimModule(new OperationFacilitiesQSimModule(drtCfg)); controler.addOverridingModule(new DrtShiftEfficiencyModeModule(drtCfg)); } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/run/ShiftEDrtModeOptimizerQSimModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/run/ShiftEDrtModeOptimizerQSimModule.java index afbf606fc1d..ab4bf41c938 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/run/ShiftEDrtModeOptimizerQSimModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/run/ShiftEDrtModeOptimizerQSimModule.java @@ -2,12 +2,12 @@ import com.google.inject.Singleton; import org.matsim.api.core.v01.network.Network; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.edrt.EDrtActionCreator; import org.matsim.contrib.drt.extension.edrt.optimizer.EDrtVehicleDataEntryFactory; import org.matsim.contrib.drt.extension.edrt.schedule.EDrtTaskFactoryImpl; import org.matsim.contrib.drt.extension.edrt.scheduler.EmptyVehicleChargingScheduler; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.eshifts.dispatcher.EDrtAssignShiftToVehicleLogic; import org.matsim.contrib.drt.extension.operations.eshifts.dispatcher.EDrtShiftDispatcherImpl; import org.matsim.contrib.drt.extension.operations.eshifts.dispatcher.EDrtShiftStartLogic; @@ -53,7 +53,7 @@ public class ShiftEDrtModeOptimizerQSimModule extends AbstractDvrpModeQSimModule public ShiftEDrtModeOptimizerQSimModule(DrtConfigGroup drtCfg) { super(drtCfg.getMode()); - this.drtOperationsParams = ((DrtWithOperationsConfigGroup) drtCfg).getDrtOperationsParams(); + this.drtOperationsParams = ((DrtWithExtensionsConfigGroup) drtCfg).getDrtOperationsParams().orElseThrow(); this.drtCfg = drtCfg; } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesModeModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesModeModule.java index 15276252c50..e178fc0a69d 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesModeModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/operationFacilities/OperationFacilitiesModeModule.java @@ -1,6 +1,6 @@ package org.matsim.contrib.drt.extension.operations.operationFacilities; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.shifts.io.OperationFacilitiesReader; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; @@ -8,9 +8,9 @@ public class OperationFacilitiesModeModule extends AbstractDvrpModeModule { private final OperationFacilitiesParams operationFacilitiesParams; - public OperationFacilitiesModeModule(DrtWithOperationsConfigGroup drtCfg) { + public OperationFacilitiesModeModule(DrtWithExtensionsConfigGroup drtCfg) { super(drtCfg.getMode()); - this.operationFacilitiesParams = drtCfg.getDrtOperationsParams().getOperationFacilitiesParams().orElseThrow(); + this.operationFacilitiesParams = drtCfg.getDrtOperationsParams().orElseThrow().getOperationFacilitiesParams().orElseThrow(); } @Override diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeModule.java index 91e324456d1..7df2d885723 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeModule.java @@ -6,8 +6,8 @@ import com.google.inject.Singleton; import com.google.inject.TypeLiteral; import org.matsim.api.core.v01.population.Population; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesSpecification; import org.matsim.contrib.drt.extension.operations.shifts.analysis.*; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; @@ -52,7 +52,7 @@ public class ShiftDrtModeModule extends AbstractDvrpModeModule { public ShiftDrtModeModule(DrtConfigGroup drtCfg) { super(drtCfg.getMode()); this.drtConfigGroup = drtCfg; - this.drtOperationsParams = ((DrtWithOperationsConfigGroup) drtCfg).getDrtOperationsParams(); + this.drtOperationsParams = ((DrtWithExtensionsConfigGroup) drtCfg).getDrtOperationsParams().orElseThrow(); } private static final Comparator taskTypeComparator = Comparator.comparing((Task.TaskType type) -> { diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeOptimizerQSimModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeOptimizerQSimModule.java index a10c6e409e3..a6398faf3b3 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeOptimizerQSimModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/shifts/run/ShiftDrtModeOptimizerQSimModule.java @@ -4,8 +4,8 @@ import com.google.inject.Singleton; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Network; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilities; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilityFinder; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; @@ -70,7 +70,7 @@ public class ShiftDrtModeOptimizerQSimModule extends AbstractDvrpModeQSimModule public ShiftDrtModeOptimizerQSimModule(DrtConfigGroup drtCfg) { super(drtCfg.getMode()); this.drtCfg = drtCfg; - this.drtOperationsParams = ((DrtWithOperationsConfigGroup) drtCfg).getDrtOperationsParams(); + this.drtOperationsParams = ((DrtWithExtensionsConfigGroup) drtCfg).getDrtOperationsParams().orElseThrow(); } @Override diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java index 3ae153f665a..2da1b30b225 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/fiss/RunFissDrtScenarioIT.java @@ -7,9 +7,9 @@ import org.matsim.api.core.v01.events.handler.LinkLeaveEventHandler; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsControlerCreator; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; @@ -42,7 +42,7 @@ public class RunFissDrtScenarioIT { @Test void test() { - MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); + MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new); String fleetFile = "holzkirchenFleet.xml"; String plansFile = "holzkirchenPlans_car_drt.xml.gz"; @@ -50,7 +50,7 @@ void test() { String opFacilitiesFile = "holzkirchenOperationFacilities.xml"; String shiftsFile = "holzkirchenShifts.xml"; - DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); + DrtWithExtensionsConfigGroup drtWithShiftsConfigGroup = (DrtWithExtensionsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java index 3b5d9830c29..a137d932fe5 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/eshifts/run/RunEShiftDrtScenarioIT.java @@ -4,8 +4,9 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; + import org.matsim.contrib.drt.extension.operations.EDrtOperationsControlerCreator; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; @@ -43,7 +44,7 @@ public class RunEShiftDrtScenarioIT { @Test void test() { - MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); + MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new); String fleetFile = "holzkirchenFleet.xml"; String plansFile = "holzkirchenPlans.xml.gz"; @@ -53,7 +54,7 @@ void test() { String chargersFile = "holzkirchenChargers.xml"; String evsFile = "holzkirchenElectricFleet.xml"; - DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); + DrtWithExtensionsConfigGroup drtWithShiftsConfigGroup = (DrtWithExtensionsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java index 6f08a46d3c7..b481b20898f 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunMultiHubShiftDrtScenarioIT.java @@ -4,8 +4,8 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsControlerCreator; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; @@ -34,7 +34,7 @@ public class RunMultiHubShiftDrtScenarioIT { @Test void test() { - MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); + MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new); String fleetFile = "holzkirchenMultiHubFleet.xml"; String plansFile = "holzkirchenPlans.xml.gz"; @@ -42,7 +42,7 @@ void test() { String opFacilitiesFile = "holzkirchenMultiHubOperationFacilities.xml"; String shiftsFile = "holzkirchenMultiHubShifts.xml"; - DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); + DrtWithExtensionsConfigGroup drtWithShiftsConfigGroup = (DrtWithExtensionsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); DrtConfigGroup drtConfigGroup = drtWithShiftsConfigGroup; drtConfigGroup.mode = TransportMode.drt; diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java index 1b866a314d2..acfc878a000 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunShiftDrtScenarioIT.java @@ -4,9 +4,9 @@ import org.matsim.api.core.v01.TransportMode; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.analysis.zonal.DrtZoneSystemParams; +import org.matsim.contrib.drt.extension.DrtWithExtensionsConfigGroup; import org.matsim.contrib.drt.extension.operations.DrtOperationsControlerCreator; import org.matsim.contrib.drt.extension.operations.DrtOperationsParams; -import org.matsim.contrib.drt.extension.operations.DrtWithOperationsConfigGroup; import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacilitiesParams; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; @@ -36,7 +36,7 @@ public class RunShiftDrtScenarioIT { @Test void test() { - MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithOperationsConfigGroup::new); + MultiModeDrtConfigGroup multiModeDrtConfigGroup = new MultiModeDrtConfigGroup(DrtWithExtensionsConfigGroup::new); String fleetFile = "holzkirchenFleet.xml"; String plansFile = "holzkirchenPlans.xml.gz"; @@ -44,7 +44,7 @@ void test() { String opFacilitiesFile = "holzkirchenOperationFacilities.xml"; String shiftsFile = "holzkirchenShifts.xml"; - DrtWithOperationsConfigGroup drtWithShiftsConfigGroup = (DrtWithOperationsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); + DrtWithExtensionsConfigGroup drtWithShiftsConfigGroup = (DrtWithExtensionsConfigGroup) multiModeDrtConfigGroup.createParameterSet("drt"); drtWithShiftsConfigGroup.mode = TransportMode.drt; DefaultDrtOptimizationConstraintsSet defaultConstraintsSet =