diff --git a/contribs/accessibility/pom.xml b/contribs/accessibility/pom.xml index c4ead8bf378..f08160490b9 100644 --- a/contribs/accessibility/pom.xml +++ b/contribs/accessibility/pom.xml @@ -37,12 +37,12 @@ org.matsim.contrib matrixbasedptrouter - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib roadpricing - 2025.0-SNAPSHOT + ${project.parent.version} net.sf.trove4j @@ -70,7 +70,7 @@ org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/analysis/pom.xml b/contribs/analysis/pom.xml index 74a32b64c03..eea01c79ffb 100644 --- a/contribs/analysis/pom.xml +++ b/contribs/analysis/pom.xml @@ -13,7 +13,7 @@ org.matsim.contrib roadpricing - 2025.0-SNAPSHOT + ${project.parent.version} org.osgeo diff --git a/contribs/application/pom.xml b/contribs/application/pom.xml index e8ec00d4800..b427dfbfcf9 100644 --- a/contribs/application/pom.xml +++ b/contribs/application/pom.xml @@ -40,37 +40,37 @@ org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib osm - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib sumo - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib emissions - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib noise - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib freight - 2025.0-SNAPSHOT + ${project.parent.version} @@ -87,7 +87,7 @@ com.github.matsim-org gtfs2matsim - 47b0802a29 + 19f1676fc6 @@ -151,7 +151,7 @@ org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} compile diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfs.java b/contribs/application/src/main/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfs.java index ddbe0e7868a..cef7709361e 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfs.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/pt/CreateTransitScheduleFromGtfs.java @@ -25,6 +25,7 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.pt.transitSchedule.api.*; import org.matsim.pt.utils.CreatePseudoNetwork; +import org.matsim.pt.utils.CreatePseudoNetworkWithLoopLinks; import org.matsim.pt.utils.TransitScheduleValidator; import org.matsim.vehicles.*; import picocli.CommandLine; @@ -32,7 +33,10 @@ import java.io.File; import java.nio.file.Path; import java.time.LocalDate; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; @@ -85,8 +89,8 @@ public class CreateTransitScheduleFromGtfs implements MATSimAppCommand { @CommandLine.Option(names = "--transform-schedule", description = "Fully qualified class name to a Consumer to be executed after the schedule was created", arity = "0..*", split = ",") private List> transformSchedule; - @CommandLine.Option(names = "--merge-stops", description = "Whether stops should be merged by coordinate") - private boolean mergeStops; + @CommandLine.Option(names = "--merge-stops", description = "Whether stops should be merged by coordinate", defaultValue = "doNotMerge") + private GtfsConverter.MergeGtfsStops mergeStops; @CommandLine.Option(names = "--prefix", description = "Prefixes to add to the gtfs ids. Required if multiple inputs are used and ids are not unique.", split = ",") private List prefixes = new ArrayList<>(); @@ -100,10 +104,29 @@ public class CreateTransitScheduleFromGtfs implements MATSimAppCommand { @CommandLine.Option(names = "--shp-crs", description = "Overwrite coordinate system of the shape file") private String shpCrs; + @CommandLine.Option(names = "--pseudo-network", description = "Define how the pseudo network should be created", defaultValue = "singleLinkBetweenStops") + private PseudoNetwork pseudoNetwork; + + public static void main(String[] args) { System.exit(new CommandLine(new CreateTransitScheduleFromGtfs()).execute(args)); } + private static void addHbefaMapping(VehicleType vehicleType, HbefaVehicleCategory category) { + EngineInformation carEngineInformation = vehicleType.getEngineInformation(); + VehicleUtils.setHbefaVehicleCategory(carEngineInformation, String.valueOf(category)); + VehicleUtils.setHbefaTechnology(carEngineInformation, "average"); + VehicleUtils.setHbefaSizeClass(carEngineInformation, "average"); + VehicleUtils.setHbefaEmissionsConcept(carEngineInformation, "average"); + vehicleType.setNetworkMode(TransportMode.pt); + } + + private static void increaseLinkFreespeedIfLower(Link link, double newFreespeed) { + if (link.getFreespeed() < newFreespeed) { + link.setFreespeed(newFreespeed); + } + } + @Override public Integer call() throws Exception { @@ -237,14 +260,19 @@ private Predicate createFilter(int i) throws Exception { /** * Creates the pt scenario and network. */ - private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network network, TransitSchedule schedule, String ptNetworkIdentifier) { + private Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network network, TransitSchedule schedule, String ptNetworkIdentifier) { ScenarioUtils.ScenarioBuilder builder = new ScenarioUtils.ScenarioBuilder(ConfigUtils.createConfig()); builder.setNetwork(network); builder.setTransitSchedule(schedule); Scenario scenario = builder.build(); // add pseudo network for pt - new CreatePseudoNetwork(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork(); + switch (pseudoNetwork) { + case singleLinkBetweenStops -> + new CreatePseudoNetwork(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork(); + case withLoopLinks -> + new CreatePseudoNetworkWithLoopLinks(scenario.getTransitSchedule(), scenario.getNetwork(), ptNetworkIdentifier, 0.1, 100000.0).createNetwork(); + } // create TransitVehicle types // see https://svn.vsp.tu-berlin.de/repos/public-svn/publications/vspwp/2014/14-24/ for veh capacities @@ -481,20 +509,15 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network return scenario; } - private static void addHbefaMapping(VehicleType vehicleType, HbefaVehicleCategory category) { - EngineInformation carEngineInformation = vehicleType.getEngineInformation(); - VehicleUtils.setHbefaVehicleCategory(carEngineInformation, String.valueOf(category)); - VehicleUtils.setHbefaTechnology(carEngineInformation, "average"); - VehicleUtils.setHbefaSizeClass(carEngineInformation, "average"); - VehicleUtils.setHbefaEmissionsConcept(carEngineInformation, "average"); - vehicleType.setNetworkMode(TransportMode.pt); - } - - private static void increaseLinkFreespeedIfLower(Link link, double newFreespeed) { - if (link.getFreespeed() < newFreespeed) { - link.setFreespeed(newFreespeed); - } + public enum PseudoNetwork { + /** + * Create links between all stops and possibly duplicate stops. + */ + singleLinkBetweenStops, + /** + * Create a pseudo network with loop links at each stop. + */ + withLoopLinks, } - } diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java index ac3c44cb5a6..d01a6226691 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/FreightDemandGeneration.java @@ -37,8 +37,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.CoordinateTransformation; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierModule; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierModule; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.freight.carriers.usecases.chessboard.CarrierScoringFunctionFactoryImpl; import picocli.CommandLine; diff --git a/contribs/av/pom.xml b/contribs/av/pom.xml index 1536e9e78ef..590c8f7e7a1 100644 --- a/contribs/av/pom.xml +++ b/contribs/av/pom.xml @@ -16,19 +16,19 @@ org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} compile org.matsim.contrib taxi - 2025.0-SNAPSHOT + ${project.parent.version} compile org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} compile diff --git a/contribs/bicycle/pom.xml b/contribs/bicycle/pom.xml index f3ffdc96601..9bd3a41df5e 100644 --- a/contribs/bicycle/pom.xml +++ b/contribs/bicycle/pom.xml @@ -23,7 +23,7 @@ org.matsim.contrib osm - 2025.0-SNAPSHOT + ${project.parent.version} compile diff --git a/contribs/cadytsIntegration/pom.xml b/contribs/cadytsIntegration/pom.xml index 2d4b716db7e..5fba4fc8e57 100644 --- a/contribs/cadytsIntegration/pom.xml +++ b/contribs/cadytsIntegration/pom.xml @@ -17,7 +17,7 @@ org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} 2012 diff --git a/contribs/carsharing/pom.xml b/contribs/carsharing/pom.xml index 2580047b892..54eb37ac992 100644 --- a/contribs/carsharing/pom.xml +++ b/contribs/carsharing/pom.xml @@ -12,7 +12,7 @@ org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/commercialTrafficApplications/pom.xml b/contribs/commercialTrafficApplications/pom.xml index 2d6f1061274..4804f34b6d9 100644 --- a/contribs/commercialTrafficApplications/pom.xml +++ b/contribs/commercialTrafficApplications/pom.xml @@ -14,13 +14,13 @@ org.matsim.contrib freight - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/TestScenarioGeneration.java b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/TestScenarioGeneration.java index 1d6b845a665..601038f2f73 100644 --- a/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/TestScenarioGeneration.java +++ b/contribs/commercialTrafficApplications/src/test/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/TestScenarioGeneration.java @@ -126,8 +126,6 @@ private static CarrierVehicle getLightVehicle(Id id, VehicleType type, Id org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib ev - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib informed-mode-choice - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib simwrapper - 2025.0-SNAPSHOT + ${project.parent.version} @@ -45,7 +45,7 @@ org.matsim.contrib vsp - 2025.0-SNAPSHOT + ${project.parent.version} test diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java index 00dabefc585..90773153294 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/EDrtModeOptimizerQSimModule.java @@ -59,6 +59,7 @@ import org.matsim.contrib.dvrp.schedule.ScheduleTimingUpdater; import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic; import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructure; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructureUtils; import org.matsim.core.api.experimental.events.EventsManager; @@ -116,7 +117,8 @@ protected void configureQSim() { public EmptyVehicleChargingScheduler get() { var taskFactory = getModalInstance(DrtTaskFactory.class); var chargingInfrastructure = getModalInstance(ChargingInfrastructure.class); - return new EmptyVehicleChargingScheduler(timer, taskFactory, chargingInfrastructure); + ChargingStrategy.Factory chargingStrategyFactory = getModalInstance(ChargingStrategy.Factory.class); + return new EmptyVehicleChargingScheduler(timer, taskFactory, chargingInfrastructure, chargingStrategyFactory); } }).asEagerSingleton(); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenario.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenario.java index 741c4047786..915c5efa220 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenario.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/run/RunEDrtScenario.java @@ -22,15 +22,17 @@ import java.net.URL; +import org.matsim.contrib.drt.extension.edrt.optimizer.EDrtVehicleDataEntryFactory.EDrtVehicleDataEntryFactoryProvider; import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; -import org.matsim.contrib.drt.extension.edrt.optimizer.EDrtVehicleDataEntryFactory.EDrtVehicleDataEntryFactoryProvider; +import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.contrib.ev.charging.ChargeUpToMaxSocStrategy; import org.matsim.contrib.ev.charging.ChargingLogic; import org.matsim.contrib.ev.charging.ChargingPower; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithQueueingAndAssignmentLogic; import org.matsim.contrib.ev.charging.FixedSpeedCharging; import org.matsim.contrib.ev.temperature.TemperatureService; @@ -40,6 +42,8 @@ import org.matsim.core.controler.Controler; import org.matsim.vis.otfvis.OTFVisConfigGroup; +import com.google.inject.Key; + /** * @author Michal Maciejewski (michalm) */ @@ -69,10 +73,13 @@ public void install() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - bind(ChargingLogic.Factory.class).toProvider(new ChargingWithQueueingAndAssignmentLogic.FactoryProvider( - charger -> new ChargeUpToMaxSocStrategy(charger, MAX_RELATIVE_SOC))); + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingAndAssignmentLogic.Factory.class); bind(ChargingPower.Factory.class).toInstance(ev -> new FixedSpeedCharging(ev, CHARGING_SPEED_FACTOR)); bind(TemperatureService.class).toInstance(linkId -> TEMPERATURE); + + for (DrtConfigGroup drtCfg : MultiModeDrtConfigGroup.get(config).getModalElements()) { + bind(Key.get(ChargingStrategy.Factory.class, DvrpModes.mode(drtCfg.mode))).toInstance(new ChargeUpToMaxSocStrategy.Factory(MAX_RELATIVE_SOC)); + } } }); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtChargingTask.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtChargingTask.java index e2dcfdba751..95b36f65889 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtChargingTask.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtChargingTask.java @@ -20,6 +20,7 @@ package org.matsim.contrib.drt.extension.edrt.schedule; import org.matsim.contrib.drt.schedule.DrtTaskType; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; import org.matsim.contrib.evrp.ChargingTaskImpl; @@ -27,7 +28,7 @@ public class EDrtChargingTask extends ChargingTaskImpl { public static final DrtTaskType TYPE = new DrtTaskType("CHARGING"); - public EDrtChargingTask(double beginTime, double endTime, Charger charger, ElectricVehicle ev, double totalEnergy) { - super(TYPE, beginTime, endTime, charger, ev, totalEnergy); + public EDrtChargingTask(double beginTime, double endTime, Charger charger, ElectricVehicle ev, double totalEnergy, ChargingStrategy chargingStrategy) { + super(TYPE, beginTime, endTime, charger, ev, totalEnergy, chargingStrategy); } } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtTaskFactoryImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtTaskFactoryImpl.java index 4ec83dc7a15..d99fdc6fbfe 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtTaskFactoryImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/schedule/EDrtTaskFactoryImpl.java @@ -26,6 +26,7 @@ import org.matsim.contrib.dvrp.schedule.DefaultStayTask; import org.matsim.contrib.evrp.EvDvrpVehicle; import org.matsim.contrib.evrp.VrpPathEnergyConsumptions; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; @@ -59,8 +60,8 @@ public DefaultStayTask createInitialTask(DvrpVehicle vehicle, double beginTime, } public EDrtChargingTask createChargingTask(DvrpVehicle vehicle, double beginTime, double endTime, Charger charger, - double totalEnergy) { + double totalEnergy, ChargingStrategy chargingStrategy) { return new EDrtChargingTask(beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), - totalEnergy); + totalEnergy, chargingStrategy); } } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/scheduler/EmptyVehicleChargingScheduler.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/scheduler/EmptyVehicleChargingScheduler.java index eea29745e80..2df2ed57028 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/scheduler/EmptyVehicleChargingScheduler.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/edrt/scheduler/EmptyVehicleChargingScheduler.java @@ -47,10 +47,12 @@ public class EmptyVehicleChargingScheduler { private final MobsimTimer timer; private final EDrtTaskFactoryImpl taskFactory; private final Map, List> linkToChargersMap; + private final ChargingStrategy.Factory chargingStrategyFactory; public EmptyVehicleChargingScheduler(MobsimTimer timer, DrtTaskFactory taskFactory, - ChargingInfrastructure chargingInfrastructure) { + ChargingInfrastructure chargingInfrastructure, ChargingStrategy.Factory chargingStrategyFactory) { this.timer = timer; + this.chargingStrategyFactory = chargingStrategyFactory; this.taskFactory = (EDrtTaskFactoryImpl)taskFactory; linkToChargersMap = chargingInfrastructure.getChargers() .values() @@ -68,15 +70,16 @@ public void chargeVehicle(DvrpVehicle vehicle) { // Empty charger or at least smallest queue charger Charger charger = freeCharger.orElseGet(() -> chargers.stream().min(Comparator.comparingInt(e -> e.getLogic().getQueuedVehicles().size())).orElseThrow()); ElectricVehicle ev = ((EvDvrpVehicle)vehicle).getElectricVehicle(); - if (!charger.getLogic().getChargingStrategy().isChargingCompleted(ev)) { - chargeVehicleImpl(vehicle, charger); + ChargingStrategy strategy = chargingStrategyFactory.createStrategy(charger.getSpecification(), ev); + if (!strategy.isChargingCompleted()) { + chargeVehicleImpl(vehicle, ev, charger, strategy); } } } - private void chargeVehicleImpl(DvrpVehicle vehicle, Charger charger) { + private void chargeVehicleImpl(DvrpVehicle vehicle, ElectricVehicle ev, Charger charger, ChargingStrategy strategy) { Schedule schedule = vehicle.getSchedule(); DrtStayTask stayTask = (DrtStayTask)schedule.getCurrentTask(); if (stayTask.getTaskIdx() != schedule.getTaskCount() - 1) { @@ -86,19 +89,17 @@ private void chargeVehicleImpl(DvrpVehicle vehicle, Charger charger) { // add CHARGING TASK double beginTime = stayTask.getEndTime(); - ChargingStrategy strategy = charger.getLogic().getChargingStrategy(); - ElectricVehicle ev = ((EvDvrpVehicle)vehicle).getElectricVehicle(); - double totalEnergy = -strategy.calcRemainingEnergyToCharge(ev); + double totalEnergy = -strategy.calcRemainingEnergyToCharge(); - double chargingDuration = Math.min(strategy.calcRemainingTimeToCharge(ev), + double chargingDuration = Math.min(strategy.calcRemainingTimeToCharge(), vehicle.getServiceEndTime() - beginTime); if (chargingDuration <= 0) { return;// no charging } double endTime = beginTime + chargingDuration; - schedule.addTask(taskFactory.createChargingTask(vehicle, beginTime, endTime, charger, totalEnergy)); - ((ChargingWithAssignmentLogic)charger.getLogic()).assignVehicle(ev); + schedule.addTask(taskFactory.createChargingTask(vehicle, beginTime, endTime, charger, totalEnergy, strategy)); + ((ChargingWithAssignmentLogic)charger.getLogic()).assignVehicle(ev, strategy); // append STAY schedule.addTask(taskFactory.createStayTask(vehicle, endTime, vehicle.getServiceEndTime(), charger.getLink())); diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/dispatcher/EDrtShiftDispatcherImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/dispatcher/EDrtShiftDispatcherImpl.java index ace6e8d66e0..b3469edbc2e 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/dispatcher/EDrtShiftDispatcherImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/dispatcher/EDrtShiftDispatcherImpl.java @@ -42,15 +42,18 @@ public class EDrtShiftDispatcherImpl implements DrtShiftDispatcher { private final Fleet fleet; + private final ChargingStrategy.Factory chargingStrategyFactory; + public EDrtShiftDispatcherImpl(EShiftTaskScheduler shiftTaskScheduler, ChargingInfrastructure chargingInfrastructure, ShiftsParams drtShiftParams, OperationFacilities operationFacilities, - DrtShiftDispatcher delegate, Fleet fleet) { + DrtShiftDispatcher delegate, Fleet fleet, ChargingStrategy.Factory chargingStrategyFactory) { this.shiftTaskScheduler = shiftTaskScheduler; this.chargingInfrastructure = chargingInfrastructure; this.drtShiftParams = drtShiftParams; this.operationFacilities = operationFacilities; this.delegate = delegate; this.fleet = fleet; + this.chargingStrategyFactory = chargingStrategyFactory; } @Override @@ -112,18 +115,18 @@ private void checkChargingAtHub(double timeStep) { if (selectedCharger.isPresent()) { Charger selectedChargerImpl = selectedCharger.get(); - ChargingStrategy chargingStrategy = selectedChargerImpl.getLogic().getChargingStrategy(); - if (!chargingStrategy.isChargingCompleted(electricVehicle)) { + ChargingStrategy chargingStrategy = chargingStrategyFactory.createStrategy(selectedChargerImpl.getSpecification(), electricVehicle); + if (!chargingStrategy.isChargingCompleted()) { final double waitTime = ChargingEstimations .estimateMaxWaitTimeForNextVehicle(selectedChargerImpl); final double chargingTime = chargingStrategy - .calcRemainingTimeToCharge(electricVehicle); + .calcRemainingTimeToCharge(); double energy = -chargingStrategy - .calcRemainingEnergyToCharge(electricVehicle); + .calcRemainingEnergyToCharge(); final double endTime = timeStep + waitTime + chargingTime; if (endTime < currentTask.getEndTime()) { shiftTaskScheduler.chargeAtHub((WaitForShiftTask) currentTask, eShiftVehicle, - electricVehicle, selectedChargerImpl, timeStep, endTime, energy); + electricVehicle, selectedChargerImpl, timeStep, endTime, energy, chargingStrategy); } } } 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 32bf96909bf..95b6feb85e3 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 @@ -34,6 +34,7 @@ import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.vrpagent.VrpAgentLogic; import org.matsim.contrib.dvrp.vrpagent.VrpLegFactory; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructure; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.mobsim.framework.MobsimTimer; @@ -72,7 +73,7 @@ protected void configureQSim() { drtShiftParams, new EDrtShiftStartLogic(new DefaultShiftStartLogic()), new EDrtAssignShiftToVehicleLogic(new DefaultAssignShiftToVehicleLogic(drtShiftParams), drtShiftParams), getter.getModal(ShiftScheduler.class)), - getter.getModal(Fleet.class))) + getter.getModal(Fleet.class), getter.getModal(ChargingStrategy.Factory.class))) ).asEagerSingleton(); bindModal(VehicleEntry.EntryFactory.class).toProvider(modalProvider(getter -> @@ -87,7 +88,8 @@ drtShiftParams, new EDrtShiftStartLogic(new DefaultShiftStartLogic()), getter -> new EShiftTaskScheduler(getter.getModal(Network.class), getter.getModal(TravelTime.class), getter.getModal(TravelDisutilityFactory.class).createTravelDisutility(getter.getModal(TravelTime.class)), getter.get(MobsimTimer.class), getter.getModal(ShiftDrtTaskFactory.class), drtShiftParams, getter.getModal(ChargingInfrastructure.class), - getter.getModal(OperationFacilities.class), getter.getModal(Fleet.class)) + getter.getModal(OperationFacilities.class), getter.getModal(Fleet.class), + getter.getModal(ChargingStrategy.Factory.class)) )).asEagerSingleton(); // See EDrtModeOptimizerQSimModule diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/schedule/ShiftEDrtTaskFactoryImpl.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/schedule/ShiftEDrtTaskFactoryImpl.java index b7c2657f1bf..c74713d9f73 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/schedule/ShiftEDrtTaskFactoryImpl.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/schedule/ShiftEDrtTaskFactoryImpl.java @@ -19,6 +19,7 @@ import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.path.VrpPathWithTravelData; import org.matsim.contrib.dvrp.schedule.DefaultStayTask; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.infrastructure.Charger; import org.matsim.contrib.evrp.ChargingTask; import org.matsim.contrib.evrp.ChargingTaskImpl; @@ -99,21 +100,21 @@ public WaitForShiftTask createWaitForShiftStayTask(DvrpVehicle vehicle, double b public WaitForShiftTask createChargingWaitForShiftStayTask(DvrpVehicle vehicle, double beginTime, double endTime, Link link, OperationFacility facility, - double totalEnergy, Charger charger) { - ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy); + double totalEnergy, Charger charger, ChargingStrategy strategy) { + ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy, strategy); return new EDrtWaitForShiftTask(beginTime, endTime, link, totalEnergy, facility, chargingTask); } public EDrtShiftBreakTaskImpl createChargingShiftBreakTask(DvrpVehicle vehicle, double beginTime, double endTime, Link link, - DrtShiftBreak shiftBreak, Charger charger, double totalEnergy, OperationFacility facility) { - ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy); + DrtShiftBreak shiftBreak, Charger charger, double totalEnergy, OperationFacility facility, ChargingStrategy strategy) { + ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy, strategy); return new EDrtShiftBreakTaskImpl(beginTime, endTime, link, shiftBreak, totalEnergy, chargingTask, facility); } public ShiftChangeOverTask createChargingShiftChangeoverTask(DvrpVehicle vehicle, double beginTime, double endTime, Link link, Charger charger, double totalEnergy, - DrtShift shift, OperationFacility facility) { - ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy); + DrtShift shift, OperationFacility facility, ChargingStrategy strategy) { + ChargingTask chargingTask = new ChargingTaskImpl(EDrtChargingTask.TYPE, beginTime, endTime, charger, ((EvDvrpVehicle)vehicle).getElectricVehicle(), totalEnergy, strategy); return new EDrtShiftChangeoverTaskImpl(beginTime, endTime, link, shift, totalEnergy, chargingTask, facility); } } diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/scheduler/EShiftTaskScheduler.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/scheduler/EShiftTaskScheduler.java index 9c5a7172282..2bc42cc1925 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/scheduler/EShiftTaskScheduler.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/operations/eshifts/scheduler/EShiftTaskScheduler.java @@ -1,5 +1,11 @@ package org.matsim.contrib.drt.extension.operations.eshifts.scheduler; +import static org.matsim.contrib.drt.schedule.DrtTaskBaseType.DRIVE; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; @@ -12,7 +18,11 @@ import org.matsim.contrib.drt.extension.operations.operationFacilities.OperationFacility; import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams; import org.matsim.contrib.drt.extension.operations.shifts.fleet.ShiftDvrpVehicle; -import org.matsim.contrib.drt.extension.operations.shifts.schedule.*; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftBreakTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftChangeOverTask; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftDrtTaskFactory; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.ShiftSchedules; +import org.matsim.contrib.drt.extension.operations.shifts.schedule.WaitForShiftTask; import org.matsim.contrib.drt.extension.operations.shifts.scheduler.ShiftTaskScheduler; import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShift; import org.matsim.contrib.drt.extension.operations.shifts.shift.DrtShiftBreak; @@ -23,11 +33,16 @@ import org.matsim.contrib.dvrp.fleet.Fleet; import org.matsim.contrib.dvrp.path.VrpPathWithTravelData; import org.matsim.contrib.dvrp.path.VrpPaths; -import org.matsim.contrib.dvrp.schedule.*; +import org.matsim.contrib.dvrp.schedule.DriveTask; +import org.matsim.contrib.dvrp.schedule.Schedule; +import org.matsim.contrib.dvrp.schedule.Schedules; +import org.matsim.contrib.dvrp.schedule.StayTask; +import org.matsim.contrib.dvrp.schedule.Task; import org.matsim.contrib.dvrp.tracker.OnlineDriveTaskTracker; import org.matsim.contrib.dvrp.util.LinkTimePair; import org.matsim.contrib.ev.charging.BatteryCharging; import org.matsim.contrib.ev.charging.ChargingEstimations; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; @@ -38,12 +53,7 @@ import org.matsim.core.router.util.LeastCostPathCalculator; import org.matsim.core.router.util.TravelDisutility; import org.matsim.core.router.util.TravelTime; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import static org.matsim.contrib.drt.schedule.DrtTaskBaseType.DRIVE; +import org.matsim.core.utils.collections.Tuple; /** * @author nkuehnel / MOIA @@ -61,10 +71,12 @@ public class EShiftTaskScheduler implements ShiftTaskScheduler { private final Network network; private final ChargingInfrastructure chargingInfrastructure; + private final ChargingStrategy.Factory chargingStrategyFactory; public EShiftTaskScheduler(Network network, TravelTime travelTime, TravelDisutility travelDisutility, MobsimTimer timer, ShiftDrtTaskFactory taskFactory, ShiftsParams shiftsParams, - ChargingInfrastructure chargingInfrastructure, OperationFacilities operationFacilities, Fleet fleet) { + ChargingInfrastructure chargingInfrastructure, OperationFacilities operationFacilities, Fleet fleet, + ChargingStrategy.Factory chargingStrategyFactory) { this.travelTime = travelTime; this.timer = timer; this.taskFactory = taskFactory; @@ -72,6 +84,7 @@ public EShiftTaskScheduler(Network network, TravelTime travelTime, TravelDisutil this.shiftsParams = shiftsParams; this.router = new SpeedyALTFactory().createPathCalculator(network, travelDisutility, travelTime); this.chargingInfrastructure = chargingInfrastructure; + this.chargingStrategyFactory = chargingStrategyFactory; } public void relocateForBreak(ShiftDvrpVehicle vehicle, OperationFacility breakFacility, DrtShift shift) { @@ -169,23 +182,25 @@ private void relocateForBreakImpl(ShiftDvrpVehicle vehicle, double startTime, do ShiftBreakTask dropoffStopTask; ElectricVehicle ev = ((EvDvrpVehicle) vehicle).getElectricVehicle(); - Optional charger = charge(breakFacility, ev); + Optional charger = charge(breakFacility, ev); if (charger.isPresent()) { - final Charger chargerImpl = charger.get(); + final ChargerWithStrategy chargerImpl = charger.get(); final double waitTime = ChargingEstimations - .estimateMaxWaitTimeForNextVehicle(chargerImpl); + .estimateMaxWaitTimeForNextVehicle(chargerImpl.charger); if (ev.getBattery().getCharge() / ev.getBattery().getCapacity() > shiftsParams.chargeDuringBreakThreshold || waitTime > 0) { dropoffStopTask = taskFactory.createShiftBreakTask(vehicle, startTime, endTime, link, shiftBreak, breakFacility); } else { - double energyCharge = ((BatteryCharging) ev.getChargingPower()).calcEnergyCharged(chargerImpl.getSpecification(), endTime - startTime); + ChargingStrategy strategy = chargingStrategyFactory.createStrategy(chargerImpl.charger.getSpecification(), ev); + + double energyCharge = ((BatteryCharging) ev.getChargingPower()).calcEnergyCharged(chargerImpl.charger.getSpecification(), endTime - startTime); double totalEnergy = -energyCharge; - ((ChargingWithAssignmentLogic) chargerImpl.getLogic()).assignVehicle(ev); + ((ChargingWithAssignmentLogic) chargerImpl.charger.getLogic()).assignVehicle(ev, strategy); dropoffStopTask = ((ShiftEDrtTaskFactoryImpl) taskFactory).createChargingShiftBreakTask(vehicle, - startTime, endTime, link, shiftBreak, chargerImpl, totalEnergy, breakFacility); + startTime, endTime, link, shiftBreak, chargerImpl.charger, totalEnergy, breakFacility, chargerImpl.strategy); } } else { dropoffStopTask = taskFactory.createShiftBreakTask(vehicle, startTime, @@ -202,7 +217,7 @@ private void relocateForBreakImpl(ShiftDvrpVehicle vehicle, double startTime, do shiftBreak.schedule(Math.min(latestDetourArrival, latestTimeConstraintArrival)); } - private Optional charge(OperationFacility breakFacility, ElectricVehicle electricVehicle) { + private Optional charge(OperationFacility breakFacility, ElectricVehicle electricVehicle) { if (chargingInfrastructure != null) { List> chargerIds = breakFacility.getChargers(); if (!chargerIds.isEmpty()) { @@ -218,16 +233,19 @@ private Optional charge(OperationFacility breakFacility, ElectricVehicl return Double.compare(waitTime, waitTime2); }); if (selectedCharger.isPresent()) { - if (selectedCharger.get().getLogic().getChargingStrategy().isChargingCompleted(electricVehicle)) { + ChargingStrategy strategy = chargingStrategyFactory.createStrategy(selectedCharger.get().getSpecification(), electricVehicle); + if (strategy.isChargingCompleted()) { return Optional.empty(); } + return Optional.of(new ChargerWithStrategy(selectedCharger.get(), strategy)); } - return selectedCharger; } } return Optional.empty(); } + private record ChargerWithStrategy(Charger charger, ChargingStrategy strategy) {} + public void relocateForShiftChange(DvrpVehicle vehicle, Link link, DrtShift shift, OperationFacility breakFacility) { final Schedule schedule = vehicle.getSchedule(); @@ -318,24 +336,24 @@ private void appendShiftChange(DvrpVehicle vehicle, DrtShift shift, OperationFac // append SHIFT_CHANGEOVER task ElectricVehicle ev = ((EvDvrpVehicle) vehicle).getElectricVehicle(); - Optional charger = charge(breakFacility, ev); + Optional charger = charge(breakFacility, ev); if (charger.isPresent()) { - Charger chargingImpl = charger.get(); - + ChargerWithStrategy chargingImpl = charger.get(); + final double waitTime = ChargingEstimations - .estimateMaxWaitTimeForNextVehicle(chargingImpl); + .estimateMaxWaitTimeForNextVehicle(chargingImpl.charger); if (ev.getBattery().getCharge() / ev.getBattery().getCapacity() < shiftsParams.chargeDuringBreakThreshold - || ((ChargingWithAssignmentLogic) chargingImpl.getLogic()).getAssignedVehicles().contains(ev) + || ((ChargingWithAssignmentLogic) chargingImpl.charger.getLogic()).isAssigned(ev) || waitTime > 0) { dropoffStopTask = taskFactory.createShiftChangeoverTask(vehicle, startTime, endTime, link, shift, breakFacility); } else { - double energyCharge = ((BatteryCharging) ev.getChargingPower()).calcEnergyCharged(chargingImpl.getSpecification(), endTime - startTime); + double energyCharge = ((BatteryCharging) ev.getChargingPower()).calcEnergyCharged(chargingImpl.charger.getSpecification(), endTime - startTime); double totalEnergy = -energyCharge; - ((ChargingWithAssignmentLogic) chargingImpl.getLogic()).assignVehicle(ev); + ((ChargingWithAssignmentLogic) chargingImpl.charger.getLogic()).assignVehicle(ev, chargingImpl.strategy); dropoffStopTask = ((ShiftEDrtTaskFactoryImpl) taskFactory).createChargingShiftChangeoverTask(vehicle, - startTime, endTime, link, chargingImpl, totalEnergy, shift, breakFacility); + startTime, endTime, link, chargingImpl.charger, totalEnergy, shift, breakFacility, chargingImpl.strategy); } } else { dropoffStopTask = taskFactory.createShiftChangeoverTask(vehicle, startTime, @@ -470,12 +488,12 @@ private void updateShiftChangeImpl(DvrpVehicle vehicle, VrpPathWithTravelData vr public void chargeAtHub(WaitForShiftTask currentTask, ShiftDvrpVehicle vehicle, ElectricVehicle electricVehicle, Charger charger, double beginTime, - double endTime, double energy) { + double endTime, double energy, ChargingStrategy strategy) { final double initialEndTime = currentTask.getEndTime(); currentTask.setEndTime(beginTime); - ((ChargingWithAssignmentLogic) charger.getLogic()).assignVehicle(electricVehicle); + ((ChargingWithAssignmentLogic) charger.getLogic()).assignVehicle(electricVehicle, strategy); final WaitForShiftTask chargingWaitForShiftTask = ((ShiftEDrtTaskFactoryImpl) taskFactory).createChargingWaitForShiftStayTask(vehicle, - beginTime, endTime, currentTask.getLink(), currentTask.getFacility(), energy, charger); + beginTime, endTime, currentTask.getLink(), currentTask.getFacility(), energy, charger, strategy); final WaitForShiftTask waitForShiftTask = taskFactory.createWaitForShiftStayTask(vehicle, endTime, initialEndTime, currentTask.getLink(), currentTask.getFacility()); 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 a137d932fe5..a65091c6102 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 @@ -17,6 +17,7 @@ import org.matsim.contrib.drt.run.DrtConfigGroup; import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; +import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.contrib.ev.charging.*; import org.matsim.contrib.ev.temperature.TemperatureService; @@ -32,6 +33,8 @@ import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.examples.ExamplesUtils; +import com.google.inject.Key; + import java.util.HashSet; import java.util.Set; @@ -177,8 +180,8 @@ void test() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - bind(ChargingLogic.Factory.class).toProvider(new ChargingWithQueueingAndAssignmentLogic.FactoryProvider( - charger -> new ChargeUpToMaxSocStrategy(charger, MAX_RELATIVE_SOC))); + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingAndAssignmentLogic.Factory.class); + bind(Key.get(ChargingStrategy.Factory.class, DvrpModes.mode(drtConfigGroup.mode))).toInstance(new ChargeUpToMaxSocStrategy.Factory(MAX_RELATIVE_SOC)); bind(ChargingPower.Factory.class).toInstance(FastThenSlowCharging::new); bind(TemperatureService.class).toInstance(linkId -> TEMPERATURE); } diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunPrebookingShiftDrtScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunPrebookingShiftDrtScenarioIT.java index 61e3a64a97a..e4286bed31c 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunPrebookingShiftDrtScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/operations/shifts/run/RunPrebookingShiftDrtScenarioIT.java @@ -280,8 +280,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(5000); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 1800.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5000.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 1800.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5000.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); @@ -295,8 +295,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(5000); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 900.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5005.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 900.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5005.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); @@ -310,8 +310,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(5000); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 5000.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 5000.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); @@ -325,8 +325,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(8000); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 11000.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 11000.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); @@ -340,8 +340,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(6000.); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 6000.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 6000.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); @@ -355,8 +355,8 @@ private void preparePopulation(Scenario scenario) { Plan plan = factory.createPlan(); Activity start = factory.createActivityFromLinkId("start", Id.createLinkId(1)); start.setEndTime(6500.); - start.getAttributes().putAttribute("prebooking:submissionTime" + "drt", 4000.); - start.getAttributes().putAttribute("prebooking:plannedDepartureTime" + "drt", 6500.); + AttributeBasedPrebookingLogic.setSubmissionTime("drt", start, 4000.0); + AttributeBasedPrebookingLogic.setPlannedDepartureTime("drt", start, 6500.0); plan.addActivity(start); plan.addLeg(factory.createLeg("drt")); plan.addActivity(factory.createActivityFromLinkId("end", Id.createLinkId(2))); diff --git a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/services/RunEDrtWithServicesScenarioIT.java b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/services/RunEDrtWithServicesScenarioIT.java index b16dca56807..da8b28c6c82 100644 --- a/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/services/RunEDrtWithServicesScenarioIT.java +++ b/contribs/drt-extensions/src/test/java/org/matsim/contrib/drt/extension/services/RunEDrtWithServicesScenarioIT.java @@ -14,6 +14,7 @@ import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup; import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; +import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.ev.charging.*; import org.matsim.contrib.ev.temperature.TemperatureService; import org.matsim.core.config.Config; @@ -22,6 +23,8 @@ import org.matsim.core.controler.Controler; import org.matsim.testcases.MatsimTestUtils; +import com.google.inject.Key; + public class RunEDrtWithServicesScenarioIT { public static final double MINIMUM_RELATIVE_SOC = 0.2; public static final double MAX_SOC = 1.0; @@ -77,7 +80,8 @@ public void install() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - bind(ChargingLogic.Factory.class).toProvider(new ChargingWithQueueingAndAssignmentLogic.FactoryProvider(charger -> new ChargeUpToMaxSocStrategy(charger, MAX_SOC))); + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingAndAssignmentLogic.Factory.class); + bind(Key.get(ChargingStrategy.Factory.class, DvrpModes.mode(drtConfigGroup.mode))).toInstance(new ChargeUpToMaxSocStrategy.Factory(MAX_SOC)); bind(ChargingPower.Factory.class).toInstance(ev -> new FixedSpeedCharging(ev, RELATIVE_SPEED)); bind(TemperatureService.class).toInstance(linkId -> TEMPERATURE); } diff --git a/contribs/drt/pom.xml b/contribs/drt/pom.xml index 7790f252b3c..99fd9d77ec7 100644 --- a/contribs/drt/pom.xml +++ b/contribs/drt/pom.xml @@ -15,19 +15,19 @@ org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtEventSequenceCollector.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtEventSequenceCollector.java index 90836e785cc..cee1304544d 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtEventSequenceCollector.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/analysis/DrtEventSequenceCollector.java @@ -159,7 +159,10 @@ public List getDrtFares() { } public boolean isCompleted() { - return submitted.getPersonIds().stream().allMatch(personId -> personEvents.get(personId).droppedOff != null); + return submitted.getPersonIds().stream().allMatch(personId -> { + var events = personEvents.get(personId); + return events != null && personEvents.get(personId).droppedOff != null; + }); } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java index 3ba0a7ce169..fd26a90256a 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/constraints/DefaultDrtOptimizationConstraintsSet.java @@ -23,34 +23,35 @@ public class DefaultDrtOptimizationConstraintsSet extends DrtOptimizationConstra @Parameter @Comment( - "Defines the maximum allowed absolute detour in seconds. Note that the detour is computed from the latest promised pickup time. " + - "To enable the max detour constraint, maxAllowedPickupDelay has to be specified. maxAbsoluteDetour should not be smaller than 0, " + "Defines the maximum allowed absolute detour in seconds. maxAbsoluteDetour should not be smaller than 0, " + "and should be higher than the offset maxDetourBeta. By default, this limit is disabled (i.e. set to Inf)") @PositiveOrZero public double maxAbsoluteDetour = Double.POSITIVE_INFINITY;// [s] @Parameter @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + "Defines the maximum allowed absolute detour based on the unsharedRideTime. A linear combination similar to travel " + "time constrain is used. This is the ratio part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourBeta).") @DecimalMin("1.0") public double maxDetourAlpha = Double.POSITIVE_INFINITY; @Parameter @Comment( - "Defines the maximum allowed absolute detour based on the unsharedRideTime. Note that the detour is computed from the latest promised " - + "pickup time. To enable the max detour constraint, maxAllowedPickupDelay has to be specified. A linear combination similar to travel " + "Defines the maximum allowed absolute detour based on the unsharedRideTime. A linear combination similar to travel " + "time constrain is used. This is the constant part. By default, this limit is disabled (i.e. set to Inf, together with maxDetourAlpha).") @PositiveOrZero public double maxDetourBeta = Double.POSITIVE_INFINITY;// [s] + @Parameter + @Comment( + "Defines the minimum allowed absolute detour in seconds. By default, this bound is disabled (i.e. set to 0.)") + @PositiveOrZero + public double minimumAllowedDetour = 0; + @Override protected void checkConsistency(Config config) { super.checkConsistency(config); - if ((maxDetourAlpha != Double.POSITIVE_INFINITY && maxDetourBeta != Double.POSITIVE_INFINITY) || maxAbsoluteDetour != Double.POSITIVE_INFINITY) { - Verify.verify(maxAllowedPickupDelay != Double.POSITIVE_INFINITY, "Detour constraints are activated, " + - "maxAllowedPickupDelay must be specified! A value between 0 and 240 seconds can be a good choice for maxAllowedPickupDelay."); - } + Verify.verify(maxAbsoluteDetour > minimumAllowedDetour, "The minimum allowed detour must" + + "be lower than the maximum allowed detour."); } } 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 a5dad2f114b..69aef1db822 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 @@ -399,22 +399,31 @@ private void processRejections(double now) { int index = WithinDayAgentUtils.getCurrentPlanElementIndex(agent); Plan plan = WithinDayAgentUtils.getModifiablePlan(agent); PlanElement planElement = plan.getPlanElements().get(index); - Activity activity; - if(planElement instanceof Activity currentActivity) { - activity = currentActivity; + + if (planElement instanceof Activity currentActivity) { + Activity activity = currentActivity; + activity.setEndTime(Double.POSITIVE_INFINITY); + activity.setMaximumDurationUndefined(); + + ((HasModifiablePlan) agent).resetCaches(); + internalInterface.getMobsim().rescheduleActivityEnd(agent); + eventsManager.processEvent(new PersonStuckEvent(now, agent.getId(), agent.getCurrentLinkId(), + this.mode)); + + internalInterface.getMobsim().getAgentCounter().incLost(); + internalInterface.getMobsim().getAgentCounter().decLiving(); } else { // If the current element is a leg, the agent is walking towards the pickup location // We make the agent stuck at the interaction activity - activity = (Activity) plan.getPlanElements().get(index+1); + while (index < plan.getPlanElements().size()) { + if (plan.getPlanElements().get(index) instanceof Activity activity) { + activity.setEndTime(Double.POSITIVE_INFINITY); + activity.setMaximumDurationUndefined(); + } + + index++; + } } - activity.setEndTime(Double.POSITIVE_INFINITY); - activity.setMaximumDurationUndefined(); - - ((HasModifiablePlan) agent).resetCaches(); - internalInterface.getMobsim().rescheduleActivityEnd(agent); - eventsManager.processEvent(new PersonStuckEvent(now, agent.getId(), agent.getCurrentLinkId(), - this.mode)); - internalInterface.getMobsim().getAgentCounter().incLost(); } } } diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/logic/AttributeBasedPrebookingLogic.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/logic/AttributeBasedPrebookingLogic.java index a48cbe50e46..7908ca1378c 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/logic/AttributeBasedPrebookingLogic.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/prebooking/logic/AttributeBasedPrebookingLogic.java @@ -2,6 +2,7 @@ import java.util.Optional; +import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.contrib.drt.prebooking.logic.helpers.PopulationIterator; @@ -35,23 +36,40 @@ * @author Sebastian Hörl (sebhoerl), IRT SystemX */ public class AttributeBasedPrebookingLogic implements PrebookingLogic, MobsimInitializedListener { - static private final String SUBMISSION_TIME_ATTRIBUTE_PREFIX = "prebooking:submissionTime"; - static private final String PLANNED_DEPARTURE_ATTRIBUTE_PREFIX = "prebooking:plannedDepartureTime"; + static private final String SUBMISSION_TIME_ATTRIBUTE_PREFIX = "prebooking:submissionTime:"; + static private final String PLANNED_DEPARTURE_ATTRIBUTE_PREFIX = "prebooking:plannedDepartureTime:"; - static public String getSubmissionAttribute(String mode) { + static public String getSubmissionTimeAttribute(String mode) { return SUBMISSION_TIME_ATTRIBUTE_PREFIX + mode; } - static public String getPlannedDepartureAttribute(String mode) { + static public String getPlannedDepartureTimeAttribute(String mode) { return PLANNED_DEPARTURE_ATTRIBUTE_PREFIX + mode; } static public Optional getSubmissionTime(String mode, Trip trip) { - return Optional.ofNullable((Double) trip.getTripAttributes().getAttribute(getSubmissionAttribute(mode))); + return Optional.ofNullable((Double) trip.getTripAttributes().getAttribute(getSubmissionTimeAttribute(mode))); } static public Optional getPlannedDepartureTime(String mode, Trip trip) { - return Optional.ofNullable((Double) trip.getTripAttributes().getAttribute(getPlannedDepartureAttribute(mode))); + return Optional + .ofNullable((Double) trip.getTripAttributes().getAttribute(getPlannedDepartureTimeAttribute(mode))); + } + + static public void setSubmissionTime(String mode, Trip trip, double submissionTime) { + trip.getTripAttributes().putAttribute(getSubmissionTimeAttribute(mode), submissionTime); + } + + static public void setPlannedDepartureTime(String mode, Trip trip, double plannedDepartureTime) { + trip.getTripAttributes().putAttribute(getPlannedDepartureTimeAttribute(mode), plannedDepartureTime); + } + + static public void setSubmissionTime(String mode, Activity originActivity, double submissionTime) { + originActivity.getAttributes().putAttribute(getSubmissionTimeAttribute(mode), submissionTime); + } + + static public void setPlannedDepartureTime(String mode, Activity originActivity, double plannedDepartureTime) { + originActivity.getAttributes().putAttribute(getPlannedDepartureTimeAttribute(mode), plannedDepartureTime); } private final PrebookingQueue prebookingQueue; diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java index f8e1f9b36eb..cfcaaa3e5c8 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/routing/DefaultDrtRouteConstraintsCalculator.java @@ -25,9 +25,12 @@ public DefaultDrtRouteConstraintsCalculator(DrtConfigGroup drtCfg, ConstraintSet /** * Calculates the maximum travel time defined as: drtCfg.getMaxTravelTimeAlpha() * unsharedRideTime + drtCfg.getMaxTravelTimeBeta() - * - * Calculates the maximum ride time defined as: drtCfg.maxDetourAlpha * - * unsharedRideTime + drtCfg.maxDetourBeta + * + * Calculates the maximum ride time defined as: + * unsharedRideTime + min( + * maxAbsoluteDetour, + * max(minimumAllowedDetour, unsharedRideTime * (1-drtCfg.maxDetourAlpha) + drtCfg.maxDetourBeta) + * ) * * @return DrtRouteConstraints constraints */ @@ -40,8 +43,8 @@ public DrtRouteConstraints calculateRouteConstraints(double departureTime, Link if (constraintsSet instanceof DefaultDrtOptimizationConstraintsSet defaultSet) { double maxTravelTime = defaultSet.maxTravelTimeAlpha * unsharedRideTime + defaultSet.maxTravelTimeBeta; - double maxRideTime = Math.min(unsharedRideTime + defaultSet.maxAbsoluteDetour, - defaultSet.maxDetourAlpha * unsharedRideTime + defaultSet.maxDetourBeta); + double maxDetour = Math.max(defaultSet.minimumAllowedDetour, unsharedRideTime * (defaultSet.maxDetourAlpha -1) + defaultSet.maxDetourBeta); + double maxRideTime = unsharedRideTime + Math.min(defaultSet.maxAbsoluteDetour, maxDetour); double maxWaitTime = constraintsSet.maxWaitTime; return new DrtRouteConstraints(maxTravelTime, maxRideTime, maxWaitTime); diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java index 4809a205c8a..22f9bef8d06 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTest.java @@ -4,6 +4,11 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import org.matsim.api.core.v01.Coord; +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.contrib.drt.passenger.DrtRequest; import org.matsim.contrib.drt.prebooking.PrebookingTestEnvironment.RequestInfo; import org.matsim.contrib.drt.prebooking.logic.AttributeBasedPrebookingLogic; @@ -13,6 +18,7 @@ import org.matsim.contrib.dvrp.fleet.DvrpVehicle; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.core.controler.Controler; +import org.matsim.core.population.PopulationUtils; import org.matsim.testcases.MatsimTestUtils; /** @@ -67,7 +73,8 @@ static PrebookingParams installPrebooking(Controler controller, boolean installL return installPrebooking(controller, installLogic, new PrebookingParams()); } - static PrebookingParams installPrebooking(Controler controller, boolean installLogic, PrebookingParams prebookingParams) { + static PrebookingParams installPrebooking(Controler controller, boolean installLogic, + PrebookingParams prebookingParams) { DrtConfigGroup drtConfig = DrtConfigGroup.getSingleModeDrtConfig(controller.getConfig()); drtConfig.addParameterSet(prebookingParams); @@ -647,12 +654,12 @@ void intraStopTiming_pickupTooEarly() { .addRequest("requestA1", 1, 1, 8, 8, 2000.0, 1.0) // forward .addRequest("requestA2", 1, 1, 8, 8, 2000.0, 2.0) // forward .addRequest("requestB1", 8, 8, 1, 1, 2356.0, 3.0) // backward - .configure(300.0, 2.0, 1800.0, 60.0) // + .configure(300.0, 2.0, 1800.0, 60.0) // .endTime(12.0 * 3600.0); Controler controller = environment.build(); installPrebooking(controller); - + controller.addOverridingModule(new AbstractDvrpModeModule("drt") { @Override public void install() { @@ -665,7 +672,7 @@ public double calcPickupDuration(DvrpVehicle vehicle, DrtRequest request) { return 30.0; // shorter than the dropoff duration (see below) } } - + @Override public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { return 60.0; @@ -673,7 +680,7 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { }); } }); - + controller.run(); { @@ -693,13 +700,14 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { { RequestInfo requestInfo = environment.getRequestInfo().get("requestB1"); assertEquals(3.0, requestInfo.submissionTime, 1e-3); - assertEquals(2356.0 + 60.0, requestInfo.pickupTime, 1e-3); // NOT 30s because we need to wait for the dropoffs + assertEquals(2356.0 + 60.0, requestInfo.pickupTime, 1e-3); // NOT 30s because we need to wait for the + // dropoffs assertEquals(2753.0 + 60.0, requestInfo.dropoffTime, 1e-3); } assertEquals(3, environment.getTaskInfo().get("vehicleA").stream().filter(t -> t.type.equals("STOP")).count()); } - + @Test void intraStopTiming_dropoffTooLate() { /*- @@ -715,12 +723,12 @@ void intraStopTiming_dropoffTooLate() { .addRequest("requestA", 1, 1, 8, 8, 2000.0, 1.0) // forward .addRequest("requestB1", 8, 8, 1, 1, 2356.0, 2.0) // backward .addRequest("requestB2", 8, 8, 1, 1, 2356.0, 3.0) // backward - .configure(300.0, 2.0, 1800.0, 60.0) // + .configure(300.0, 2.0, 1800.0, 60.0) // .endTime(12.0 * 3600.0); Controler controller = environment.build(); installPrebooking(controller); - + controller.addOverridingModule(new AbstractDvrpModeModule("drt") { @Override public void install() { @@ -729,7 +737,7 @@ public void install() { public double calcPickupDuration(DvrpVehicle vehicle, DrtRequest request) { return 60.0; } - + @Override public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { if (request.getPassengerIds().get(0).toString().equals("requestA")) { @@ -741,7 +749,7 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { }); } }); - + controller.run(); { @@ -755,9 +763,10 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { RequestInfo requestInfo = environment.getRequestInfo().get("requestB1"); assertEquals(2.0, requestInfo.submissionTime, 1e-3); assertEquals(2356.0 + 60.0, requestInfo.pickupTime, 1e-3); - assertEquals(2753.0 + 60.0 + 30.0, requestInfo.dropoffTime, 1e-3); // +30 because we wait for dropoff of A for B2 to enter + assertEquals(2753.0 + 60.0 + 30.0, requestInfo.dropoffTime, 1e-3); // +30 because we wait for dropoff of A + // for B2 to enter } - + { RequestInfo requestInfo = environment.getRequestInfo().get("requestB2"); assertEquals(3.0, requestInfo.submissionTime, 1e-3); @@ -767,4 +776,62 @@ public double calcDropoffDuration(DvrpVehicle vehicle, DrtRequest request) { assertEquals(3, environment.getTaskInfo().get("vehicleA").stream().filter(t -> t.type.equals("STOP")).count()); } + + @Test + void abortAfterRejection_onActivity() { + PrebookingTestEnvironment environment = new PrebookingTestEnvironment(utils) // + .addVehicle("vehicleA", 1, 1) // + .setVehicleCapacity(1) // + .addRequest("requestA", 1, 1, 8, 8, 2000.0, 1800.0) + .configure(10.0, 1.0, 0.0, 5.0) + .endTime(12.0 * 3600.0); + + Controler controller = environment.build(); + installPrebooking(controller); + + controller.run(); + + { + RequestInfo requestInfo = environment.getRequestInfo().get("requestA"); + assertEquals(1800.0, requestInfo.submissionTime); + assertEquals(Double.NaN, requestInfo.pickupTime, 1e-3); + assertEquals(1, requestInfo.submissionTimes.size()); + assertEquals(1, environment.getStuckInfo().size()); + } + } + + @Test + void abortAfterRejection_onLeg() { + PrebookingTestEnvironment environment = new PrebookingTestEnvironment(utils) // + .addVehicle("vehicleA", 1, 1) // + .setVehicleCapacity(1) // + .addRequest("requestA", 1, 1, 8, 8, 2000.0, 1800.0) + .configure(10.0, 1.0, 0.0, 5.0) + .endTime(12.0 * 3600.0); + + Controler controller = environment.build(); + installPrebooking(controller); + + // make sure the agent will be on a leg + for (Person person : controller.getScenario().getPopulation().getPersons().values()) { + Plan plan = person.getSelectedPlan(); + + Activity activity = PopulationUtils.createActivityFromCoord("generic", new Coord(-50000.0, -50000.0)); + activity.setEndTime(0.0); + Leg leg = PopulationUtils.createLeg("walk"); + + plan.getPlanElements().add(0, activity); + plan.getPlanElements().add(1, leg); + } + + controller.run(); + + { + RequestInfo requestInfo = environment.getRequestInfo().get("requestA"); + assertEquals(1800.0, requestInfo.submissionTime); + assertEquals(Double.NaN, requestInfo.pickupTime, 1e-3); + assertEquals(1, requestInfo.submissionTimes.size()); + assertEquals(1, environment.getStuckInfo().size()); + } + } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java index 60108070ab8..fcdb7ab7d7a 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/prebooking/PrebookingTestEnvironment.java @@ -1,14 +1,26 @@ package org.matsim.contrib.drt.prebooking; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + import org.apache.commons.lang3.tuple.Pair; import org.matsim.api.core.v01.Coord; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; +import org.matsim.api.core.v01.events.PersonStuckEvent; +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.network.NetworkFactory; import org.matsim.api.core.v01.network.Node; -import org.matsim.api.core.v01.population.*; +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.Population; +import org.matsim.api.core.v01.population.PopulationFactory; import org.matsim.contrib.common.zones.systems.grid.square.SquareGridZoneSystemParams; import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet; import org.matsim.contrib.drt.optimizer.insertion.DrtInsertionSearchParams; @@ -26,7 +38,12 @@ import org.matsim.contrib.dvrp.fleet.FleetSpecification; import org.matsim.contrib.dvrp.fleet.FleetSpecificationImpl; import org.matsim.contrib.dvrp.fleet.ImmutableDvrpVehicleSpecification; -import org.matsim.contrib.dvrp.passenger.*; +import org.matsim.contrib.dvrp.passenger.PassengerDroppedOffEvent; +import org.matsim.contrib.dvrp.passenger.PassengerDroppedOffEventHandler; +import org.matsim.contrib.dvrp.passenger.PassengerPickedUpEvent; +import org.matsim.contrib.dvrp.passenger.PassengerPickedUpEventHandler; +import org.matsim.contrib.dvrp.passenger.PassengerRequestRejectedEvent; +import org.matsim.contrib.dvrp.passenger.PassengerRequestRejectedEventHandler; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.run.DvrpModule; @@ -48,11 +65,6 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.testcases.MatsimTestUtils; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - public class PrebookingTestEnvironment { private final MatsimTestUtils utils; @@ -164,6 +176,7 @@ public Controler build() { configureRequestListener(controller); configureVehicleListener(controller); + configureStuckListener(controller); return controller; } @@ -227,9 +240,9 @@ private void buildConfig(Config config) { DrtConfigGroup modeConfig = new DrtConfigGroup(); drtConfig.addParameterSet(modeConfig); modeConfig.mode = "drt"; - DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = - (DefaultDrtOptimizationConstraintsSet) modeConfig.addOrGetDrtOptimizationConstraintsParams() - .addOrGetDefaultDrtOptimizationConstraintsSet(); + DefaultDrtOptimizationConstraintsSet defaultConstraintsSet = (DefaultDrtOptimizationConstraintsSet) modeConfig + .addOrGetDrtOptimizationConstraintsParams() + .addOrGetDefaultDrtOptimizationConstraintsSet(); defaultConstraintsSet.maxWaitTime = maximumWaitTime; defaultConstraintsSet.maxTravelTimeAlpha = detourRelative; defaultConstraintsSet.maxTravelTimeBeta = detourAbsolute; @@ -270,13 +283,13 @@ private void buildPopulation(Scenario scenario) { plan.addLeg(firstLeg); if (!Double.isNaN(request.submissionTime)) { - firstActivity.getAttributes().putAttribute(AttributeBasedPrebookingLogic.getSubmissionAttribute("drt"), + firstActivity.getAttributes().putAttribute(AttributeBasedPrebookingLogic.getSubmissionTimeAttribute("drt"), request.submissionTime); } if (!Double.isNaN(request.plannedDepartureTime)) { firstActivity.getAttributes().putAttribute( - AttributeBasedPrebookingLogic.getPlannedDepartureAttribute("drt"), + AttributeBasedPrebookingLogic.getPlannedDepartureTimeAttribute("drt"), request.plannedDepartureTime); } @@ -444,4 +457,26 @@ public void handleEvent(TaskEndedEvent event) { taskInfo.get(event.getDvrpVehicleId().toString()).getLast().endTime = event.getTime(); } } + + private final List stuckEvents = new LinkedList<>(); + + public List getStuckInfo() { + return stuckEvents; + } + + private void configureStuckListener(Controler controller) { + controller.addOverridingModule(new AbstractModule() { + @Override + public void install() { + addEventHandlerBinding().toInstance(new StuckListener()); + } + }); + } + + private class StuckListener implements PersonStuckEventHandler { + @Override + public void handleEvent(PersonStuckEvent event) { + stuckEvents.add(event); + } + } } diff --git a/contribs/dvrp/pom.xml b/contribs/dvrp/pom.xml index 716fab806f2..e6fc424004c 100644 --- a/contribs/dvrp/pom.xml +++ b/contribs/dvrp/pom.xml @@ -24,17 +24,17 @@ org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib ev - 2025.0-SNAPSHOT + ${project.parent.version} org.apache.commons diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingActivity.java b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingActivity.java index 05217bf940e..8c1cb0adee3 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingActivity.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingActivity.java @@ -21,6 +21,7 @@ package org.matsim.contrib.evrp; import org.matsim.contrib.dynagent.DynActivity; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic; import org.matsim.contrib.ev.fleet.ElectricVehicle; @@ -64,7 +65,7 @@ private void initialize(double now) { ChargingWithAssignmentLogic logic = chargingTask.getChargingLogic(); ElectricVehicle ev = chargingTask.getElectricVehicle(); logic.unassignVehicle(ev); - logic.addVehicle(ev, new DvrpChargingListener(this), now); + logic.addVehicle(ev, chargingTask.getChargingStrategy(), new DvrpChargingListener(this), now); state = State.added; } diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTask.java b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTask.java index 21ad8303ae5..7326e1bedd9 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTask.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTask.java @@ -20,6 +20,7 @@ package org.matsim.contrib.evrp; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic; import org.matsim.contrib.ev.fleet.ElectricVehicle; @@ -29,6 +30,8 @@ public interface ChargingTask extends ETask { ChargingWithAssignmentLogic getChargingLogic(); + ChargingStrategy getChargingStrategy(); + ElectricVehicle getElectricVehicle(); double getChargingStartedTime(); diff --git a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTaskImpl.java b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTaskImpl.java index 969fa50da00..8cbd525cbea 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTaskImpl.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/evrp/ChargingTaskImpl.java @@ -24,6 +24,7 @@ import com.google.common.base.Preconditions; import org.matsim.contrib.dvrp.schedule.DefaultStayTask; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; @@ -33,18 +34,20 @@ */ public class ChargingTaskImpl extends DefaultStayTask implements ChargingTask { private final ChargingWithAssignmentLogic chargingLogic; + private final ChargingStrategy chargingStrategy; private final ElectricVehicle ev; private Double chargingStartedTime; private final double totalEnergy; public ChargingTaskImpl(TaskType taskType, double beginTime, double endTime, Charger charger, ElectricVehicle ev, - double totalEnergy) { + double totalEnergy, ChargingStrategy chargingStrategy) { super(taskType, beginTime, endTime, charger.getLink()); Preconditions.checkArgument(totalEnergy < 0, "Total energy consumption is not negative: %s", totalEnergy); this.chargingLogic = (ChargingWithAssignmentLogic)charger.getLogic(); this.ev = ev; this.totalEnergy = totalEnergy; + this.chargingStrategy = chargingStrategy; } @Override @@ -57,6 +60,11 @@ public ChargingWithAssignmentLogic getChargingLogic() { return chargingLogic; } + @Override + public ChargingStrategy getChargingStrategy() { + return chargingStrategy; + } + @Override public ElectricVehicle getElectricVehicle() { return ev; @@ -76,6 +84,7 @@ public double getChargingStartedTime() { public String toString() { return MoreObjects.toStringHelper(this) .add("chargingLogic", chargingLogic) + .add("chargingStrategy", chargingStrategy) .add("ev", ev) .add("chargingStartedTime", chargingStartedTime) .add("totalEnergy", totalEnergy) diff --git a/contribs/emissions/pom.xml b/contribs/emissions/pom.xml index 16d87bc8cdb..98daccca22b 100644 --- a/contribs/emissions/pom.xml +++ b/contribs/emissions/pom.xml @@ -58,7 +58,7 @@ org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} com.fasterxml.jackson.core diff --git a/contribs/ev/pom.xml b/contribs/ev/pom.xml index e1c5144d706..120d63dfbe3 100644 --- a/contribs/ev/pom.xml +++ b/contribs/ev/pom.xml @@ -14,7 +14,7 @@ org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} org.apache.commons diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargeUpToMaxSocStrategy.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargeUpToMaxSocStrategy.java index 85760aabefc..3703a7b0794 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargeUpToMaxSocStrategy.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargeUpToMaxSocStrategy.java @@ -23,30 +23,65 @@ import org.matsim.contrib.ev.fleet.Battery; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.ChargerSpecification; +import org.matsim.vehicles.Vehicle; /** * @author Michal Maciejewski (michalm) + * @author Sebastian Hörl (sebhoerl), IRT SystemX */ public class ChargeUpToMaxSocStrategy implements ChargingStrategy { + static public final String MAXIMUM_SOC_VEHICLE_ATTRIBUTE = "maximumSoc"; + + private final ElectricVehicle ev; private final ChargerSpecification charger; private final double maxSoc; - public ChargeUpToMaxSocStrategy(ChargerSpecification charger, double maxSoc) { + public ChargeUpToMaxSocStrategy(ChargerSpecification charger, ElectricVehicle ev, double maxSoc) { if (maxSoc < 0 || maxSoc > 1) { throw new IllegalArgumentException(); } this.charger = charger; this.maxSoc = maxSoc; + this.ev = ev; } @Override - public double calcRemainingEnergyToCharge(ElectricVehicle ev) { + public double calcRemainingEnergyToCharge() { Battery battery = ev.getBattery(); return maxSoc * battery.getCapacity() - battery.getCharge(); } @Override - public double calcRemainingTimeToCharge(ElectricVehicle ev) { - return ((BatteryCharging)ev.getChargingPower()).calcChargingTime(charger, calcRemainingEnergyToCharge(ev)); + public double calcRemainingTimeToCharge() { + return ((BatteryCharging)ev.getChargingPower()).calcChargingTime(charger, calcRemainingEnergyToCharge()); + } + + @Override + public boolean isChargingCompleted() { + return calcRemainingEnergyToCharge() <= 0; + } + + static public class Factory implements ChargingStrategy.Factory { + private final double maxSoc; + + public Factory(double maxSoc) { + this.maxSoc = maxSoc; + } + + @Override + public ChargingStrategy createStrategy(ChargerSpecification charger, ElectricVehicle ev) { + double vehicleMaximumSoc = maxSoc; + + Vehicle vehicle = ev.getVehicleSpecification().getMatsimVehicle(); + if (vehicle != null) { + Double value = (Double) vehicle.getAttributes().getAttribute(MAXIMUM_SOC_VEHICLE_ATTRIBUTE); + + if (value != null) { + vehicleMaximumSoc = value; + } + } + + return new ChargeUpToMaxSocStrategy(charger, ev, vehicleMaximumSoc); + } } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingEstimations.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingEstimations.java index 5c0499f3bbf..502573d8bb2 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingEstimations.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingEstimations.java @@ -20,7 +20,7 @@ import java.util.stream.Stream; -import org.matsim.contrib.ev.fleet.ElectricVehicle; +import org.matsim.contrib.ev.charging.ChargingLogic.ChargingVehicle; import org.matsim.contrib.ev.infrastructure.Charger; /** @@ -38,20 +38,18 @@ public static double estimateMaxWaitTimeForNextVehicle(Charger charger) { } public static double estimateTotalTimeToCharge(ChargingLogic logic) { - return estimateTotalTimeToCharge(logic.getChargingStrategy(), - Stream.concat(logic.getPluggedVehicles().stream(), logic.getQueuedVehicles().stream())); + return estimateTotalTimeToCharge(Stream.concat(logic.getPluggedVehicles().stream(), logic.getQueuedVehicles().stream())); } public static double estimateTotalEnergyToCharge(ChargingLogic logic) { - return estimateTotalEnergyToCharge(logic.getChargingStrategy(), - Stream.concat(logic.getPluggedVehicles().stream(), logic.getQueuedVehicles().stream())); + return estimateTotalEnergyToCharge(Stream.concat(logic.getPluggedVehicles().stream(), logic.getQueuedVehicles().stream())); } - public static double estimateTotalTimeToCharge(ChargingStrategy strategy, Stream vehicles) { - return vehicles.mapToDouble(strategy::calcRemainingTimeToCharge).sum(); + public static double estimateTotalTimeToCharge(Stream vehicles) { + return vehicles.map(ChargingVehicle::strategy).mapToDouble(ChargingStrategy::calcRemainingTimeToCharge).sum(); } - public static double estimateTotalEnergyToCharge(ChargingStrategy strategy, Stream vehicles) { - return vehicles.mapToDouble(strategy::calcRemainingEnergyToCharge).sum(); + public static double estimateTotalEnergyToCharge(Stream vehicles) { + return vehicles.map(ChargingVehicle::strategy).mapToDouble(ChargingStrategy::calcRemainingEnergyToCharge).sum(); } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingLogic.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingLogic.java index 854947741e0..de274606326 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingLogic.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingLogic.java @@ -29,17 +29,17 @@ interface Factory { ChargingLogic create(ChargerSpecification charger); } - void addVehicle(ElectricVehicle ev, double now); + void addVehicle(ElectricVehicle ev, ChargingStrategy strategy, double now); - void addVehicle(ElectricVehicle ev, ChargingListener chargingListener, double now); + void addVehicle(ElectricVehicle ev, ChargingStrategy strategy, ChargingListener chargingListener, double now); void removeVehicle(ElectricVehicle ev, double now); void chargeVehicles(double chargePeriod, double now); - Collection getPluggedVehicles(); + Collection getPluggedVehicles(); - Collection getQueuedVehicles(); + Collection getQueuedVehicles(); - ChargingStrategy getChargingStrategy(); + record ChargingVehicle(ElectricVehicle ev, ChargingStrategy strategy) {} } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingModule.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingModule.java index 7b42877507d..430484e4943 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingModule.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingModule.java @@ -20,14 +20,13 @@ package org.matsim.contrib.ev.charging; -import com.google.inject.Singleton; import org.matsim.contrib.ev.EvModule; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.core.controler.AbstractModule; import org.matsim.core.mobsim.qsim.AbstractQSimModule; -import com.google.inject.Inject; -import com.google.inject.Provider; +import com.google.inject.Provides; +import com.google.inject.Singleton; /** * @author Michal Maciejewski (michalm) @@ -35,13 +34,11 @@ public class ChargingModule extends AbstractModule { @Override public void install() { - // The following returns a charging logic for a given charger specification. Needs to be a provider, since the eventsManager needs to be inserted. - bind(ChargingLogic.Factory.class).toProvider(new Provider<>() { - @Inject private EventsManager eventsManager; - @Override public ChargingLogic.Factory get() { - return charger -> new ChargingWithQueueingLogic(charger, new ChargeUpToMaxSocStrategy(charger, 1.), eventsManager); - } - }); + // By default, charging logic with queue is used + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingLogic.Factory.class); + + // By default, charging strategy that chargers to 100% is used + bind(ChargingStrategy.Factory.class).toInstance(new ChargeUpToMaxSocStrategy.Factory(1.0)); // The following returns the charging power/speed for a vehicle: bind(ChargingPower.Factory.class).toInstance(ev -> new FixedSpeedCharging(ev, 1)); @@ -58,4 +55,14 @@ public void install() { // this.addMobsimListenerBinding().to( ChargingHandler.class ).in( Singleton.class ); // does not work since ChargingInfrastructure is not available. } + + @Provides @Singleton + ChargingWithQueueingLogic.Factory provideChargingWithQueueingLogicFactory(EventsManager eventsManager) { + return new ChargingWithQueueingLogic.Factory(eventsManager); + } + + @Provides @Singleton + ChargingWithQueueingAndAssignmentLogic.Factory provideChargingWithQueueingAndAssignmentLogicFactory(EventsManager eventsManager) { + return new ChargingWithQueueingAndAssignmentLogic.Factory(eventsManager); + } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingStrategy.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingStrategy.java index 87b76bf1303..bb5717b3cc2 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingStrategy.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingStrategy.java @@ -19,17 +19,21 @@ package org.matsim.contrib.ev.charging; import org.matsim.contrib.ev.fleet.ElectricVehicle; +import org.matsim.contrib.ev.infrastructure.ChargerSpecification; /** * @author michalm + * @author Sebastian Hörl (sebhoerl), IRT SystemX */ public interface ChargingStrategy { - default boolean isChargingCompleted(ElectricVehicle ev) { - return calcRemainingEnergyToCharge(ev) <= 0; - } + boolean isChargingCompleted(); - double calcRemainingEnergyToCharge(ElectricVehicle ev); + double calcRemainingEnergyToCharge(); //XXX should include potentially longer charging if AUX remains turned on - double calcRemainingTimeToCharge(ElectricVehicle ev); + double calcRemainingTimeToCharge(); + + static public interface Factory { + ChargingStrategy createStrategy(ChargerSpecification charger, ElectricVehicle ev); + } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithAssignmentLogic.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithAssignmentLogic.java index ceaabad797e..cd7333d9411 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithAssignmentLogic.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithAssignmentLogic.java @@ -5,9 +5,11 @@ import java.util.Collection; public interface ChargingWithAssignmentLogic extends ChargingLogic { - void assignVehicle(ElectricVehicle ev); + void assignVehicle(ElectricVehicle ev, ChargingStrategy strategy); void unassignVehicle(ElectricVehicle ev); - Collection getAssignedVehicles(); + Collection getAssignedVehicles(); + + boolean isAssigned(ElectricVehicle ev); } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingAndAssignmentLogic.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingAndAssignmentLogic.java index 5fb5cc0ae6d..a21fde69f40 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingAndAssignmentLogic.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingAndAssignmentLogic.java @@ -23,7 +23,6 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import java.util.function.Function; import org.matsim.api.core.v01.Id; import org.matsim.contrib.ev.fleet.ElectricVehicle; @@ -31,21 +30,18 @@ import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.vehicles.Vehicle; -import com.google.inject.Inject; -import com.google.inject.Provider; - public class ChargingWithQueueingAndAssignmentLogic extends ChargingWithQueueingLogic implements ChargingWithAssignmentLogic { - private final Map, ElectricVehicle> assignedVehicles = new LinkedHashMap<>(); + private final Map, ChargingVehicle> assignedVehicles = new LinkedHashMap<>(); - public ChargingWithQueueingAndAssignmentLogic(ChargerSpecification charger, ChargingStrategy chargingStrategy, - EventsManager eventsManager) { - super(charger, chargingStrategy, eventsManager); + public ChargingWithQueueingAndAssignmentLogic(ChargerSpecification charger, EventsManager eventsManager) { + super(charger, eventsManager); } @Override - public void assignVehicle(ElectricVehicle ev) { - if (assignedVehicles.put(ev.getId(), ev) != null) { + public void assignVehicle(ElectricVehicle ev, ChargingStrategy strategy) { + ChargingVehicle cv = new ChargingVehicle(ev, strategy); + if (assignedVehicles.put(ev.getId(), cv) != null) { throw new IllegalArgumentException("Vehicle is already assigned: " + ev.getId()); } } @@ -57,28 +53,29 @@ public void unassignVehicle(ElectricVehicle ev) { } } - private final Collection unmodifiableAssignedVehicles = Collections.unmodifiableCollection( + @Override + public boolean isAssigned(ElectricVehicle ev) { + return assignedVehicles.containsKey(ev.getId()); + } + + private final Collection unmodifiableAssignedVehicles = Collections.unmodifiableCollection( assignedVehicles.values()); @Override - public Collection getAssignedVehicles() { + public Collection getAssignedVehicles() { return unmodifiableAssignedVehicles; } - public static class FactoryProvider implements Provider { - @Inject - private EventsManager eventsManager; - - private final Function chargingStrategyCreator; + static public class Factory implements ChargingLogic.Factory { + private final EventsManager eventsManager; - public FactoryProvider(Function chargingStrategyCreator) { - this.chargingStrategyCreator = chargingStrategyCreator; + public Factory(EventsManager eventsManager) { + this.eventsManager = eventsManager; } @Override - public ChargingLogic.Factory get() { - return charger -> new ChargingWithQueueingAndAssignmentLogic(charger, - chargingStrategyCreator.apply(charger), eventsManager); + public ChargingLogic create(ChargerSpecification charger) { + return new ChargingWithQueueingAndAssignmentLogic(charger, eventsManager); } } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingLogic.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingLogic.java index 8cf57733532..515a586a4c2 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingLogic.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingWithQueueingLogic.java @@ -19,49 +19,55 @@ package org.matsim.contrib.ev.charging; -import com.google.common.base.Preconditions; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.Objects; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; + import org.matsim.api.core.v01.Id; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.ChargerSpecification; import org.matsim.core.api.experimental.events.EventsManager; import org.matsim.vehicles.Vehicle; -import java.util.*; -import java.util.concurrent.LinkedBlockingQueue; +import com.google.common.base.Preconditions; public class ChargingWithQueueingLogic implements ChargingLogic { protected final ChargerSpecification charger; - private final ChargingStrategy chargingStrategy; private final EventsManager eventsManager; - private final Map, ElectricVehicle> pluggedVehicles = new LinkedHashMap<>(); - private final Queue queuedVehicles = new LinkedList<>(); - private final Queue arrivingVehicles = new LinkedBlockingQueue<>(); + private final Map, ChargingVehicle> pluggedVehicles = new LinkedHashMap<>(); + private final Queue queuedVehicles = new LinkedList<>(); + private final Queue arrivingVehicles = new LinkedBlockingQueue<>(); private final Map, ChargingListener> listeners = new LinkedHashMap<>(); - public ChargingWithQueueingLogic(ChargerSpecification charger, ChargingStrategy chargingStrategy, EventsManager eventsManager) { - this.chargingStrategy = Objects.requireNonNull(chargingStrategy); + public ChargingWithQueueingLogic(ChargerSpecification charger, EventsManager eventsManager) { this.charger = Objects.requireNonNull(charger); this.eventsManager = Objects.requireNonNull(eventsManager); } @Override public void chargeVehicles(double chargePeriod, double now) { - Iterator evIter = pluggedVehicles.values().iterator(); - while (evIter.hasNext()) { - ElectricVehicle ev = evIter.next(); + Iterator cvIter = pluggedVehicles.values().iterator(); + while (cvIter.hasNext()) { + ChargingVehicle cv = cvIter.next(); // with fast charging, we charge around 4% of SOC per minute, // so when updating SOC every 10 seconds, SOC increases by less then 1% - double oldCharge = ev.getBattery().getCharge(); - double energy = ev.getChargingPower().calcChargingPower(charger) * chargePeriod; - double newCharge = Math.min(oldCharge + energy, ev.getBattery().getCapacity()); - ev.getBattery().setCharge(newCharge); - eventsManager.processEvent(new EnergyChargedEvent(now, charger.getId(), ev.getId(), newCharge - oldCharge, newCharge)); - - if (chargingStrategy.isChargingCompleted(ev)) { - evIter.remove(); - eventsManager.processEvent(new ChargingEndEvent(now, charger.getId(), ev.getId(), ev.getBattery().getCharge())); - listeners.remove(ev.getId()).notifyChargingEnded(ev, now); + double oldCharge = cv.ev().getBattery().getCharge(); + double energy = cv.ev().getChargingPower().calcChargingPower(charger) * chargePeriod; + double newCharge = Math.min(oldCharge + energy, cv.ev().getBattery().getCapacity()); + cv.ev().getBattery().setCharge(newCharge); + eventsManager.processEvent(new EnergyChargedEvent(now, charger.getId(), cv.ev().getId(), newCharge - oldCharge, newCharge)); + + if (cv.strategy().isChargingCompleted()) { + cvIter.remove(); + eventsManager.processEvent(new ChargingEndEvent(now, charger.getId(), cv.ev().getId(), cv.ev().getBattery().getCharge())); + listeners.remove(cv.ev().getId()).notifyChargingEnded(cv.ev(), now); } } @@ -72,25 +78,25 @@ public void chargeVehicles(double chargePeriod, double now) { var arrivingVehiclesIter = arrivingVehicles.iterator(); while (arrivingVehiclesIter.hasNext()) { - var ev = arrivingVehiclesIter.next(); + var cv = arrivingVehiclesIter.next(); if (pluggedVehicles.size() < charger.getPlugCount()) { - plugVehicle(ev, now); + plugVehicle(cv, now); } else { - queueVehicle(ev, now); + queueVehicle(cv, now); } arrivingVehiclesIter.remove(); } } @Override - public void addVehicle(ElectricVehicle ev, double now) { - addVehicle(ev, new ChargingListener() { + public void addVehicle(ElectricVehicle ev, ChargingStrategy strategy, double now) { + addVehicle(ev, strategy, new ChargingListener() { }, now); } @Override - public void addVehicle(ElectricVehicle ev, ChargingListener chargingListener, double now) { - arrivingVehicles.add(ev); + public void addVehicle(ElectricVehicle ev, ChargingStrategy strategy, ChargingListener chargingListener, double now) { + arrivingVehicles.add(new ChargingVehicle(ev, strategy)); listeners.put(ev.getId(), chargingListener); } @@ -111,36 +117,44 @@ public void removeVehicle(ElectricVehicle ev, double now) { } } - private void queueVehicle(ElectricVehicle ev, double now) { - queuedVehicles.add(ev); - eventsManager.processEvent(new QueuedAtChargerEvent(now, charger.getId(), ev.getId())); - listeners.get(ev.getId()).notifyVehicleQueued(ev, now); + private void queueVehicle(ChargingVehicle cv, double now) { + queuedVehicles.add(cv); + eventsManager.processEvent(new QueuedAtChargerEvent(now, charger.getId(), cv.ev().getId())); + listeners.get(cv.ev().getId()).notifyVehicleQueued(cv.ev(), now); } - private void plugVehicle(ElectricVehicle ev, double now) { - if (pluggedVehicles.put(ev.getId(), ev) != null) { + private void plugVehicle(ChargingVehicle cv, double now) { + if (pluggedVehicles.put(cv.ev().getId(), cv) != null) { throw new IllegalArgumentException(); } - eventsManager.processEvent(new ChargingStartEvent(now, charger.getId(), ev.getId(), ev.getBattery().getCharge())); - listeners.get(ev.getId()).notifyChargingStarted(ev, now); + eventsManager.processEvent(new ChargingStartEvent(now, charger.getId(), cv.ev().getId(), cv.ev().getBattery().getCharge())); + listeners.get(cv.ev().getId()).notifyChargingStarted(cv.ev(), now); } - private final Collection unmodifiablePluggedVehicles = Collections.unmodifiableCollection(pluggedVehicles.values()); + private final Collection unmodifiablePluggedVehicles = Collections.unmodifiableCollection(pluggedVehicles.values()); @Override - public Collection getPluggedVehicles() { + public Collection getPluggedVehicles() { return unmodifiablePluggedVehicles; } - private final Collection unmodifiableQueuedVehicles = Collections.unmodifiableCollection(queuedVehicles); + private final Collection unmodifiableQueuedVehicles = Collections.unmodifiableCollection(queuedVehicles); @Override - public Collection getQueuedVehicles() { + public Collection getQueuedVehicles() { return unmodifiableQueuedVehicles; } - @Override - public ChargingStrategy getChargingStrategy() { - return chargingStrategy; + static public class Factory implements ChargingLogic.Factory { + private final EventsManager eventsManager; + + public Factory(EventsManager eventsManager) { + this.eventsManager = eventsManager; + } + + @Override + public ChargingLogic create(ChargerSpecification charger) { + return new ChargingWithQueueingLogic(charger, eventsManager); + } } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java index d206a50c875..15431cea1fe 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/VehicleChargingHandler.java @@ -86,11 +86,14 @@ public class VehicleChargingHandler private final ImmutableListMultimap, Charger> chargersAtLinks; private final EvConfigGroup evCfg; + private final ChargingStrategy.Factory strategyFactory; + @Inject - VehicleChargingHandler(ChargingInfrastructure chargingInfrastructure, ElectricFleet electricFleet, EvConfigGroup evConfigGroup) { + VehicleChargingHandler(ChargingInfrastructure chargingInfrastructure, ElectricFleet electricFleet, EvConfigGroup evConfigGroup, ChargingStrategy.Factory strategyFactory) { this.chargingInfrastructure = chargingInfrastructure; this.electricFleet = electricFleet; this.evCfg = evConfigGroup; + this.strategyFactory = strategyFactory; chargersAtLinks = ChargingInfrastructureUtils.getChargersAtLinks(chargingInfrastructure ); } @@ -112,7 +115,7 @@ public void handleEvent(ActivityStartEvent event) { .filter(ch -> ev.getChargerTypes().contains(ch.getChargerType())) .findAny() .get(); - c.getLogic().addVehicle(ev, event.getTime()); + c.getLogic().addVehicle(ev, strategyFactory.createStrategy(c.getSpecification(), ev), event.getTime()); vehiclesAtChargers.put(evId, c.getId()); } } diff --git a/contribs/freight/pom.xml b/contribs/freight/pom.xml index d6dd0d20b65..c1df7ab953a 100644 --- a/contribs/freight/pom.xml +++ b/contribs/freight/pom.xml @@ -55,13 +55,13 @@ org.matsim.contrib roadpricing - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} @@ -85,7 +85,7 @@ org.matsim matsim-examples - 2025.0-SNAPSHOT + ${project.parent.version} jede Ressource hat einen eigenen Scheduler: 1.) Simple: Nimm die + * für jede Ressource. → jede Ressource hat einen eigenen Scheduler: 1.) Simple: Nimm die * mitgegebene Reihenfolge. 2.) */ /*package-private*/ final class ExampleSchedulingOfTransportChainHubsVsDirect { @@ -133,16 +131,16 @@ public static void main(String[] args) { log.info("schedule the LSP with the shipments and according to the scheduler of the Resource"); lsp.scheduleLogisticChains(); - log.info("Set up simulation controler and LSPModule"); + log.info("Set up simulation controller and LSPModule"); LSPUtils.addLSPs(scenario, new LSPs(Collections.singletonList(lsp))); // @KMT: LSPModule ist vom Design her nur im Zusammenhang mit dem Controler sinnvoll. Damit kann // man dann auch vollständig auf // Injection setzen. - Controler controler = new Controler(scenario); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -164,7 +162,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; @@ -174,7 +172,7 @@ public void install() { log.info("Run MATSim"); - controler.run(); + controller.run(); // print the schedules for the assigned LSPShipments log.info("print the schedules for the assigned LSPShipments"); @@ -430,7 +428,7 @@ private static LSP createInitialLSP(Scenario scenario, SolutionType solutionType log.error( "This is totally untested. I can neither say if it will work nor if it will do anything useful - kmt feb22"); - // TODO: Habe das vorziehen vor das switch statement rückgängig gemacht, weil es sideeffekte + // TODO: Habe das vorziehen vor das switch statement rückgängig gemacht, weil es sideeffects // hatte -> Die dürften hier auch sein!!!! (KMT may22) // Die createLSPPlan_reloading(..) Methoden sind nicht unabhängig voneinander. // Das liegt wohl am statischen und das dann dort wieder Verknüpfungen gesetzt werden --> diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTestOutput.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTestOutput.java index 8a0fbd8ce12..7cfc3b4ca82 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTestOutput.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTestOutput.java @@ -25,7 +25,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; @@ -47,14 +48,14 @@ public static void main(String[] args) { Scenario scenario = ScenarioUtils.loadScenario(config); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); } } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java index a776131e925..b289d95c39a 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid.java @@ -33,9 +33,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; @@ -43,9 +41,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -97,8 +95,8 @@ public static void main(String[] args) { Scenario scenario = prepareScenario(config); log.info("Prepare Controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -106,7 +104,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -119,7 +117,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -141,22 +139,22 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Some results ...."); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printScores(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printScores(controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printShipmentsOfLSP( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printResults_shipmentPlan( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printResults_shipmentLog( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); } log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java index 18525885ce7..ffaf4c0aa48 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGrid_NR.java @@ -33,9 +33,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; @@ -43,9 +41,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.io.LSPPlanXmlReader; import org.matsim.freight.logistics.io.LSPPlanXmlWriter; @@ -123,8 +121,8 @@ public static void main(String[] args) { Scenario scenario = prepareScenario(config); log.info("Prepare Controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -132,7 +130,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -145,7 +143,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -166,31 +164,31 @@ public void install() { log.warn("Runs settings were: Demand: {}\n CarrierCosts: {}\n HubCosts: " + HUBCOSTS_FIX + "\n tollValue: " + TOLL_VALUE, demandSetting, costSetting); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); // Ggf. muss der Ordner noch erstellt werden (?) - new LSPPlanXmlWriter(LSPUtils.getLSPs(controler.getScenario())) - .write(controler.getConfig().controller().getOutputDirectory() + "/lsps.xml"); + new LSPPlanXmlWriter(LSPUtils.getLSPs(controller.getScenario())) + .write(controller.getConfig().controller().getOutputDirectory() + "/lsps.xml"); new LSPPlanXmlReader( - LSPUtils.getLSPs(controler.getScenario()), - CarriersUtils.getCarriers(controler.getScenario())); - new CarrierPlanWriter(CarriersUtils.getCarriers(controler.getScenario())) - .write(controler.getConfig().controller().getOutputDirectory() + "/carriers.xml"); + LSPUtils.getLSPs(controller.getScenario()), + CarriersUtils.getCarriers(controller.getScenario())); + new CarrierPlanWriter(CarriersUtils.getCarriers(controller.getScenario())) + .write(controller.getConfig().controller().getOutputDirectory() + "/carriers.xml"); log.info("Some results ...."); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printScores(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printScores(controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printShipmentsOfLSP( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printResults_shipmentPlan( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); ResourceImplementationUtils.printResults_shipmentLog( - controler.getControlerIO().getOutputPath(), lsp); + controller.getControlerIO().getOutputPath(), lsp); } log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyCarrierScorer.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyCarrierScorer.java index 7ee4a9f4d74..83b1fa4dc3a 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyCarrierScorer.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyCarrierScorer.java @@ -24,7 +24,7 @@ import org.matsim.core.scoring.ScoringFunction; import org.matsim.core.scoring.SumScoringFunction; import org.matsim.freight.carriers.Carrier; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; /** * @author Kai Martins-Turner (kturner) diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyEventBasedCarrierScorer.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyEventBasedCarrierScorer.java index da264c45ca1..ec67c2895f6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyEventBasedCarrierScorer.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/initialPlans/MyEventBasedCarrierScorer.java @@ -34,7 +34,7 @@ import org.matsim.core.scoring.SumScoringFunction; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.Tour; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.freight.carriers.events.CarrierTourEndEvent; import org.matsim.freight.carriers.events.CarrierTourStartEvent; import org.matsim.freight.logistics.examples.ExampleConstants; @@ -171,7 +171,7 @@ private void handleEvent(LinkEnterEvent event) { */ class LinkBasedTollScoring implements SumScoringFunction.ArbitraryEventScoring { - final Logger log = LogManager.getLogger(EventBasedScoring.class); + final Logger log = LogManager.getLogger(LinkBasedTollScoring.class); private final double toll; private final List vehicleTypesToBeTolled; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspReplanning/package-info.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspReplanning/package-info.java index 3a42f344ada..5d554e99a82 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspReplanning/package-info.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspReplanning/package-info.java @@ -27,7 +27,7 @@ * This class here is in contrast used as a Replanning strategy. This behavior is not wanted anymore. *

* Please use the new approach as shown in - * {@link org.matsim.freight.logistics.example.lsp.multipleChains} ExampleMultipleOneEchelonChainsReplanning instead. + * {@link org.matsim.freight.logistics.examples.multipleChains} ExampleMultipleOneEchelonChainsReplanning instead. * ((The old approach is still available in CollectionLSPReplanningTest but will get removed earlier or later)). *

* KMT, Jul'24 diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java index d857da8727f..69f9cc76a59 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoring.java @@ -33,7 +33,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; @@ -162,33 +163,33 @@ public static void main(String[] args) { Scenario scenario = prepareScenario(config); - Controler controler = prepareControler(scenario); + Controller controller = prepareController(scenario); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); for (LSP lsp2 : LSPUtils.getLSPs(scenario).getLSPs().values()) { System.out.println("The tip of all customers was: " + lsp2.getSelectedPlan().getScore()); } } - static Controler prepareControler(Scenario scenario) { + static Controller prepareController(Scenario scenario) { // Start the Mobsim one iteration is sufficient for scoring - Controler controler = new Controler(scenario); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { bind(LSPScorerFactory.class).toInstance(TipScorer::new); } }); - return controler; + return controller; } static Scenario prepareScenario(Config config) { diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java index 74a5990c7a0..59fb551c08b 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSP.java @@ -34,7 +34,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; @@ -80,7 +81,7 @@ public static void main(String[] args) { // schedule the LSP with the lspShipments and according to the scheduler of the Resource lsp.scheduleLogisticChains(); - // set up simulation controler and LSPModule + // set up simulation controller and LSPModule ArrayList lspList = new ArrayList<>(); lspList.add(lsp); LSPs lsps = new LSPs(lspList); @@ -90,8 +91,8 @@ public static void main(String[] args) { config.controller().setLastIteration(0); config.controller().setOverwriteFileSetting(OverwriteFileSetting.overwriteExistingFiles); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -100,11 +101,11 @@ public void install() { }); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); for (LspShipment lspShipment : lsp.getLspShipments()) { System.out.println("LspShipment: " + lspShipment.getId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java index 1e81d985419..1853cc27331 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfTransportChain.java @@ -33,7 +33,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; @@ -341,14 +342,14 @@ public static void main(String[] args) { // schedule the LSP with the lspShipments and according to the scheduler of the Resource lsp.scheduleLogisticChains(); - // set up simulation controler and LSPModule + // set up simulation controller and LSPModule ArrayList lspList = new ArrayList<>(); lspList.add(lsp); LSPs lsps = new LSPs(lspList); LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -363,11 +364,11 @@ public void install() { config.network().setInputFile("scenarios/2regions/2regions-network.xml"); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); for (LspShipment lspShipment : lsp.getLspShipments()) { System.out.println("Shipment: " + lspShipment.getId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChains.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChains.java index d0932dc1753..9cd649ae127 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChains.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChains.java @@ -33,7 +33,7 @@ import org.matsim.core.scoring.SumScoringFunction; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.Tour; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.freight.carriers.events.CarrierTourEndEvent; import org.matsim.freight.carriers.events.CarrierTourStartEvent; import org.matsim.freight.logistics.analysis.Vehicle2CarrierEventHandler; @@ -148,12 +148,12 @@ private void handleEvent(LinkEnterEvent event) { */ class LinkBasedTollScoring implements SumScoringFunction.ArbitraryEventScoring { - final Logger log = LogManager.getLogger(EventBasedScoring.class); + final Logger log = LogManager.getLogger(LinkBasedTollScoring.class); private final double toll; private final List vehicleTypesToBeTolled; private double score; - private List tolledLinkList; + private final List tolledLinkList; private final Vehicle2CarrierEventHandler v2c = new Vehicle2CarrierEventHandler(); public LinkBasedTollScoring(double toll, List vehicleTypeToBeTolled, List tolledLinkListBerlin) { diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java index 91e60ea2b8e..b45a151a19e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/EventBasedCarrierScorer4MultipleChainsInclToll.java @@ -35,7 +35,7 @@ import org.matsim.core.scoring.SumScoringFunction.ArbitraryEventScoring; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.Tour; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.freight.carriers.events.CarrierTourEndEvent; import org.matsim.freight.carriers.events.CarrierTourStartEvent; import org.matsim.freight.logistics.analysis.Driver2VehicleEventHandler; @@ -139,7 +139,7 @@ private void handleEvent(LinkEnterEvent event) { // scores tolls for vehicles driving on tolled links private void handleEvent(PersonMoneyEvent event) { - double tollValue = 0; + double tollValue; if (event.getPurpose().equals("toll")) { Id vehicleId = d2v.getVehicleOfDriver(event.getPersonId()); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleGroceryDeliveryMultipleChains.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleGroceryDeliveryMultipleChains.java index b4dee499b34..e2bb5db2bc0 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleGroceryDeliveryMultipleChains.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleGroceryDeliveryMultipleChains.java @@ -35,18 +35,16 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; import org.matsim.core.replanning.selectors.GenericWorstPlanForRemovalSelector; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.ExampleConstants; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -71,9 +69,9 @@ public static void main(String[] args) { log.info("Prepare scenario"); Scenario scenario = prepareScenario(config); - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -81,7 +79,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -96,7 +94,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -118,11 +116,11 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java index 5a1a0090fbd..fcf31169400 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleMixedEchelonChains.java @@ -32,9 +32,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; @@ -42,9 +40,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.ExampleConstants; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -96,9 +94,9 @@ public static void main(String[] args) { log.info("Prepare scenario"); Scenario scenario = prepareScenario(config); - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -106,7 +104,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -121,7 +119,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -141,11 +139,11 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java index 2e107c961db..6e01b0e38ac 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChains.java @@ -35,18 +35,16 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -97,9 +95,9 @@ public static void main(String[] args) { log.info("Prepare scenario"); Scenario scenario = prepareScenario(config); - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -107,7 +105,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -119,7 +117,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -139,11 +137,11 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java index 58aa47a74ab..4012855405c 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleOneEchelonChainsReplanning.java @@ -36,9 +36,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -47,9 +45,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -100,9 +98,9 @@ public static void main(String[] args) { log.info("Prepare scenario"); Scenario scenario = prepareScenario(config); - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -110,7 +108,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -122,7 +120,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -155,11 +153,11 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java index 0b36343790d..a0204e7fb36 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleMultipleTwoEchelonChainsReplanning.java @@ -36,9 +36,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -47,9 +45,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -102,9 +100,9 @@ public static void main(String[] args) { log.info("Prepare scenario"); Scenario scenario = prepareScenario(config); - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -113,7 +111,7 @@ public void install() { }); // @formatter:off - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -121,7 +119,7 @@ public void install() { bind(CarrierScoringFunctionFactory.class).toInstance(carrierScorer); bind(LSPScorerFactory.class).toInstance(MyLSPScorer::new); bind(CarrierStrategyManager.class).toProvider( () -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; }); @@ -141,11 +139,11 @@ public void install() { // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); log.info("Done."); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java index 57231be2dc1..1ed5bcc050d 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChains.java @@ -44,7 +44,6 @@ import java.io.IOException; import java.util.*; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; @@ -55,9 +54,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -65,9 +62,9 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.ExampleConstants; import org.matsim.freight.logistics.resourceImplementations.CarrierSchedulerUtils; @@ -75,7 +72,6 @@ import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.vehicles.VehicleType; - /** * This bases on {@link ExampleGroceryDeliveryMultipleChains}. * Now it will include two different LSPs @@ -132,13 +128,13 @@ public static void main(String[] args) { lsps.add(createLspWithDirectChain(scenario, "Kaufland_DIRECT", MultipleChainsUtils.createLSPShipmentsFromCarrierShipments(carrierKaufland), getDepotLinkFromVehicle(carrierKaufland), vehicleTypes)); LSPUtils.addLSPs(scenario, new LSPs(lsps)); - Controler controler = prepareControler(scenario); + Controller controller = prepareController(scenario); log.info("Run MATSim"); - controler.run(); + controller.run(); - runCarrierAnalysis(controler.getControlerIO().getOutputPath(), config); + runCarrierAnalysis(controller.getControlerIO().getOutputPath(), config); log.info("Done."); } @@ -170,10 +166,10 @@ private static Config prepareConfig(String[] args) { return config; } - private static Controler prepareControler(Scenario scenario) { - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + private static Controller prepareController(Scenario scenario) { + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -181,7 +177,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -196,7 +192,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -213,7 +209,7 @@ public void install() { }); } }); - return controler; + return controller; } private static void runCarrierAnalysis(String outputPath, Config config) { diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java index e27b2e27a4b..cd397b50937 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/ExampleTwoLspsGroceryDeliveryMultipleChainsWithToll.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.*; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.analysis.personMoney.PersonMoneyEventsAnalysisModule; @@ -36,9 +35,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.replanning.selectors.ExpBetaPlanSelector; @@ -47,9 +44,9 @@ import org.matsim.core.utils.misc.Time; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.ExampleConstants; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -118,19 +115,19 @@ public static void main(String[] args) { LSPUtils.addLSPs(scenario, new LSPs(lsps)); - Controler controler = prepareControler(scenario, rpScheme); + Controller controller = prepareController(scenario, rpScheme); log.info("Run MATSim"); // The VSP default settings are designed for person transport simulation. After talking to Kai, // they will be set to WARN here. Kai MT may'23 - controler + controller .getConfig() .vspExperimental() .setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.run(); - runCarrierAnalysis(controler.getControlerIO().getOutputPath(), config); + runCarrierAnalysis(controller.getControlerIO().getOutputPath(), config); log.info("Done."); } @@ -158,10 +155,10 @@ private static Config prepareConfig(String[] args) { return config; } - private static Controler prepareControler(Scenario scenario, RoadPricingScheme rpScheme) { - log.info("Prepare controler"); - Controler controler = new Controler(scenario); - controler.addOverridingModule( + private static Controller prepareController(Scenario scenario, RoadPricingScheme rpScheme) { + log.info("Prepare controller"); + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -170,7 +167,7 @@ public void install() { } }); - controler.addOverridingModule( + controller.addOverridingModule( new AbstractModule() { @Override public void install() { @@ -180,7 +177,7 @@ public void install() { .toProvider( () -> { CarrierStrategyManager strategyManager = - CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy( new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; @@ -198,10 +195,10 @@ public void install() { } }); if (!rpScheme.getTolledLinkIds().isEmpty()) { - // RoadPricing.configure(controler); - controler.addOverridingModule( new RoadPricingModule(rpScheme) ); + // RoadPricing.configure(controller); + controller.addOverridingModule( new RoadPricingModule(rpScheme) ); } - return controler; + return controller; } /* diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomLogisticChainShipmentAssigner.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomLogisticChainShipmentAssigner.java index 7477d0e0ac3..6cd0c2389c6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomLogisticChainShipmentAssigner.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomLogisticChainShipmentAssigner.java @@ -26,9 +26,9 @@ import java.util.Random; import org.matsim.core.gbl.Gbl; import org.matsim.core.gbl.MatsimRandom; +import org.matsim.freight.logistics.InitialShipmentAssigner; import org.matsim.freight.logistics.LSPPlan; import org.matsim.freight.logistics.LogisticChain; -import org.matsim.freight.logistics.InitialShipmentAssigner; import org.matsim.freight.logistics.shipment.LspShipment; /** diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomShiftingStrategyFactory.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomShiftingStrategyFactory.java index ee25acd18e5..45ae711dcf1 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomShiftingStrategyFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/RandomShiftingStrategyFactory.java @@ -25,7 +25,6 @@ import java.util.Iterator; import java.util.List; import java.util.Random; - import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.replanning.GenericPlanStrategy; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/RedRequirement.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/RedRequirement.java index ea51cb3a65a..0422427ab30 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/RedRequirement.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/requirementsChecking/RedRequirement.java @@ -45,7 +45,6 @@ import org.matsim.freight.logistics.LogisticChain; import org.matsim.freight.logistics.shipment.LspShipmentRequirement; - /*package-private*/ class RedRequirement implements LspShipmentRequirement { static final String RED = "red"; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/DistanceAndTimeHandler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/DistanceAndTimeHandler.java index 5eece04dd0e..22572f86572 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/DistanceAndTimeHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/DistanceAndTimeHandler.java @@ -85,7 +85,7 @@ private void processLeaveEvent(Id vehicleId, double time) { distanceCosts += linkLength * carrierVehicle.getType().getCostInformation().getCostsPerMeter(); } - // (there might not be a corresponding enter event if vehicle just entered traffic. Could add + // (there might not be a corresponding enter-event if vehicle just entered traffic. Could add // that as well, but then we would need to compensate for fact that this covers little distance. // kai, jul'22) diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java index 88d29d56327..26959c6081d 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/simulationTrackers/ExampleSimulationTrackers.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Random; - import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/io/LSPPlanXmlWriter.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/io/LSPPlanXmlWriter.java index 2c97a9ae99e..c997b5a35d2 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/io/LSPPlanXmlWriter.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/io/LSPPlanXmlWriter.java @@ -94,11 +94,11 @@ private void writeRootElement() throws IOException { this.writer.write(NL); } - private void startLSP(LSP lsp) throws IOException { + private void startLSP(LSP lsp) { this.writeStartTag(LSP, List.of(createTuple(ID, lsp.getId().toString()))); } - private void writeResources(LSP lsp) throws IOException { + private void writeResources(LSP lsp) { if (lsp.getResources().isEmpty()) return; this.writeStartTag(RESOURCES, null); for (LSPResource resource : lsp.getResources()) { @@ -127,7 +127,7 @@ private void writeResources(LSP lsp) throws IOException { this.writeEndTag(RESOURCES); } - private void writeShipments(LSP lsp) throws IOException { + private void writeShipments(LSP lsp) { if (lsp.getLspShipments().isEmpty()) return; this.writeStartTag(SHIPMENTS, null); for (LspShipment lspShipment : lsp.getLspShipments()) { @@ -149,7 +149,7 @@ private void writeShipments(LSP lsp) throws IOException { this.writeEndTag(SHIPMENTS); } - private void writePlans(LSP lsp, BufferedWriter writer) throws IOException { + private void writePlans(LSP lsp, BufferedWriter writer) { if (lsp.getPlans().isEmpty()) return; this.writeStartTag(LSP_PLANS, null); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CarrierSchedulerUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CarrierSchedulerUtils.java index bbd9235ca64..deb8e984b2e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CarrierSchedulerUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CarrierSchedulerUtils.java @@ -6,7 +6,6 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; import java.util.List; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java index 708f57974e4..d91bf1c94f5 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -22,7 +22,6 @@ package org.matsim.freight.logistics.resourceImplementations; import java.util.Objects; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; @@ -45,7 +44,7 @@ */ /*package-private*/ class CollectionCarrierScheduler extends LSPResourceScheduler { - Logger log = LogManager.getLogger(CollectionCarrierScheduler.class); + private static final Logger log = LogManager.getLogger(CollectionCarrierScheduler.class); private Carrier carrier; private CollectionCarrierResource resource; diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java index 249b5a76031..90abf00ea67 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -22,7 +22,6 @@ package org.matsim.freight.logistics.resourceImplementations; import java.util.*; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.locationtech.jts.util.Assert; @@ -49,7 +48,7 @@ */ /*package-private*/ class DistributionCarrierScheduler extends LSPResourceScheduler { - Logger log = LogManager.getLogger(DistributionCarrierScheduler.class); + private static final Logger log = LogManager.getLogger(DistributionCarrierScheduler.class); private Carrier carrier; private DistributionCarrierResource resource; @@ -101,8 +100,8 @@ protected void scheduleResource() { scheduledPlans.add(auxiliaryCarrier.getSelectedPlan()); var vrpLogic = CarrierSchedulerUtils.getVrpLogic(carrier); switch (vrpLogic) { - case serviceBased -> { carrier.getServices().putAll(auxiliaryCarrier.getServices()); } - case shipmentBased -> { carrier.getShipments().putAll(auxiliaryCarrier.getShipments()); } + case serviceBased -> carrier.getServices().putAll(auxiliaryCarrier.getServices()); + case shipmentBased -> carrier.getShipments().putAll(auxiliaryCarrier.getShipments()); default -> throw new IllegalStateException("Unexpected value: " + vrpLogic); } @@ -123,12 +122,11 @@ protected void scheduleResource() { scheduledPlans.add(auxiliaryCarrier.getSelectedPlan()); switch (CarrierSchedulerUtils.getVrpLogic(carrier)) { - case serviceBased -> { carrier.getServices().putAll(auxiliaryCarrier.getServices()); } - case shipmentBased -> { carrier.getShipments().putAll(auxiliaryCarrier.getShipments()); - //TODO: When using shipmentbased, only ONE Vrp should be created and solved. -> No need for the auxiliary carrier(s). KMT'Aug 24 - //Then we can also just pass all the vehicles over :) - //And need the TimeWindows for the Shipments... - } + case serviceBased -> carrier.getServices().putAll(auxiliaryCarrier.getServices()); + case shipmentBased -> //TODO: When using shipmentbased, only ONE Vrp should be created and solved. -> No need for the auxiliary carrier(s). KMT'Aug 24 + //Then we can also just pass all the vehicles over :) + //And need the TimeWindows for the Shipments... + carrier.getShipments().putAll(auxiliaryCarrier.getShipments()); default -> throw new IllegalStateException("Unexpected value: " + CarrierSchedulerUtils.getVrpLogic(carrier)); } shipmentsInCurrentTour.clear(); @@ -437,12 +435,8 @@ private void addDistributionServiceEventHandler( if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { DistributionServiceStartEventHandler handler; switch (tourActivity) { - case Tour.ServiceActivity serviceActivity-> { - handler = new DistributionServiceStartEventHandler(serviceActivity.getService(), lspShipment, element, resource, null); - } - case Tour.ShipmentBasedActivity shipmentBasedActivity-> { - handler = new DistributionServiceStartEventHandler(null, lspShipment, element, resource, shipmentBasedActivity.getShipment()); - } + case Tour.ServiceActivity serviceActivity-> handler = new DistributionServiceStartEventHandler(serviceActivity.getService(), lspShipment, element, resource, null); + case Tour.ShipmentBasedActivity shipmentBasedActivity-> handler = new DistributionServiceStartEventHandler(null, lspShipment, element, resource, shipmentBasedActivity.getShipment()); default -> throw new IllegalStateException("Unexpected value: " + tourActivity); } @@ -462,12 +456,8 @@ private void addDistributionTourStartEventHandler( if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourStartEventHandler handler; switch (tourActivity) { - case Tour.ServiceActivity serviceActivity-> { - handler = new LSPTourStartEventHandler(lspShipment, serviceActivity.getService(), element, resource, tour, null); - } - case Tour.ShipmentBasedActivity shipmentBasedActivity-> { - handler = new LSPTourStartEventHandler(lspShipment, null , element, resource, tour, shipmentBasedActivity.getShipment()); - } + case Tour.ServiceActivity serviceActivity-> handler = new LSPTourStartEventHandler(lspShipment, serviceActivity.getService(), element, resource, tour, null); + case Tour.ShipmentBasedActivity shipmentBasedActivity-> handler = new LSPTourStartEventHandler(lspShipment, null , element, resource, tour, shipmentBasedActivity.getShipment()); default -> throw new IllegalStateException("Unexpected value: " + tourActivity); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java index 4b3ff6a8daf..46a0ae0e709 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java @@ -21,6 +21,7 @@ package org.matsim.freight.logistics.resourceImplementations; +import java.util.Objects; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.freight.carriers.Carrier; @@ -40,8 +41,6 @@ import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; -import java.util.Objects; - /*package-private*/ class LSPTourStartEventHandler implements CarrierTourStartEventHandler, LSPSimulationTracker { diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/SimpleForwardLogisticChainScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/SimpleForwardLogisticChainScheduler.java index f046b80c846..59307392ff6 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/SimpleForwardLogisticChainScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/SimpleForwardLogisticChainScheduler.java @@ -33,7 +33,7 @@ * LogisticChainElement}. * *

2.) all {@link LSPResource}s that were handed over to the SimpleForwardSolutionScheduler - * exogenously, are now scheduled sequentially in an order that was also specified exogenously. This + * exogenous, are now scheduled sequentially in an order that was also specified exogenously. This * order ensures that each {@link LogisticChain} is traversed from the first to the last {@link * LogisticChainElement}. During this procedure, the concerned {@link LspShipment}s are taken from * the collection of incoming shipments, handled by the {@link LSPResource} in charge and then added diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index e4d151903e9..6c6081c81bf 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -29,10 +29,10 @@ import org.matsim.freight.logistics.LSPResourceScheduler; import org.matsim.freight.logistics.LogisticChainElement; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TranshipmentHubSchedulerBuilder; +import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentPlan; import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; -import org.matsim.freight.logistics.shipment.LspShipment; /*package-private*/ class TransshipmentHubScheduler extends LSPResourceScheduler { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java index bf1cb7be9a6..933961095cb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierEventsReadersTest.java @@ -20,6 +20,10 @@ package org.matsim.freight.carriers; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -36,12 +40,6 @@ import org.matsim.testcases.utils.EventsCollector; import org.matsim.vehicles.Vehicle; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.List; - - /** * @author Kai Martins-Turner (kturner) * @author Niclas Richter (nixlaos) @@ -195,7 +193,7 @@ void testReader() { handledEvents.addAll(eventHandlerServices.handledEvents); handledEvents.addAll(eventHandlerShipments.handledEvents); - //Please note: This test is sensitive to the order of events as they are added in carrierEvents (input) and the resukts of the handler... + //Please note: This test is sensitive to the order of events as they are added in carrierEvents (input) and the results of the handler... Assertions.assertArrayEquals(carrierEvents.toArray(), handledEvents.toArray()); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java index 49dc173dd05..e80f24075be 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierModuleTest.java @@ -33,11 +33,9 @@ import org.matsim.core.controler.Controler; import org.matsim.core.controler.OutputDirectoryHierarchy; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.freight.carriers.CarriersUtils; -import org.matsim.freight.carriers.FreightCarriersConfigGroup; -import org.matsim.freight.carriers.controler.CarrierModule; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierModule; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.carriers.mobsim.DistanceScoringFunctionFactoryForTests; import org.matsim.freight.carriers.mobsim.StrategyManagerFactoryForTests; import org.matsim.testcases.MatsimTestUtils; @@ -69,10 +67,10 @@ public void setUp(){ config.plans().setInputFile( testUtils.getClassInputDirectory() + "plans100.xml" ); config.controller().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.overwriteExistingFiles); config.controller().setWritePlansInterval(1); - config.controller().setCreateGraphs(false); + config.controller().setCreateGraphsInterval(0); freightCarriersConfigGroup = ConfigUtils.addOrGetModule( config, FreightCarriersConfigGroup.class ) ; freightCarriersConfigGroup.setCarriersFile( testUtils.getClassInputDirectory() + "carrierPlansEquils.xml"); - freightCarriersConfigGroup.setCarriersVehicleTypesFile( testUtils.getClassInputDirectory() + "vehicleTypes.xml"); + freightCarriersConfigGroup.setCarriersVehicleTypesFile( testUtils.getPackageInputDirectory() + "vehicleTypes_v2.xml"); Scenario scenario = ScenarioUtils.loadScenario( config ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java index 38749fbabdf..8092ccfd02d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanReaderV1Test.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.core.population.routes.NetworkRoute; -import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.Tour.Leg; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java index 0deffa73889..07b0a547f3e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2Test.java @@ -21,8 +21,12 @@ package org.matsim.freight.carriers; -import org.junit.jupiter.api.BeforeEach; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -32,16 +36,10 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.gbl.Gbl; import org.matsim.core.scenario.ScenarioUtils; -import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.*; - public class CarrierPlanXmlReaderV2Test { @RegisterExtension @@ -192,7 +190,7 @@ void test_readStream() { - + diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java index fb12a37ff82..db3141cf8cb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlReaderV2WithDtdTest.java @@ -21,20 +21,18 @@ package org.matsim.freight.carriers; +import java.util.*; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.core.gbl.Gbl; -import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; -import java.util.*; - public class CarrierPlanXmlReaderV2WithDtdTest { @RegisterExtension diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java deleted file mode 100644 index f4840b577ae..00000000000 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * *********************************************************************** * - * project: org.matsim.* - * *********************************************************************** * - * * - * copyright : (C) by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it 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. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** - * - */ - -package org.matsim.freight.carriers; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.matsim.api.core.v01.Id; -import org.matsim.freight.carriers.*; -import org.matsim.testcases.MatsimTestUtils; -import org.matsim.vehicles.VehicleType; -import org.matsim.vehicles.VehicleUtils; - -/** - */ -public class CarrierPlanXmlWriterV1Test { - - @RegisterExtension - private MatsimTestUtils testUtils = new MatsimTestUtils(); - - @Test - void testCarrierPlanWriterWrites() { - - CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); - new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( testUtils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); - VehicleType defaultVehicleType = VehicleUtils.getFactory().createVehicleType( Id.create("default", VehicleType.class ) ); - carrierVehicleTypes.getVehicleTypes().put( defaultVehicleType.getId(), defaultVehicleType ); - - Carriers carriers = new Carriers(); - CarrierPlanReaderV1 carrierPlanReaderV1 = new CarrierPlanReaderV1(carriers, carrierVehicleTypes ); - carrierPlanReaderV1.readFile(testUtils.getClassInputDirectory() + "carrierPlansEquils.xml"); - CarrierPlanXmlWriterV1 planWriter = new CarrierPlanXmlWriterV1(carriers.getCarriers().values()); - planWriter.write(testUtils.getOutputDirectory() + "carrierPlansEquilsWritten.xml"); - } - - -} diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java deleted file mode 100644 index 46444ed07d3..00000000000 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * *********************************************************************** * - * project: org.matsim.* - * *********************************************************************** * - * * - * copyright : (C) by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it 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. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** - * - */ - -package org.matsim.freight.carriers; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; -import org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.TransportMode; -import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.testcases.MatsimTestUtils; -import org.matsim.vehicles.Vehicle; - -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; - -public class CarrierPlanXmlWriterV2Test { - - @RegisterExtension - private MatsimTestUtils testUtils = new MatsimTestUtils(); - - private Carrier testCarrier; - - @BeforeEach - public void setUp() { - - CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); - new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( this.testUtils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); - - Carriers carriers = new Carriers(); - new CarrierPlanXmlReader(carriers, carrierVehicleTypes ).readFile(this.testUtils.getClassInputDirectory() + "carrierPlansEquils.xml" ); - new CarrierPlanXmlWriterV2(carriers).write(this.testUtils.getClassInputDirectory() + "carrierPlansEquilsWritten.xml"); - carriers.getCarriers().clear(); - new CarrierPlanXmlReader(carriers, carrierVehicleTypes ).readFile(this.testUtils.getClassInputDirectory() + "carrierPlansEquilsWritten.xml" ); - testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); - } - - @Test - void test_whenReadingServices_nuOfServicesIsCorrect(){ - assertEquals(3,testCarrier.getServices().size()); - } - - @Test - void test_whenReadingCarrier_itReadsTypeIdsCorrectly(){ - - CarrierVehicle light = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("lightVehicle")); - assertEquals("light",light.getVehicleTypeId().toString()); - - CarrierVehicle medium = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("mediumVehicle")); - assertEquals("medium",medium.getVehicleTypeId().toString()); - - CarrierVehicle heavy = CarriersUtils.getCarrierVehicle(testCarrier, Id.createVehicleId("heavyVehicle")); - assertEquals("heavy",heavy.getVehicleTypeId().toString()); - } - - @Test - void test_whenReadingCarrier_itReadsVehiclesCorrectly(){ - Map, CarrierVehicle> carrierVehicles = testCarrier.getCarrierCapabilities().getCarrierVehicles(); - assertEquals(3,carrierVehicles.size()); - assertTrue(exactlyTheseVehiclesAreInVehicleCollection(Arrays.asList(Id.create("lightVehicle", Vehicle.class), - Id.create("mediumVehicle", Vehicle.class),Id.create("heavyVehicle", Vehicle.class)),carrierVehicles.values())); - } - - @Test - void test_whenReadingCarrier_itReadsFleetSizeCorrectly(){ - assertEquals(FleetSize.INFINITE, testCarrier.getCarrierCapabilities().getFleetSize()); - } - - @Test - void test_whenReadingCarrier_itReadsShipmentsCorrectly(){ - assertEquals(2, testCarrier.getShipments().size()); - } - - @Test - void test_whenReadingCarrier_itReadsPlansCorrectly(){ - assertEquals(3, testCarrier.getPlans().size()); - } - - @Test - void test_whenReadingCarrier_itSelectsPlansCorrectly(){ - assertNotNull(testCarrier.getSelectedPlan()); - } - - @Test - void test_whenReadingPlans_nuOfToursIsCorrect(){ - List plans = new ArrayList<>(testCarrier.getPlans()); - assertEquals(1, plans.get(0).getScheduledTours().size()); - assertEquals(1, plans.get(1).getScheduledTours().size()); - assertEquals(1, plans.get(2).getScheduledTours().size()); - } - - @Test - void test_whenReadingToursOfPlan1_nuOfActivitiesIsCorrect(){ - List plans = new ArrayList<>(testCarrier.getPlans()); - CarrierPlan plan1 = plans.getFirst(); - ScheduledTour tour1 = plan1.getScheduledTours().iterator().next(); - assertEquals(5,tour1.getTour().getTourElements().size()); - } - - @Test - void test_whenReadingToursOfPlan2_nuOfActivitiesIsCorrect(){ - List plans = new ArrayList<>(testCarrier.getPlans()); - CarrierPlan plan2 = plans.get(1); - ScheduledTour tour1 = plan2.getScheduledTours().iterator().next(); - assertEquals(9,tour1.getTour().getTourElements().size()); - } - - @Test - void test_whenReadingToursOfPlan3_nuOfActivitiesIsCorrect(){ - List plans = new ArrayList<>(testCarrier.getPlans()); - CarrierPlan plan3 = plans.get(2); - ScheduledTour tour1 = plan3.getScheduledTours().iterator().next(); - assertEquals(9,tour1.getTour().getTourElements().size()); - } - - - private boolean exactlyTheseVehiclesAreInVehicleCollection(List> asList, Collection carrierVehicles) { - List vehicles = new ArrayList<>(carrierVehicles); - for(CarrierVehicle type : carrierVehicles) if(asList.contains(type.getId() )) vehicles.remove(type ); - return vehicles.isEmpty(); - } - - @Test - void test_CarrierHasAttributes(){ - assertEquals((TransportMode.drt), CarriersUtils.getCarrierMode(testCarrier)); - assertEquals(50, CarriersUtils.getJspritIterations(testCarrier)); - } - - @Test - void test_ServicesAndShipmentsHaveAttributes(){ - Object serviceCustomerAtt = testCarrier.getServices().get(Id.create("serv1",CarrierService.class)).getAttributes().getAttribute("customer"); - assertNotNull(serviceCustomerAtt); - assertEquals("someRandomCustomer", serviceCustomerAtt); - Object shipmentCustomerAtt = testCarrier.getShipments().get(Id.create("s1",CarrierShipment.class)).getAttributes().getAttribute("customer"); - assertNotNull(shipmentCustomerAtt); - assertEquals("someRandomCustomer", shipmentCustomerAtt); - } - -} diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java index b3a12fdb60f..f331ff0b671 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1Test.java @@ -21,6 +21,9 @@ package org.matsim.freight.carriers; +import static org.junit.jupiter.api.Assertions.*; + +import java.util.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -30,10 +33,6 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.*; - public class CarrierPlanXmlWriterV2_1Test { @RegisterExtension diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java index 71d69e6d216..5da6137dcd8 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierReadWriteV2_1Test.java @@ -21,13 +21,11 @@ package org.matsim.freight.carriers; +import java.util.Collections; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; -import java.util.Collections; - public class CarrierReadWriteV2_1Test { @RegisterExtension @@ -43,7 +41,7 @@ void readWriteTest() { String outputFilename = utils.getOutputDirectory() + "outputCarriers.xml"; CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(carrierVehicleTypes); - vehicleTypeReader.readFile(utils.getClassInputDirectory() + "vehicles.xml"); + vehicleTypeReader.readFile(utils.getPackageInputDirectory() + "vehicleTypes_v2.xml"); CarrierPlanXmlReader carrierReader = new CarrierPlanXmlReader(carriers, carrierVehicleTypes); carrierReader.readFile(inputFilename); @@ -65,7 +63,7 @@ void readWriteReadTest() { String outputFilename2 = utils.getOutputDirectory() + "/outputCarriers2.xml"; CarrierVehicleTypeReader vehicleTypeReader = new CarrierVehicleTypeReader(carrierVehicleTypes); - vehicleTypeReader.readFile(utils.getClassInputDirectory() + "vehicles.xml"); + vehicleTypeReader.readFile(utils.getPackageInputDirectory() + "vehicleTypes_v2.xml"); CarrierPlanXmlReader reader1 = new CarrierPlanXmlReader(carriers, carrierVehicleTypes); reader1.readFile(utils.getClassInputDirectory() + "carriers.xml"); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java index 97954bb151d..8a8b30b9a0a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest.java @@ -21,38 +21,39 @@ package org.matsim.freight.carriers; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; -import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; +import java.nio.file.Path; + public class CarrierVehicleTypeLoaderTest { @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); - private CarrierVehicleTypes types; private Carriers carriers; @BeforeEach public void setUp() { - types = new CarrierVehicleTypes(); - new CarrierVehicleTypeReader(types).readFile(utils.getClassInputDirectory() + "vehicleTypes.xml"); + CarrierVehicleTypes types = new CarrierVehicleTypes(); + new CarrierVehicleTypeReader(types).readFile(Path.of(utils.getClassInputDirectory()).getParent().resolve("vehicleTypes_v2.xml").toString()); carriers = new Carriers(); - new CarrierPlanXmlReader(carriers, types ).readFile(utils.getClassInputDirectory() + "carrierPlansEquils.xml" ); + new CarrierPlanXmlReader(carriers, types).readFile(utils.getClassInputDirectory() + "carrierPlansEquils.xml" ); } @Test void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ - new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); +// new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); Carrier testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("lightVehicle")); + assert v != null; VehicleType vehicleTypeLoaded = v.getType(); Assertions.assertNotNull(vehicleTypeLoaded); @@ -62,16 +63,17 @@ void test_whenLoadingTypes_allAssignmentsInLightVehicleAreCorrectly(){ Assertions.assertEquals(0.35, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); Assertions.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); - Assertions.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); - Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); + Assertions.assertEquals("gasoline", VehicleUtils.getHbefaTechnology(vehicleTypeLoaded.getEngineInformation())); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumptionLitersPerMeter(vehicleTypeLoaded.getEngineInformation()), MatsimTestUtils.EPSILON); } @Test void test_whenLoadingTypes_allAssignmentsInMediumVehicleAreCorrectly(){ - new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); +// new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(types); Carrier testCarrier = carriers.getCarriers().get(Id.create("testCarrier", Carrier.class)); CarrierVehicle v = CarriersUtils.getCarrierVehicle(testCarrier,Id.createVehicleId("mediumVehicle")); + assert v != null; VehicleType vehicleTypeLoaded = v.getType(); Assertions.assertNotNull(vehicleTypeLoaded); @@ -81,8 +83,8 @@ void test_whenLoadingTypes_allAssignmentsInMediumVehicleAreCorrectly(){ Assertions.assertEquals(0.4, vehicleTypeLoaded.getCostInformation().getCostsPerMeter(), MatsimTestUtils.EPSILON); Assertions.assertEquals(30, vehicleTypeLoaded.getCostInformation().getCostsPerSecond(), MatsimTestUtils.EPSILON); - Assertions.assertEquals("gasoline", vehicleTypeLoaded.getEngineInformation().getFuelType().toString()); - Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumption(vehicleTypeLoaded), MatsimTestUtils.EPSILON); + Assertions.assertEquals("gasoline", VehicleUtils.getHbefaTechnology(vehicleTypeLoaded.getEngineInformation())); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumptionLitersPerMeter(vehicleTypeLoaded.getEngineInformation()), MatsimTestUtils.EPSILON); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java index 3a2f5a5648e..47e8f2b8a95 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest.java @@ -21,6 +21,9 @@ package org.matsim.freight.carriers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; @@ -29,9 +32,7 @@ import org.matsim.api.core.v01.Id; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.VehicleType; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.matsim.vehicles.VehicleUtils; public class CarrierVehicleTypeReaderTest { @RegisterExtension private MatsimTestUtils utils = new MatsimTestUtils() ; @@ -39,25 +40,25 @@ public class CarrierVehicleTypeReaderTest { private static final Logger log = LogManager.getLogger(CarrierVehicleTypeReaderTest.class) ; private CarrierVehicleTypes types; - private String inFilename; @BeforeEach public void setUp() { types = new CarrierVehicleTypes(); - inFilename = utils.getClassInputDirectory() + "vehicleTypes.xml"; - new CarrierVehicleTypeReader(types).readFile( inFilename ); + String inFilename = utils.getClassInputDirectory() + "vehicleTypes_deprecated_v1.xml"; + new CarrierVehicleTypeReader(types).readFile(inFilename); } @Test void test_whenReadingTypes_nuOfTypesIsReadCorrectly(){ - assertEquals(2, types.getVehicleTypes().size()); + assertEquals(3, types.getVehicleTypes().size()); } @Test void test_whenReadingTypes_itReadyExactlyTheTypesFromFile(){ assertTrue(types.getVehicleTypes().containsKey(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ) ); assertTrue(types.getVehicleTypes().containsKey(Id.create("light", org.matsim.vehicles.VehicleType.class ) ) ); - assertEquals(2, types.getVehicleTypes().size()); + assertTrue(types.getVehicleTypes().containsKey(Id.create("heavy", org.matsim.vehicles.VehicleType.class ) ) ); + assertEquals(3, types.getVehicleTypes().size()); } @Test @@ -83,15 +84,15 @@ void test_whenReadingTypeMedium_itReadsCostInfoCorrectly(){ @Test void test_whenReadingTypeMedium_itReadsEngineInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.01); - assertEquals("gasoline", medium.getEngineInformation().getFuelType().toString()); + assertEquals(0.02, VehicleUtils.getFuelConsumptionLitersPerMeter(medium.getEngineInformation()), 0.01); + assertEquals("gasoline", VehicleUtils.getHbefaTechnology(medium.getEngineInformation())); } @Test void readV1andWriteV2(){ final String outFilename = utils.getOutputDirectory() + "/vehicleTypes_v2.xml"; new CarrierVehicleTypeWriter( types ).write( outFilename ) ; - final String referenceFilename = utils.getClassInputDirectory() + "/vehicleTypes_v2.xml" ; + final String referenceFilename = utils.getPackageInputDirectory() + "/vehicleTypes_v2.xml" ; MatsimTestUtils.assertEqualFilesLineByLine( referenceFilename, outFilename ); } @@ -104,7 +105,7 @@ void readV2andWriteV2() { log.info("") ; log.info("now starting for real") ; log.info("") ; - String inFilename1 = utils.getClassInputDirectory() + "vehicleTypes_v2.xml"; + String inFilename1 = utils.getPackageInputDirectory() + "vehicleTypes_v2.xml"; CarrierVehicleTypes types1 = new CarrierVehicleTypes(); new CarrierVehicleTypeReader( types1 ).readFile( inFilename1 ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java index a95fac8d1ec..653c3972aad 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeTest.java @@ -21,13 +21,12 @@ package org.matsim.freight.carriers; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; -import org.matsim.freight.carriers.CarrierVehicleTypes; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.*; import org.matsim.vehicles.EngineInformation.FuelType; @@ -49,8 +48,8 @@ public void setUp() { costInformation1.setCostsPerMeter( 1.0 ); costInformation1.setCostsPerSecond( 0.5 ); EngineInformation engineInformation1 = mediumType.getEngineInformation(); - engineInformation1.setFuelType( FuelType.diesel ); - engineInformation1.setFuelConsumption( 0.02 ); + VehicleUtils.setHbefaTechnology( engineInformation1, "diesel" ); + VehicleUtils.setFuelConsumptionLitersPerMeter( engineInformation1, 0.02 ); VehicleCapacity vehicleCapacity = mediumType.getCapacity(); vehicleCapacity.setWeightInTons( 30 ); mediumType.setDescription( "Medium Vehicle" ).setMaximumVelocity( 13.89 ); @@ -73,8 +72,8 @@ public void setUp() { costInformation.setCostsPerMeter( 0.75 ); costInformation.setCostsPerSecond( 0.25 ); EngineInformation engineInformation = smallType.getEngineInformation() ; - engineInformation.setFuelType( FuelType.gasoline ); - engineInformation.setFuelConsumption( 0.015 ); + VehicleUtils.setHbefaTechnology( engineInformation, "gasoline" ); + VehicleUtils.setFuelConsumptionLitersPerMeter( engineInformation, 0.015 ); VehicleCapacity capacity = smallType.getCapacity() ; capacity.setWeightInTons( 16 ) ; // VehicleType smallType = CarriersUtils.CarrierVehicleTypeBuilder.newInstance( smallTypeId, mediumType ) @@ -107,8 +106,8 @@ void test_whenCreatingTypeMedium_itCreatesCostInfoCorrectly(){ @Test void test_whenCreatingTypeMedium_itCreatesEngineInfoCorrectly(){ VehicleType medium = types.getVehicleTypes().get(Id.create("medium", org.matsim.vehicles.VehicleType.class ) ); - Assertions.assertEquals(0.02, medium.getEngineInformation().getFuelConsumption(),0.001); - Assertions.assertEquals(FuelType.diesel, medium.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumptionLitersPerMeter(medium.getEngineInformation())); + Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(medium.getEngineInformation())); } @Test @@ -141,8 +140,8 @@ void test_whenCopyingTypeMedium_itCopiesCostInfoCorrectly(){ @Test void test_whenCopyingTypeMedium_itCopiesEngineInfoCorrectly(){ VehicleType medium2 = types.getVehicleTypes().get(Id.create("medium2", org.matsim.vehicles.VehicleType.class ) ); - Assertions.assertEquals(0.02, medium2.getEngineInformation().getFuelConsumption(),0.001); - Assertions.assertEquals(FuelType.diesel, medium2.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.02, VehicleUtils.getFuelConsumptionLitersPerMeter(medium2.getEngineInformation())); + Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(medium2.getEngineInformation())); } @Test @@ -175,8 +174,8 @@ void test_whenModifyingTypeSmall_itModifiesCostInfoCorrectly(){ @Test void test_whenModifyingTypeSmall_itModifiesEngineInfoCorrectly(){ VehicleType small = types.getVehicleTypes().get(Id.create("small", org.matsim.vehicles.VehicleType.class ) ); - Assertions.assertEquals(0.015, small.getEngineInformation().getFuelConsumption(),0.001); - Assertions.assertEquals(FuelType.gasoline, small.getEngineInformation().getFuelType()); + Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumptionLitersPerMeter(small.getEngineInformation())); + Assertions.assertEquals("gasoline", VehicleUtils.getHbefaTechnology(small.getEngineInformation())); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java index 307408885a6..89228f26c4e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest.java @@ -23,9 +23,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.matsim.freight.carriers.CarrierVehicleTypeReader; -import org.matsim.freight.carriers.CarrierVehicleTypeWriter; -import org.matsim.freight.carriers.CarrierVehicleTypes; import org.matsim.testcases.MatsimTestUtils; public class CarrierVehicleTypeWriterTest { @@ -36,7 +33,7 @@ public class CarrierVehicleTypeWriterTest { @Test void testTypeWriter(){ CarrierVehicleTypes types = new CarrierVehicleTypes(); - new CarrierVehicleTypeReader(types).readFile(utils.getClassInputDirectory()+ "vehicleTypes.xml"); + new CarrierVehicleTypeReader(types).readFile(utils.getPackageInputDirectory()+ "vehicleTypes_v2.xml"); final String outputVehTypeFile = utils.getOutputDirectory()+ "vehicleTypesWritten.xml"; new CarrierVehicleTypeWriter(types).write(outputVehTypeFile); types.getVehicleTypes().clear(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java index 04772ee65a2..fe0428621e0 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/CarriersUtilsTest.java @@ -21,18 +21,17 @@ package org.matsim.freight.carriers; +import static org.matsim.testcases.MatsimTestUtils.EPSILON; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; -import org.matsim.freight.carriers.*; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import static org.matsim.testcases.MatsimTestUtils.EPSILON; - /** */ public class CarriersUtilsTest { @@ -43,7 +42,7 @@ public class CarriersUtilsTest { @Test void testAddAndGetVehicleToCarrier() { VehicleType vehicleType = VehicleUtils.createDefaultVehicleType(); - + Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id testVehicleId = Id.createVehicleId("testVehicle"); CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(testVehicleId, Id.createLinkId("link0"),vehicleType); @@ -58,6 +57,7 @@ void testAddAndGetVehicleToCarrier() { //get Vehicle CarrierVehicle carrierVehicle1 = CarriersUtils.getCarrierVehicle(carrier, testVehicleId ); + assert carrierVehicle1 != null; Assertions.assertEquals(testVehicleId, carrierVehicle1.getId()); Assertions.assertEquals(vehicleType, carrierVehicle1.getType()); Assertions.assertEquals(Id.createLinkId("link0"), carrierVehicle1.getLinkId() ); @@ -79,6 +79,7 @@ void testAddAndGetServiceToCarrier() { //get Service CarrierService cs1b = CarriersUtils.getService(carrier, serviceId ); + assert cs1b != null; Assertions.assertEquals(serviceId, cs1b.getId()); Assertions.assertEquals(service1.getId(), cs1b.getId()); Assertions.assertEquals(Id.createLinkId("link0"), cs1b.getLocationLinkId()); @@ -100,6 +101,7 @@ void testAddAndGetShipmentToCarrier() { //get Shipment CarrierShipment carrierShipment1b = CarriersUtils.getShipment(carrier, shipmentId ); + assert carrierShipment1b != null; Assertions.assertEquals(shipmentId, carrierShipment1b.getId()); Assertions.assertEquals(service1.getId(), carrierShipment1b.getId()); Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getFrom()); @@ -109,7 +111,7 @@ void testAddAndGetShipmentToCarrier() { @Test void testGetSetJspritIteration(){ Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); - //jspirtIterations is not set. should return Integer.Min_Value (null is not possible because returning (int) + //jspritIterations is not set. should return Integer.Min_Value (null is not possible because returning (int) Assertions.assertEquals(Integer.MIN_VALUE, CarriersUtils.getJspritIterations(carrier) ); CarriersUtils.setJspritIterations(carrier, 125); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java index 33a4d6736e8..5c3d053190b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/FreightCarriersConfigGroupTest.java @@ -21,6 +21,10 @@ package org.matsim.freight.carriers; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.matsim.core.config.Config; @@ -28,11 +32,6 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.freight.carriers.FreightCarriersConfigGroup.UseDistanceConstraintForTourPlanning; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Map; - /** * @author mrieser / Simunto */ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java index c7fc851bf24..58587ab5248 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest.java @@ -21,15 +21,14 @@ package org.matsim.freight.carriers.analysis; +import java.io.IOException; +import java.net.URL; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.testcases.MatsimTestUtils; -import java.io.IOException; -import java.net.URL; - public class FreightAnalysisEventBasedTest { @RegisterExtension diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT.java similarity index 95% rename from contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java rename to contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT.java index 75800bfd34d..d18c15840a4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT.java @@ -19,10 +19,10 @@ * */ -package org.matsim.freight.carriers.controler; +package org.matsim.freight.carriers.controller; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -40,6 +40,8 @@ import org.matsim.freight.carriers.mobsim.StrategyManagerFactoryForTests; import org.matsim.testcases.MatsimTestUtils; +import java.nio.file.Path; + public class EquilWithCarrierWithPersonsIT { private Controler controler; @@ -81,7 +83,7 @@ static Scenario commonScenario( Config config, MatsimTestUtils testUtils ){ Scenario scenario = ScenarioUtils.loadScenario( config ); CarrierVehicleTypes carrierVehicleTypes = new CarrierVehicleTypes(); - new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile( testUtils.getPackageInputDirectory() + "vehicleTypes_v2.xml" ); + new CarrierVehicleTypeReader( carrierVehicleTypes ).readFile(Path.of(testUtils.getPackageInputDirectory()).getParent().resolve("vehicleTypes_v2.xml").toString()); Carriers carriers = CarriersUtils.addOrGetCarriers(scenario ); new CarrierPlanXmlReader( carriers, carrierVehicleTypes ).readFile( testUtils.getClassInputDirectory() + "carrierPlansEquils.xml" ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT.java similarity index 99% rename from contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java rename to contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT.java index 70b01111b10..1df5a1a5b22 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT.java @@ -19,7 +19,7 @@ * */ -package org.matsim.freight.carriers.controler; +package org.matsim.freight.carriers.controller; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -33,9 +33,9 @@ import org.matsim.core.config.groups.RoutingConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; -import org.matsim.freight.carriers.FreightCarriersConfigGroup; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarriersUtils; +import org.matsim.freight.carriers.FreightCarriersConfigGroup; import org.matsim.freight.carriers.ScheduledTour; import org.matsim.freight.carriers.Tour; import org.matsim.freight.carriers.mobsim.DistanceScoringFunctionFactoryForTests; @@ -203,7 +203,7 @@ public void install() { } @Test - void testEventFilessAreEqual(){ + void testEventFilesAreEqual(){ setUp(); controler.addOverridingModule(new CarrierModule()); controler.addOverridingModule(new AbstractModule() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java index 43abc654497..43557b37a2a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintFromVehiclesFileTest.java @@ -21,6 +21,10 @@ package org.matsim.freight.carriers.jsprit; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; @@ -39,22 +43,17 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.FreightCarriersConfigGroup.UseDistanceConstraintForTourPlanning; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; +import org.matsim.freight.carriers.FreightCarriersConfigGroup.UseDistanceConstraintForTourPlanning; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; - /** * * @author rewert, kturner - * + *

* Test for the distance constraint. 4 different setups are used to control the * correct working of the constraint * @@ -113,13 +112,13 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru Assertions.assertEquals(1, carrierV1.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); VehicleType vehicleType_SmallV1 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V1", VehicleType.class)); VehicleType vehicleType_LargeV1 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V1", VehicleType.class)); - Assertions.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() - .getVehicle()).getType().getId()); + Assertions.assertEquals(vehicleType_SmallV1.getId(), carrierV1.getSelectedPlan().getScheduledTours().iterator().next() + .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV1 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV1.getEngineInformation()); double maxDistance_vehicleType_SmallV1 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV1.getEngineInformation()) @@ -144,12 +143,12 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru } Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } /** - * Option 2: Tour is not possible with the vehicle with the small battery. Thats - * why one vehicle with a large battery is used. + * Option 2: Tour is not possible with the vehicle with the small battery. + * That's why one vehicle with a large battery is used. * */ @Test @@ -190,7 +189,7 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru Assertions.assertEquals(1, carrierV2.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); VehicleType vehicleType_SmallV2 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V2", VehicleType.class)); VehicleType vehicleType_LargeV2 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V2", VehicleType.class)); @@ -221,7 +220,7 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru } Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } @@ -267,7 +266,7 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr Assertions.assertEquals(2, carrierV3.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); VehicleType vehicleType_SmallV3 = vehicleTypes.getVehicleTypes().get(Id.create("SmallBattery_V3", VehicleType.class)); VehicleType vehicleType_LargeV3 = vehicleTypes.getVehicleTypes().get(Id.create("LargeBattery_V3", VehicleType.class)); @@ -301,17 +300,17 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr if (distanceTour == 12000) Assertions.assertEquals(12000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else Assertions.assertEquals(20000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } } /** - * Option 4: An additional shipment outside the range of both BEVtypes. - * Therefore one diesel vehicle must be used and one vehicle with a small + * Option 4: An additional shipment outside the range of both BEV types. + * Therefore, one diesel vehicle must be used and one vehicle with a small * battery. * */ @@ -386,11 +385,11 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc if (thisTypeId.equals("SmallBattery_V4")) Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else if (thisTypeId.equals("DieselVehicle")) Assertions.assertEquals(36000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else Assertions.fail("Wrong vehicleType used"); } @@ -453,8 +452,6 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { /** * Creates the vehicle at the depot, ads this vehicle to the carriers and sets * the capabilities. Sets TimeWindow for the carriers. - * - * @param */ private static void createCarriers(Carriers carriers, FleetSize fleetSize, Carrier singleCarrier, CarrierVehicleTypes vehicleTypes) { @@ -474,8 +471,6 @@ private static void createCarriers(Carriers carriers, FleetSize fleetSize, Carri /** * Method for creating a new carrierVehicle * - * @param - * * @return new carrierVehicle at the depot */ static CarrierVehicle createGarbageTruck(String vehicleName, double earliestStartingTime, @@ -488,9 +483,6 @@ static CarrierVehicle createGarbageTruck(String vehicleName, double earliestStar /** * Defines and sets the Capabilities of the Carrier, including the vehicleTypes * for the carriers - * - * @param - * */ private static void defineCarriers(Carriers carriers, FleetSize fleetSize, Carrier singleCarrier, List vehicles, CarrierVehicleTypes vehicleTypes) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java index 50b8505cb70..a375cceac46 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/DistanceConstraintTest.java @@ -21,6 +21,10 @@ package org.matsim.freight.carriers.jsprit; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.Assertions; @@ -39,25 +43,20 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.FreightCarriersConfigGroup.UseDistanceConstraintForTourPlanning; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; +import org.matsim.freight.carriers.FreightCarriersConfigGroup.UseDistanceConstraintForTourPlanning; import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ExecutionException; - /** * * @author rewert, kturner - * + *

* Test for the distance constraint. 4 different setups are used to control the * correct working of the constraint for services - * + *

* 2 additional setups are defined when using shipments instead of service. * Shipments allow reloading of good during the tour. * @@ -123,10 +122,10 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru Assertions.assertEquals(1, carrierV1.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); - Assertions.assertEquals(vehicleType_SmallV1.getId(), ((Vehicle) carrierV1.getSelectedPlan().getScheduledTours().iterator().next() - .getVehicle()).getType().getId()); + Assertions.assertEquals(vehicleType_SmallV1.getId(), carrierV1.getSelectedPlan().getScheduledTours().iterator().next() + .getVehicle().getType().getId()); double maxDistance_vehicleType_LargeV1 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV1.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV1.getEngineInformation()); double maxDistance_vehicleType_SmallV1 = VehicleUtils.getEnergyCapacity(vehicleType_SmallV1.getEngineInformation()) @@ -151,12 +150,12 @@ final void CarrierSmallBatteryTest_Version1() throws ExecutionException, Interru } Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } /** - * Option 2: Tour is not possible with the vehicle with the small battery. Thats - * why one vehicle with a large battery is used. + * Option 2: Tour is not possible with the vehicle with the small battery. + * That's why one vehicle with a large battery is used. * */ @Test @@ -206,7 +205,7 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru Assertions.assertEquals(1, carrierV2.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); Assertions.assertEquals(vehicleType_LargeV2.getId(), carrierV2.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); @@ -234,7 +233,7 @@ final void CarrierLargeBatteryTest_Version2() throws ExecutionException, Interru } Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } @@ -292,7 +291,7 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr Assertions.assertEquals(2, carrierV3.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); double maxDistance_vehicleType_LargeV3 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV3.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV3.getEngineInformation()); @@ -323,17 +322,17 @@ final void Carrier2SmallBatteryTest_Version3() throws ExecutionException, Interr if (distanceTour == 12000) Assertions.assertEquals(12000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else Assertions.assertEquals(20000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); } } /** * Option 4: An additional service outside the range of both BEV types. - * Therefore one diesel vehicle must be used and one vehicle with a small + * Therefore, one diesel vehicle must be used and one vehicle with a small * battery. * */ @@ -372,7 +371,7 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc VehicleType vehicleType_Diesel = VehicleUtils.createVehicleType(Id.create("DieselVehicle", VehicleType.class)); vehicleType_Diesel.getCostInformation().setCostsPerMeter(0.00055).setCostsPerSecond(0.008).setFixedCost(400.); VehicleUtils.setHbefaTechnology(vehicleType_Diesel.getEngineInformation(), "diesel"); - VehicleUtils.setFuelConsumption(vehicleType_Diesel, 0.0001625); + VehicleUtils.setFuelConsumptionLitersPerMeter(vehicleType_Diesel.getEngineInformation(), 0.0001625); vehicleType_Diesel.setDescription("Carrier_Version4"); vehicleType_Diesel.getCapacity().setOther(40.); @@ -391,7 +390,7 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc Assertions.assertEquals(2, carrierV4.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); double maxDistance_vehicleType_Large4 = VehicleUtils.getEnergyCapacity(vehicleType_LargeV4.getEngineInformation()) / VehicleUtils.getEnergyConsumptionKWhPerMeter(vehicleType_LargeV4.getEngineInformation()); @@ -421,11 +420,11 @@ final void CarrierWithAdditionalDieselVehicleTest_Version4() throws ExecutionExc if (thisTypeId.equals("SmallBattery_V4")) Assertions.assertEquals(24000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else if (thisTypeId.equals("DieselVehicle")) Assertions.assertEquals(36000, distanceTour, MatsimTestUtils.EPSILON, - "The schedulded tour has a non expected distance"); + "The scheduled tour has a non expected distance"); else Assertions.fail("Wrong vehicleType used"); } @@ -436,7 +435,7 @@ else if (thisTypeId.equals("DieselVehicle")) * This test uses shipments instead of service . * As a consequence the vehicles can return to the depot, load more goods and run another subtour. * Distance is set to a value that, due to distance restrictions, two tours are necessary. - * + *

* This option (5) is designed similar to option 2 * */ @@ -479,7 +478,7 @@ final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionExc //We need two tours, due to reloading both shipments must be transported one after the other Assertions.assertEquals(2, carrierV5.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); Assertions.assertEquals(vehicleType_MidSizeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); @@ -506,9 +505,9 @@ final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionExc Assertions.assertEquals(2, distancesOfTours.size(), "There must be two entry for tour distances"); //One tour has distance of 12000m - Assertions.assertTrue(distancesOfTours.contains(12000.0), "The schedulded tour has a non expected distance"); + Assertions.assertTrue(distancesOfTours.contains(12000.0), "The scheduled tour has a non expected distance"); //The other tour has distance of 20000m - Assertions.assertTrue(distancesOfTours.contains(20000.0), "The schedulded tour has a non expected distance"); + Assertions.assertTrue(distancesOfTours.contains(20000.0), "The scheduled tour has a non expected distance"); } /** @@ -516,7 +515,7 @@ final void CarrierWithShipmentsMidSizeBatteryTest_Version5() throws ExecutionExc * This test uses shipments instead of service . * As a consequence the vehicles can return to the depot, load more goods and run another subtour. * Distance is set to a value that one tour can be run with loading once. - * + *

* This option (6) is designed similar to option 5 * */ @@ -560,7 +559,7 @@ final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionExcep //We need two tours, due to reloading both shipments must be transported one after the other Assertions.assertEquals(1, carrierV5.getSelectedPlan().getScheduledTours().size(), - "Not the correct amout of scheduled tours"); + "Not the correct amount of scheduled tours"); Assertions.assertEquals(vehicleType_LargeV5.getId(), carrierV5.getSelectedPlan().getScheduledTours().iterator().next() .getVehicle().getType().getId()); @@ -587,7 +586,7 @@ final void CarrierWithShipmentsLargeBatteryTest_Version6() throws ExecutionExcep Assertions.assertEquals(1, distancesOfTours.size(), "There must be one entry for tour distances"); //This tour has distance of 24000m - Assertions.assertTrue(distancesOfTours.contains(24000.0), "The schedulded tour has a non expected distance"); + Assertions.assertTrue(distancesOfTours.contains(24000.0), "The scheduled tour has a non expected distance"); } /** @@ -664,8 +663,6 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { /** * Creates the vehicle at the depot, ads this vehicle to the carriers and sets * the capabilities. Sets TimeWindow for the carriers. - * - * @param */ private static void createCarriers(Carriers carriers, FleetSize fleetSize, Carrier singleCarrier, CarrierVehicleTypes vehicleTypes) { @@ -684,9 +681,6 @@ private static void createCarriers(Carriers carriers, FleetSize fleetSize, Carri /** * Method for creating a new carrierVehicle - * - * @param - * * @return new carrierVehicle at the depot */ static CarrierVehicle createCarrierVehicle(String vehicleName, double earliestStartingTime, @@ -699,9 +693,6 @@ static CarrierVehicle createCarrierVehicle(String vehicleName, double earliestSt /** * Defines and sets the Capabilities of the Carrier, including the vehicleTypes * for the carriers - * - * @param - * */ private static void defineCarriers(Carriers carriers, FleetSize fleetSize, Carrier singleCarrier, List vehicles, CarrierVehicleTypes vehicleTypes) { @@ -711,7 +702,5 @@ private static void defineCarriers(Carriers carriers, FleetSize fleetSize, Carri CarriersUtils.addCarrierVehicle(singleCarrier, carrierVehicle); } singleCarrier.getCarrierCapabilities().getVehicleTypes().addAll(vehicleTypes.getVehicleTypes().values()); - - new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(vehicleTypes); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java index 7e0e4bbe12e..cf5060bf772 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/FixedCostsTest.java @@ -27,10 +27,12 @@ import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; +import java.net.URL; +import java.util.Collection; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -46,10 +48,6 @@ import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import java.net.URL; -import java.util.Collection; - - /** * @author kturner * @@ -91,8 +89,8 @@ public void setUp() { VehicleType carrierVehType_A = VehicleUtils.getFactory().createVehicleType( vehicleTypeId ); { EngineInformation engineInformation1 = carrierVehType_A.getEngineInformation(); - engineInformation1.setFuelType( EngineInformation.FuelType.diesel ); - engineInformation1.setFuelConsumption( 0.015 ); + VehicleUtils.setFuelConsumptionLitersPerMeter(carrierVehType_A.getEngineInformation(), 0.015); + VehicleUtils.setHbefaTechnology(engineInformation1, "diesel"); carrierVehType_A.getCapacity().setOther( 1. ); carrierVehType_A.getCostInformation().setFixedCost( 0. ).setCostsPerMeter( 0.001 ).setCostsPerSecond( 0.0 ); carrierVehType_A.setMaximumVelocity( 10 ); @@ -106,8 +104,8 @@ public void setUp() { VehicleType carrierVehType_B = VehicleUtils.getFactory().createVehicleType( vehicleTypeId1 ); { EngineInformation engineInformation = carrierVehType_B.getEngineInformation(); - engineInformation.setFuelType( EngineInformation.FuelType.diesel ); - engineInformation.setFuelConsumption( 0.015 ); + VehicleUtils.setFuelConsumptionLitersPerMeter(carrierVehType_A.getEngineInformation(), 0.015); + VehicleUtils.setHbefaTechnology(engineInformation, "diesel"); carrierVehType_B.getCapacity().setOther( 1. ); carrierVehType_B.getCostInformation().setFixedCost( 10. ).setCostsPerMeter( 0.00001 ).setCostsPerSecond( 0. ) ; carrierVehType_B.setMaximumVelocity( 10. ); @@ -118,7 +116,6 @@ public void setUp() { //carrier1: only vehicles of Type A (no fixed costs, variable costs: 1 EUR/km) CarrierCapabilities cc1 = CarrierCapabilities.Builder.newInstance() - .addType(carrierVehType_A) .addVehicle(carrierVehicle_A) .setFleetSize(CarrierCapabilities.FleetSize.INFINITE) .build(); @@ -127,7 +124,6 @@ public void setUp() { //carrier2: only vehicles of Type B (fixed costs of 10 EUR/vehicle, no variable costs) CarrierCapabilities cc2 = CarrierCapabilities.Builder.newInstance() - .addType(carrierVehType_B) .addVehicle(carrierVehicle_B) .setFleetSize(CarrierCapabilities.FleetSize.INFINITE) .build(); @@ -136,8 +132,6 @@ public void setUp() { //carrier3: has both vehicles of Type A (no fixed costs, variable costs: 1 EUR/km) and Type B (fixed costs of 10 EUR/vehicle, no variable costs) CarrierCapabilities cc3 = CarrierCapabilities.Builder.newInstance() - .addType(carrierVehType_A) - .addType(carrierVehType_B) .addVehicle(carrierVehicle_A) .addVehicle(carrierVehicle_B) .setFleetSize(CarrierCapabilities.FleetSize.INFINITE) @@ -145,10 +139,6 @@ public void setUp() { carrier3.setCarrierCapabilities(cc3); carriers.addCarrier(carrier3); - - // assign vehicle types to the carriers - new CarrierVehicleTypeLoader(carriers).loadVehicleTypes(vehicleTypes) ; - //load Network and build netbasedCosts for jsprit URL context = org.matsim.examples.ExamplesUtils.getTestScenarioURL( "freight-chessboard-9x9" ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java index 762a2efe08a..6c61511a480 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/IntegrationIT.java @@ -27,6 +27,8 @@ import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.reporting.SolutionPrinter; import com.graphhopper.jsprit.core.util.Solutions; +import java.nio.file.Path; +import java.util.concurrent.ExecutionException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -41,8 +43,6 @@ import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts.Builder; import org.matsim.testcases.MatsimTestUtils; -import java.util.concurrent.ExecutionException; - public class IntegrationIT { @RegisterExtension @@ -51,7 +51,7 @@ public class IntegrationIT { @Test void testJsprit() throws ExecutionException, InterruptedException { final String networkFilename = utils.getClassInputDirectory() + "/merged-network-simplified.xml.gz"; - final String vehicleTypeFilename = utils.getClassInputDirectory() + "/vehicleTypes.xml"; + final String vehicleTypeFilename = Path.of(utils.getPackageInputDirectory()).getParent().resolve("vehicleTypes_v2.xml").toString(); final String carrierFilename = utils.getClassInputDirectory() + "/carrier.xml"; Config config = ConfigUtils.createConfig(); @@ -99,7 +99,7 @@ void testJsprit() throws ExecutionException, InterruptedException { @Test void testJspritWithDefaultSolutionOption() throws ExecutionException, InterruptedException { final String networkFilename = utils.getClassInputDirectory() + "/merged-network-simplified.xml.gz"; - final String vehicleTypeFilename = utils.getClassInputDirectory() + "/vehicleTypes.xml"; + final String vehicleTypeFilename = Path.of(utils.getPackageInputDirectory()).getParent().resolve("vehicleTypes_v2.xml").toString(); final String carrierFilename = utils.getClassInputDirectory() + "/carrier.xml"; Config config = ConfigUtils.createConfig(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java index 15f7a1a7c86..5025334cc5e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/MatsimTransformerTest.java @@ -21,6 +21,8 @@ package org.matsim.freight.carriers.jsprit; +import static org.junit.jupiter.api.Assertions.*; + import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.job.Job; @@ -31,6 +33,9 @@ import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; import com.graphhopper.jsprit.core.problem.vehicle.VehicleImpl; import com.graphhopper.jsprit.core.problem.vehicle.VehicleTypeImpl; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -44,12 +49,6 @@ import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.*; - public class MatsimTransformerTest { @RegisterExtension @@ -340,7 +339,7 @@ private ScheduledTour getMatsimServiceTour() { .setCapacityDemand(10).build(); CarrierVehicle matsimVehicle = getMatsimVehicle("matsimVehicle", "loc", getMatsimVehicleType()); double startTime = 15.0; - Tour.Builder sTourBuilder = Tour.Builder.newInstance(); + Tour.Builder sTourBuilder = Tour.Builder.newInstance(Id.create("testTour", Tour.class)); sTourBuilder.scheduleStart(matsimVehicle.getLinkId() ); sTourBuilder.addLeg(sTourBuilder.createLeg(null, 15.0, 0.0)); sTourBuilder.scheduleService(s1); @@ -356,7 +355,7 @@ private ScheduledTour getMatsimTour(String vehicleId) { CarrierShipment s2 = getMatsimShipment("s2", "from", "to2", 20); CarrierVehicle matsimVehicle = getMatsimVehicle(vehicleId, "loc", getMatsimVehicleType()); double startTime = 15.0; - Tour.Builder sTourBuilder = Tour.Builder.newInstance(); + Tour.Builder sTourBuilder = Tour.Builder.newInstance(Id.create("testTour", Tour.class)); sTourBuilder.scheduleStart(matsimVehicle.getLinkId() ); sTourBuilder.addLeg(sTourBuilder.createLeg(null, 15.0, 0.0)); sTourBuilder.schedulePickup(s1); @@ -378,18 +377,13 @@ private CarrierVehicle getMatsimVehicle(String VehicleId, String locationId, Veh } private VehicleType getMatsimVehicleType() { -// EngineInformation engineInformation = new EngineInformation(); -// engineInformation.setFuelType( FuelType.diesel ); -// engineInformation.setFuelConsumption( (double) 15 ); -// CarriersUtils.CarrierVehicleTypeBuilder builder = CarriersUtils.CarrierVehicleTypeBuilder.newInstance( Id.create( "matsimType", VehicleType.class ) ) VehicleType vehicleType = VehicleUtils.getFactory() .createVehicleType(Id.create("matsimType", VehicleType.class)).setMaximumVelocity(13.8); vehicleType.getCapacity().setOther(50); vehicleType.getCostInformation().setCostsPerMeter(10.0).setCostsPerSecond(5.0).setFixedCost(100.); VehicleUtils.setHbefaTechnology(vehicleType.getEngineInformation(), "diesel"); - VehicleUtils.setFuelConsumption(vehicleType, 15.); -// vehicleType.getEngineInformation().setFuelType( FuelType.diesel ) ; -// vehicleType.getEngineInformation().setFuelConsumption( 15. ); + VehicleUtils.setFuelConsumptionLitersPerMeter(vehicleType.getEngineInformation(), 0.015); + return vehicleType; } @@ -422,8 +416,8 @@ void createVehicleRoutingProblemBuilderWithServices_isMadeCorrectly() { assertEquals(10.0, vehicle.getType().getVehicleCostParams().perDistanceUnit, 0.0); assertEquals(5.0, vehicle.getType().getVehicleCostParams().perTransportTimeUnit, 0.0); assertEquals(100.0, vehicle.getType().getVehicleCostParams().fix, 0.0); - // assertEquals(FuelType.diesel, vehicle. ...); //TODO - // assertEquals(15, FuelConsumption ...); //TODO + assertEquals("diesel", VehicleUtils.getHbefaTechnology(((VehicleType)vehicle.getType().getUserData()).getEngineInformation())); + assertEquals(0.015, VehicleUtils.getFuelConsumptionLitersPerMeter(((VehicleType)vehicle.getType().getUserData()).getEngineInformation())); assertEquals(13.8, vehicle.getType().getMaxVelocity(), 0.0); // check service data diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java index 64e7eeba641..d58cadf388a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/NetworkBasedTransportCostsTest.java @@ -21,9 +21,13 @@ package org.matsim.freight.carriers.jsprit; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import com.graphhopper.jsprit.core.problem.Location; import com.graphhopper.jsprit.core.problem.driver.Driver; import com.graphhopper.jsprit.core.problem.vehicle.Vehicle; +import java.util.Arrays; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -43,12 +47,6 @@ import org.matsim.vehicles.VehicleUtils; import org.matsim.vehicles.VehiclesFactory; -import java.util.Arrays; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - - public class NetworkBasedTransportCostsTest { diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java index 8886010e74b..7da556872c2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/jsprit/SkillsIT.java @@ -127,7 +127,6 @@ private Scenario setupTestScenario() { // typeOne.setCapacity(vehicleCapacity); typeOne.getCapacity().setOther( 2.0 ); CarriersUtils.addSkill(typeOne, "skill 1"); - capabilitiesBuilder.addType(typeOne); CarrierVehicle vehicleOne = CarrierVehicle.Builder.newInstance(Id.createVehicleId("1"), carrierLocation, typeOne ) .setEarliestStart(0.0) .setLatestEnd(Time.parseTime("24:00:00")) @@ -141,7 +140,6 @@ private Scenario setupTestScenario() { // typeTwo.setCapacity(vehicleCapacity); typeTwo.getCapacity().setOther( 2.0 ); CarriersUtils.addSkill(typeTwo, "skill 2"); - capabilitiesBuilder.addType(typeTwo); CarrierVehicle vehicleTwo = CarrierVehicle.Builder.newInstance(Id.createVehicleId("2"), carrierLocation, typeTwo ) .setEarliestStart(0.0) .setLatestEnd(Time.parseTime("24:00:00")) diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java index 81ad7c6e577..6fc9b085bf1 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/DistanceScoringFunctionFactoryForTests.java @@ -22,6 +22,8 @@ package org.matsim.freight.carriers.mobsim; import jakarta.inject.Inject; +import java.util.HashSet; +import java.util.Set; import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -38,14 +40,11 @@ import org.matsim.deprecated.scoring.ScoringFunctionAccumulator.LegScoring; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarrierConstants; -import org.matsim.freight.carriers.CarriersUtils; import org.matsim.freight.carriers.CarrierVehicle; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.CarriersUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.vehicles.Vehicle; -import java.util.HashSet; -import java.util.Set; - @Disabled public class DistanceScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ @@ -140,7 +139,7 @@ private double getTimeParameter(CarrierVehicle vehicle, Person driver) { // if(carrier.getCarrierCapabilities().getCarrierVehicles().containsKey(vehicleId)){ // return carrier.getCarrierCapabilities().getCarrierVehicles().get(vehicleId); // } -// log.error("Vehicle with Id does not exists", new IllegalStateException("vehicle with id " + vehicleId + " is missing")); +// log.error("Vehicle with Id does not exist", new IllegalStateException("vehicle with id " + vehicleId + " is missing")); // return null; // } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java index 68dbf0bc7ab..e529b690fd4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/ScoringFunctionFactoryForTests.java @@ -21,6 +21,8 @@ package org.matsim.freight.carriers.mobsim; +import java.util.HashSet; +import java.util.Set; import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -37,14 +39,11 @@ import org.matsim.deprecated.scoring.ScoringFunctionAccumulator.LegScoring; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarrierConstants; -import org.matsim.freight.carriers.CarriersUtils; import org.matsim.freight.carriers.CarrierVehicle; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.CarriersUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.vehicles.Vehicle; -import java.util.HashSet; -import java.util.Set; - @Disabled public class ScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ @@ -55,9 +54,8 @@ static class DriverLegScoring implements BasicScoring, LegScoring{ private final Carrier carrier; private final Set employedVehicles; private Leg currentLeg = null; - private double currentLegStartTime; - public DriverLegScoring(Carrier carrier, Network network) { + public DriverLegScoring(Carrier carrier, Network network) { super(); this.network = network; this.carrier = carrier; @@ -66,9 +64,7 @@ public DriverLegScoring(Carrier carrier, Network network) { @Override - public void finish() { - - } + public void finish() {} @Override @@ -87,7 +83,6 @@ public void reset() { @Override public void startLeg(double time, Leg leg) { currentLeg = leg; - currentLegStartTime = time; } @@ -97,9 +92,7 @@ public void endLeg(double time) { Id vehicleId = nRoute.getVehicleId(); CarrierVehicle vehicle = CarriersUtils.getCarrierVehicle(carrier, vehicleId); Gbl.assertNotNull(vehicle); - if(!employedVehicles.contains(vehicle)){ - employedVehicles.add(vehicle); - } + employedVehicles.add(vehicle); double distance = 0.0; if(currentLeg.getRoute() instanceof NetworkRoute){ distance += network.getLinks().get(currentLeg.getRoute().getStartLinkId()).getLength(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java index 680ef4e1953..c61519ea613 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/StrategyManagerFactoryForTests.java @@ -23,6 +23,7 @@ import com.google.inject.Provider; import jakarta.inject.Inject; +import java.util.Map; import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -36,13 +37,11 @@ import org.matsim.core.router.util.TravelTime; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarrierPlan; -import org.matsim.freight.carriers.controler.CarrierReRouteVehicles; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierReRouteVehicles; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.vehicles.Vehicle; -import java.util.Map; - @Disabled public class StrategyManagerFactoryForTests implements Provider{ @@ -83,7 +82,7 @@ public CarrierStrategyManager get() { GenericPlanStrategyImpl planStrat_reRoutePlan = new GenericPlanStrategyImpl<>( new BestPlanSelector<>() ); planStrat_reRoutePlan.addStrategyModule(new CarrierReRouteVehicles.Factory(router, network, travelTimes.get(TransportMode.car )).build() ); - CarrierStrategyManager stratManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager stratManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); stratManager.addStrategy(planStrat_reRoutePlan, null, 1.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java index a8cc127ba93..3b3f8965acf 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/mobsim/TimeScoringFunctionFactoryForTests.java @@ -22,6 +22,8 @@ package org.matsim.freight.carriers.mobsim; import jakarta.inject.Inject; +import java.util.HashSet; +import java.util.Set; import org.junit.jupiter.api.Disabled; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; @@ -38,14 +40,11 @@ import org.matsim.deprecated.scoring.ScoringFunctionAccumulator.LegScoring; import org.matsim.freight.carriers.Carrier; import org.matsim.freight.carriers.CarrierConstants; -import org.matsim.freight.carriers.CarriersUtils; import org.matsim.freight.carriers.CarrierVehicle; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.CarriersUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; import org.matsim.vehicles.Vehicle; -import java.util.HashSet; -import java.util.Set; - @Disabled public class TimeScoringFunctionFactoryForTests implements CarrierScoringFunctionFactory{ diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java index 76738a411a9..d7127bc80bf 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsIT.java @@ -26,8 +26,9 @@ import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; -import org.junit.jupiter.api.BeforeEach; +import java.util.Collection; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -45,9 +46,6 @@ import org.matsim.vehicles.*; import org.matsim.vehicles.EngineInformation.FuelType; -import java.util.Collection; - - //TODO: length of routes (legs) AND end time of route are missing. /** * @author kturner @@ -71,7 +69,7 @@ public class CarrierControllerUtilsIT{ public void setUp() { //Create carrier with services and shipments - Carriers carriersWithServicesAndShpiments = new Carriers(); + Carriers carriersWithServicesAndShipments = new Carriers(); carrierWServices = CarriersUtils.createCarrier(CARRIER_SERVICES_ID ); CarrierService service1 = createMatsimService("Service1", "i(3,9)", 2); CarriersUtils.addService(carrierWServices, service1); @@ -89,8 +87,8 @@ public void setUp() { final Id vehTypeId = Id.create( "gridType", VehicleType.class ); VehicleType carrierVehType = VehicleUtils.getFactory().createVehicleType( vehTypeId ); EngineInformation engineInformation = carrierVehType.getEngineInformation() ; - engineInformation.setFuelType( FuelType.diesel ); - engineInformation.setFuelConsumption( 0.015 ); + VehicleUtils.setHbefaTechnology(engineInformation, "diesel"); + VehicleUtils.setFuelConsumptionLitersPerMeter(engineInformation, 0.015); VehicleCapacity capacity = carrierVehType.getCapacity() ; capacity.setOther( 3. ) ; CostInformation costInfo = carrierVehType.getCostInformation(); @@ -106,18 +104,14 @@ public void setUp() { CarrierVehicle carrierVehicle = CarrierVehicle.Builder.newInstance(Id.create("gridVehicle", org.matsim.vehicles.Vehicle.class), Id.createLinkId("i(6,0)"), carrierVehType ).setEarliestStart(0.0 ).setLatestEnd(36000.0 ).build(); CarrierCapabilities.Builder ccBuilder = CarrierCapabilities.Builder.newInstance() - .addType(carrierVehType) .addVehicle(carrierVehicle) .setFleetSize(FleetSize.INFINITE); carrierWServices.setCarrierCapabilities(ccBuilder.build()); carrierWShipments.setCarrierCapabilities(ccBuilder.build()); // Add both carriers - carriersWithServicesAndShpiments.addCarrier(carrierWServices); - carriersWithServicesAndShpiments.addCarrier(carrierWShipments); - - // assign vehicle types to the carriers - new CarrierVehicleTypeLoader(carriersWithServicesAndShpiments).loadVehicleTypes(vehicleTypes) ; + carriersWithServicesAndShipments.addCarrier(carrierWServices); + carriersWithServicesAndShipments.addCarrier(carrierWShipments); //load Network and build netbasedCosts for jsprit Network network = NetworkUtils.createNetwork(); @@ -126,7 +120,7 @@ public void setUp() { final NetworkBasedTransportCosts netBasedCosts = netBuilder.build() ; netBuilder.setTimeSliceWidth(1800) ; // !!!!, otherwise it will not do anything. - for (Carrier carrier : carriersWithServicesAndShpiments.getCarriers().values()) { + for (Carrier carrier : carriersWithServicesAndShipments.getCarriers().values()) { //Build VRP VehicleRoutingProblem.Builder vrpBuilder = MatsimJspritFactory.createRoutingProblemBuilder(carrier, network); vrpBuilder.setRoutingCost(netBasedCosts) ; @@ -144,15 +138,12 @@ public void setUp() { } /* - * Now convert it to a only shipment-based VRP. + * Now convert it to an only shipment-based VRP. */ //Convert to jsprit VRP Carriers carriersWithShipmentsOnly = CarriersUtils.createShipmentVRPCarrierFromServiceVRPSolution( - carriersWithServicesAndShpiments ); - - // assign vehicle types to the carriers - new CarrierVehicleTypeLoader(carriersWithShipmentsOnly).loadVehicleTypes(vehicleTypes) ; + carriersWithServicesAndShipments ); for (Carrier carrier : carriersWithShipmentsOnly.getCarriers().values()) { //Build VRP diff --git a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java index 87ac86ec9b3..1896021e805 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/carriers/utils/CarrierControllerUtilsTest.java @@ -28,10 +28,12 @@ import com.graphhopper.jsprit.core.problem.VehicleRoutingProblem; import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution; import com.graphhopper.jsprit.core.util.Solutions; +import java.net.URL; +import java.util.Collection; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; @@ -41,7 +43,8 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.PlansConfigGroup; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.network.NetworkUtils; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; @@ -56,9 +59,6 @@ import org.matsim.testcases.MatsimTestUtils; import org.matsim.vehicles.*; -import java.net.URL; -import java.util.Collection; - public class CarrierControllerUtilsTest{ @RegisterExtension @@ -82,7 +82,7 @@ public class CarrierControllerUtilsTest{ public void setUp() { //Create carrier with services and shipments - Carriers carriersWithServicesAndShpiments = new Carriers(); + Carriers carriersWithServicesAndShipments = new Carriers(); carrierWServices = CarriersUtils.createCarrier(CARRIER_SERVICES_ID ); CarrierService service1 = createMatsimService("Service1", "i(3,9)", 2); CarriersUtils.addService(carrierWServices, service1); @@ -100,7 +100,7 @@ public void setUp() { final Id vehicleTypeId = Id.create( "gridType", VehicleType.class ); VehicleType carrierVehType = VehicleUtils.getFactory().createVehicleType( vehicleTypeId ); VehicleUtils.setHbefaTechnology(carrierVehType.getEngineInformation(), "diesel"); - VehicleUtils.setFuelConsumption(carrierVehType, 0.015); + VehicleUtils.setFuelConsumptionLitersPerMeter(carrierVehType.getEngineInformation(), 0.015); VehicleCapacity vehicleCapacity = carrierVehType.getCapacity(); vehicleCapacity.setOther( 3 ); CostInformation costInfo = carrierVehType.getCostInformation(); @@ -115,18 +115,14 @@ public void setUp() { CarrierVehicle carrierVehicle = CarrierVehicle.Builder.newInstance(Id.create("gridVehicle", org.matsim.vehicles.Vehicle.class), Id.createLinkId("i(6,0)"), carrierVehType ).setEarliestStart(0.0 ).setLatestEnd(36000.0 ).build(); CarrierCapabilities.Builder ccBuilder = CarrierCapabilities.Builder.newInstance() - .addType(carrierVehType) .addVehicle(carrierVehicle) .setFleetSize(FleetSize.INFINITE); carrierWServices.setCarrierCapabilities(ccBuilder.build()); carrierWShipments.setCarrierCapabilities(ccBuilder.build()); // Add both carriers - carriersWithServicesAndShpiments.addCarrier(carrierWServices); - carriersWithServicesAndShpiments.addCarrier(carrierWShipments); - - // assign vehicle types to the carriers - new CarrierVehicleTypeLoader(carriersWithServicesAndShpiments).loadVehicleTypes(vehicleTypes) ; + carriersWithServicesAndShipments.addCarrier(carrierWServices); + carriersWithServicesAndShipments.addCarrier(carrierWShipments); //load Network and build netbasedCosts for jsprit Network network = NetworkUtils.createNetwork(); @@ -152,22 +148,19 @@ public void setUp() { carrierWServices.addPlan(carrierPlanServicesAndShipments) ; /* - * Now convert it to a only shipment-based VRP. + * Now convert it to an only shipment-based VRP. */ //Convert to jsprit VRP - Carriers carriersWithShipmentsOnly = CarriersUtils.createShipmentVRPCarrierFromServiceVRPSolution(carriersWithServicesAndShpiments); + Carriers carriersWithShipmentsOnly = CarriersUtils.createShipmentVRPCarrierFromServiceVRPSolution(carriersWithServicesAndShipments); carrierWShipmentsOnlyFromCarrierWServices = carriersWithShipmentsOnly.getCarriers().get(CARRIER_SERVICES_ID); //with converted Service carrierWShipmentsOnlyFromCarrierWShipments = carriersWithShipmentsOnly.getCarriers().get(CARRIER_SHIPMENTS_ID); //with copied Shipments - - // assign vehicle types to the carriers - new CarrierVehicleTypeLoader(carriersWithShipmentsOnly).loadVehicleTypes(vehicleTypes) ; } //Should only have Services @Test - void numberOfInitalServicesIsCorrect() { + void numberOfInitialServicesIsCorrect() { Assertions.assertEquals(2, carrierWServices.getServices().size()); int demandServices = 0; @@ -227,7 +220,7 @@ void fleetAvailableAfterConvertingIsCorrect() { Assertions.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); Assertions.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); - Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); + Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumptionLitersPerMeter(carrierVehicleType.getEngineInformation()), 0.0); } Assertions.assertEquals(FleetSize.INFINITE, carrierWShipmentsOnlyFromCarrierWShipments.getCarrierCapabilities().getFleetSize()); @@ -239,11 +232,11 @@ void fleetAvailableAfterConvertingIsCorrect() { Assertions.assertEquals(0.001, carrierVehicleType.getCostInformation().getCostsPerSecond(), 0.0 ); Assertions.assertEquals(10, carrierVehicleType.getMaximumVelocity(), 0.0); Assertions.assertEquals("diesel", VehicleUtils.getHbefaTechnology(carrierVehicleType.getEngineInformation())); - Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumption(carrierVehicleType), 0.0); } + Assertions.assertEquals(0.015, VehicleUtils.getFuelConsumptionLitersPerMeter(carrierVehicleType.getEngineInformation()), 0.0); } } @Test - void copiingOfShipmentsIsDoneCorrectly() { + void copyingOfShipmentsIsDoneCorrectly() { boolean foundShipment1 = false; boolean foundShipment2 = false; CarrierShipment carrierShipment1 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWShipments, Id.create("shipment1", CarrierShipment.class)); @@ -276,19 +269,19 @@ void copiingOfShipmentsIsDoneCorrectly() { Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); Assertions.assertEquals(7200.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); } - Assertions.assertTrue(foundShipment1, "Not found Shipment1 after copiing"); - Assertions.assertTrue(foundShipment2, "Not found Shipment2 after copiing"); + Assertions.assertTrue(foundShipment1, "Not found Shipment1 after copying"); + Assertions.assertTrue(foundShipment2, "Not found Shipment2 after copying"); } @Test void convertionOfServicesIsDoneCorrectly() { - boolean foundSercice1 = false; + boolean foundService1 = false; boolean foundService2 = false; CarrierShipment carrierShipment1 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWServices, Id.create("Service1", CarrierShipment.class)); assert carrierShipment1 != null; if (carrierShipment1.getId() == Id.create("Service1", CarrierShipment.class)) { - foundSercice1 = true; + foundService1 = true; Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getFrom()); Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getTo()); Assertions.assertEquals(2, carrierShipment1.getSize()); @@ -313,12 +306,12 @@ void convertionOfServicesIsDoneCorrectly() { Assertions.assertEquals(0.0, carrierShipment2.getPickupTimeWindow().getStart(), 0); Assertions.assertEquals(36001.0, carrierShipment2.getPickupTimeWindow().getEnd(), 0); } - Assertions.assertTrue(foundSercice1, "Not found converted Service1 after converting"); + Assertions.assertTrue(foundService1, "Not found converted Service1 after converting"); Assertions.assertTrue(foundService2, "Not found converted Service2 after converting"); } /*Note: This test can be removed / modified when jsprit works properly with a combined Service and Shipment VRP. - * Currently the capacity of the vehicle seems to be "ignored" in a way that the load within the tour is larger than the capacity; + * Currently, the capacity of the vehicle seems to be "ignored" in a way that the load within the tour is larger than the capacity; * Maybe it is because of the misunderstanding, that a Service is modeled as "Pickup" and not as thought before as "Delivery". KMT sep18 */ @Test @@ -426,7 +419,7 @@ void testRunJsprit_allInformationGiven(){ Scenario scenario = ScenarioUtils.loadScenario(config); CarriersUtils.loadCarriersAccordingToFreightConfig(scenario ); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); try { CarriersUtils.runJsprit(scenario); @@ -435,7 +428,7 @@ void testRunJsprit_allInformationGiven(){ Assertions.fail(); } - Assertions.assertEquals(vraFile, ConfigUtils.addOrGetModule( controler.getConfig(), FreightCarriersConfigGroup.class ).getVehicleRoutingAlgorithmFile()); + Assertions.assertEquals(vraFile, ConfigUtils.addOrGetModule( controller.getConfig(), FreightCarriersConfigGroup.class ).getVehicleRoutingAlgorithmFile()); } /** @@ -461,10 +454,10 @@ void testRunJsprit_NoOfJspritIterationsMissing() { } /** - * Don't crash even if there is no algortihm file specified. + * Don't crash even if there is no algorithm file specified. */ @Test - void testRunJsprit_NoAlgortihmFileGiven(){ + void testRunJsprit_NoAlgorithmFileGiven(){ Config config = prepareConfig(); config.controller().setOutputDirectory(utils.getOutputDirectory()); Scenario scenario = ScenarioUtils.loadScenario(config); @@ -483,7 +476,7 @@ private Config prepareConfig(){ Config config = ConfigUtils.loadConfig(IOUtils.extendUrl(scenarioUrl, "config.xml" ) ); config.controller().setLastIteration(0); config.plans().setActivityDurationInterpretation(PlansConfigGroup.ActivityDurationInterpretation.tryEndTimeThenDuration ); - //freight configstuff + //freight config stuff FreightCarriersConfigGroup freightCarriersConfigGroup = ConfigUtils.addOrGetModule(config, FreightCarriersConfigGroup.class); freightCarriersConfigGroup.setCarriersFile(IOUtils.extendUrl(scenarioUrl, "singleCarrierFiveActivitiesWithoutRoutes.xml" ).toString() ); freightCarriersConfigGroup.setCarriersVehicleTypesFile(IOUtils.extendUrl(scenarioUrl, "vehicleTypes.xml" ).toString() ); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index 5d1d12abe8e..b7c0966e53d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -108,7 +108,7 @@ public void testCollectionResource() { assertTrue(collectionCarrier.getServices().isEmpty()); assertTrue(collectionCarrier.getShipments().isEmpty()); if (collectionCarrier.getCarrierCapabilities() == capabilities) { - assertSame(capabilities.getFleetSize(), FleetSize.INFINITE); + assertSame(FleetSize.INFINITE, capabilities.getFleetSize()); assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index a5b2bf9a8c9..4c4456bd9bc 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -110,7 +110,7 @@ public void testCollectionResource() { assertTrue(distributionCarrier.getServices().isEmpty()); assertTrue(distributionCarrier.getShipments().isEmpty()); if (distributionCarrier.getCarrierCapabilities() == capabilities) { - assertSame(capabilities.getFleetSize(), FleetSize.INFINITE); + assertSame(FleetSize.INFINITE, capabilities.getFleetSize()); assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 24eec24bc2f..06b2c79e66e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -108,7 +108,7 @@ public void testMainRunResource() { assertTrue(carrier.getServices().isEmpty()); assertTrue(carrier.getShipments().isEmpty()); if (carrier.getCarrierCapabilities() == capabilities) { - assertSame(capabilities.getFleetSize(), FleetSize.INFINITE); + assertSame(FleetSize.INFINITE, capabilities.getFleetSize()); assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/events/LspEventsReaderTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/events/LspEventsReaderTest.java index 5455ab846ef..e94073aace3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/events/LspEventsReaderTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/events/LspEventsReaderTest.java @@ -4,8 +4,8 @@ import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.List; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.Event; import org.matsim.core.api.experimental.events.EventsManager; @@ -63,4 +63,4 @@ private static class TestEventHandler handledEvents.add(event); } } -} \ No newline at end of file +} diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirectTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirectTest.java index 0e413a0719a..53fdd3eebcc 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirectTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleSchedulingOfTransportChainHubsVsDirectTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; public class ExampleSchedulingOfTransportChainHubsVsDirectTest { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGridTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGridTest.java index d2fce96569c..525936facc3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGridTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/initialPlans/ExampleTwoEchelonGridTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; public class ExampleTwoEchelonGridTest { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java index c3600d60c10..eaa6c22e3f4 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java @@ -25,8 +25,8 @@ import java.util.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -36,7 +36,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.replanning.GenericPlanStrategy; @@ -45,8 +46,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.CollectionCarrierResourceBuilder; @@ -194,11 +195,11 @@ public void initialize() { LSPUtils.addLSPs(scenario, new LSPs(Collections.singletonList(collectionLSP))); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new LSPModule() ); + controller.addOverridingModule(new LSPModule() ); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager manager = new LSPStrategyManagerImpl(); @@ -211,7 +212,7 @@ public void initialize() { }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -223,8 +224,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index 2e06a80c4cf..acfb73567df 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -28,8 +28,8 @@ import java.util.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -39,7 +39,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; @@ -156,10 +157,10 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule( new LSPModule() ); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule( new LSPModule() ); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPScorerFactory.class ).toInstance(ExampleLSPScoring.TipScorer::new); } @@ -170,8 +171,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoringTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoringTest.java index 78f968387b9..c6634e58239 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoringTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/ExampleLSPScoringTest.java @@ -21,12 +21,12 @@ package org.matsim.freight.logistics.examples.lspScoring; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Scenario; import org.matsim.core.config.Config; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; import org.matsim.freight.logistics.LSP; import org.matsim.freight.logistics.LSPUtils; import org.matsim.testcases.MatsimTestUtils; @@ -44,11 +44,11 @@ public void testMain() { Scenario scenario = ExampleLSPScoring.prepareScenario(config); - Controler controler = ExampleLSPScoring.prepareControler(scenario); + Controller controller = ExampleLSPScoring.prepareController(scenario); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); for (LSP lsp : LSPUtils.getLSPs(scenario).getLSPs().values()) { Assertions.assertEquals(13.245734044444207, lsp.getSelectedPlan().getScore(), Double.MIN_VALUE); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java index ee94945117d..e18204c2f99 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java @@ -26,8 +26,8 @@ import java.util.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -37,7 +37,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.replanning.GenericPlanStrategyImpl; @@ -45,8 +46,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -169,16 +170,16 @@ public void initialize() { lspList.add(collectionLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule( new LSPModule() ); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule( new LSPModule() ); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPScorerFactory.class ).toInstance(ExampleLSPScoring.TipScorer::new); bind( LSPStrategyManager.class ).toInstance( new LSPModule.LSPStrategyManagerEmptyImpl() ); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -189,8 +190,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSPTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSPTest.java index 89c841a26bb..8c50a3b20b3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSPTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/mobsimExamples/ExampleMobsimOfSimpleLSPTest.java @@ -25,8 +25,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.testcases.MatsimTestUtils; /** @@ -52,4 +52,4 @@ public void testForRuntimeExceptionsAndCompareEvents() { MatsimTestUtils.assertEqualEventsFiles(utils.getClassInputDirectory() + "output_events.xml.gz", utils.getOutputDirectory() + "output_events.xml.gz" ); } -} \ No newline at end of file +} diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java index 501e710b12f..b98dd24e4ca 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java @@ -28,8 +28,8 @@ import java.util.Collections; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -37,18 +37,16 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -225,22 +223,22 @@ public void initialize() { Scenario scenario = prepareScenario(config); - Controler controler = new Controler(scenario); - controler.addOverridingModule(new AbstractModule() { + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); } }); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { final EventBasedCarrierScorer4MultipleChains carrierScorer = new EventBasedCarrierScorer4MultipleChains(); bind(CarrierScoringFunctionFactory.class).toInstance(carrierScorer); bind(LSPScorerFactory.class).toInstance(MyLSPScorer::new); bind(CarrierStrategyManager.class).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; }); @@ -252,14 +250,14 @@ public void install() { } }); - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - LSP lsp = LSPUtils.getLSPs(controler.getScenario()).getLSPs().values().iterator().next(); + LSP lsp = LSPUtils.getLSPs(controller.getScenario()).getLSPs().values().iterator().next(); initialPlanCount = lsp.getPlans().size(); initialPlanShipmentPlanCount = lsp.getPlans().getFirst().getShipmentPlans().size(); - controler.run(); + controller.run(); updatedPlanCount = lsp.getPlans().size(); innovatedPlanShipmentPlanCount = lsp.getPlans().get(1).getShipmentPlans().size(); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java index fccfa68e09d..7556c24f8c6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java @@ -36,9 +36,7 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.config.groups.VspExperimentalConfigGroup; -import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; -import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.controler.*; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.replanning.GenericPlanStrategyImpl; import org.matsim.core.replanning.selectors.BestPlanSelector; @@ -48,9 +46,9 @@ import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.shipment.LspShipment; @@ -248,15 +246,15 @@ public void initialize() { Scenario scenario = prepareScenario(config); - Controler controler = new Controler(scenario); - controler.addOverridingModule(new AbstractModule() { + Controller controller = ControllerUtils.createController(scenario); + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); } }); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { final EventBasedCarrierScorer4MultipleChains carrierScorer = new EventBasedCarrierScorer4MultipleChains(); @@ -264,7 +262,7 @@ public void install() { bind(CarrierScoringFunctionFactory.class).toInstance(carrierScorer); bind(LSPScorerFactory.class).toInstance(MyLSPScorer::new); bind(CarrierStrategyManager.class).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); return strategyManager; }); @@ -279,10 +277,10 @@ public void install() { } }); - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - this.lsp = LSPUtils.getLSPs(controler.getScenario()).getLSPs().values().iterator().next(); + this.lsp = LSPUtils.getLSPs(controller.getScenario()).getLSPs().values().iterator().next(); } private Config prepareConfig() { diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index b6695f5377d..e72394b24ea 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -21,12 +21,14 @@ package org.matsim.freight.logistics.examples.simulationTrackers; +import static org.junit.jupiter.api.Assertions.*; + import java.util.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -36,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.events.handler.EventHandler; import org.matsim.core.network.io.MatsimNetworkReader; @@ -57,8 +60,6 @@ import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; -import static org.junit.jupiter.api.Assertions.*; - public class CollectionTrackerTest { private static final Logger log = LogManager.getLogger(CollectionTrackerTest.class); @RegisterExtension @@ -185,9 +186,9 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -199,8 +200,8 @@ public void install() { // config.network().setInputFile("scenarios/2regions/2regions-network.xml"); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test @@ -220,7 +221,7 @@ public void testCollectionTracker() { if (handler instanceof TourStartHandler startHandler) { double scheduledCosts = 0; for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { - scheduledCosts += ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getFixedCosts(); + scheduledCosts += scheduledTour.getVehicle().getType().getCostInformation().getFixedCosts(); totalScheduledCosts += scheduledCosts; } double trackedCosts = startHandler.getVehicleFixedCosts(); @@ -235,7 +236,7 @@ public void testCollectionTracker() { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof ServiceActivity activity) { - scheduledCosts += activity.getService().getServiceDuration() * ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getCostsPerSecond(); + scheduledCosts += activity.getService().getServiceDuration() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerSecond(); totalScheduledCosts += scheduledCosts; totalScheduledWeight += activity.getService().getCapacityDemand(); totalNumberOfScheduledShipments++; @@ -254,7 +255,7 @@ public void testCollectionTracker() { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof Leg leg) { - scheduledTimeCosts += leg.getExpectedTransportTime() * ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getCostsPerSecond(); + scheduledTimeCosts += leg.getExpectedTransportTime() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerSecond(); } } } @@ -265,17 +266,17 @@ public void testCollectionTracker() { double trackedDistanceCosts = distanceHandler.getDistanceCosts(); totalTrackedCosts += trackedDistanceCosts; for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { - scheduledDistanceCosts += network.getLinks().get(scheduledTour.getTour().getEndLinkId()).getLength() * ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getCostsPerMeter(); + scheduledDistanceCosts += network.getLinks().get(scheduledTour.getTour().getEndLinkId()).getLength() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerMeter(); for (TourElement element : scheduledTour.getTour().getTourElements()) { System.out.println(element); if (element instanceof Leg leg) { NetworkRoute linkRoute = (NetworkRoute) leg.getRoute(); for (Id linkId : linkRoute.getLinkIds()) { - scheduledDistanceCosts += network.getLinks().get(linkId).getLength() * ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getCostsPerMeter(); + scheduledDistanceCosts += network.getLinks().get(linkId).getLength() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerMeter(); } } if (element instanceof ServiceActivity activity) { - scheduledDistanceCosts += network.getLinks().get(activity.getLocation()).getLength() * ((Vehicle) scheduledTour.getVehicle()).getType().getCostInformation().getCostsPerMeter(); + scheduledDistanceCosts += network.getLinks().get(activity.getLocation()).getLength() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerMeter(); // (I think that we need this since the last link is not in the route. Or is it? kai, jul'22) // (yy I do not understand why we do not need to do this for the end activity of the tour.) } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/io/LSPReadWriteTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/io/LSPReadWriteTest.java index 9d3083cca8b..82a2d86a835 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/io/LSPReadWriteTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/io/LSPReadWriteTest.java @@ -1,8 +1,8 @@ package org.matsim.freight.logistics.io; import java.util.Collections; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.freight.carriers.CarrierPlanXmlReader; import org.matsim.freight.carriers.CarrierVehicleTypeReader; import org.matsim.freight.carriers.CarrierVehicleTypes; diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java index c97220d04f1..df196d86233 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java @@ -31,18 +31,18 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; -import org.matsim.api.core.v01.events.Event; import org.matsim.api.core.v01.network.Link; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.events.handler.BasicEventHandler; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.scenario.ScenarioUtils; @@ -182,10 +182,10 @@ public void initialize() { lspList.add(collectionLSP); lsps = new LSPs(lspList); } - Controler controler = new Controler(scenario); - controler.getEvents().addHandler((BasicEventHandler) event -> log.warn(event)); + Controller controller = ControllerUtils.createController(scenario); + controller.getEvents().addHandler((BasicEventHandler) event -> log.warn(event)); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -194,8 +194,8 @@ public void install() { LSPUtils.addLSPs(scenario, lsps); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java index aff14551751..4a17e1dbc4d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java @@ -24,8 +24,8 @@ import java.util.*; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -35,7 +35,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; @@ -284,9 +285,9 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -300,8 +301,8 @@ public void install() { config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java index de67d12221c..3294ed1b7c2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -258,9 +259,9 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -271,8 +272,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java index f32adf076fa..d5ba96be6d0 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -203,9 +204,9 @@ public void initialize() { LSPs lsps = new LSPs(lspList); LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -216,8 +217,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java index 0717249ee6f..aac62ebf43a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -234,9 +235,9 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -247,8 +248,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java index 2ddbb434170..57a4886fba3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -182,9 +183,9 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -195,8 +196,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java index 703861839c5..910cd4ce3ea 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.CollectionCarrierResourceBuilder; @@ -169,20 +170,20 @@ public void initialize() { lspList.add(collectionLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); } }); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toInstance( new LSPModule.LSPStrategyManagerEmptyImpl() ); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -193,8 +194,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java index 8c914933a58..8b2a05157c6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -296,11 +297,11 @@ public void initialize() { lspList.add(completeLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -308,7 +309,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -319,12 +320,12 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printResults_shipmentPlan(controler.getControlerIO().getOutputPath(), lsp); - ResourceImplementationUtils.printResults_shipmentLog(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printResults_shipmentPlan(controller.getControlerIO().getOutputPath(), lsp); + ResourceImplementationUtils.printResults_shipmentLog(controller.getControlerIO().getOutputPath(), lsp); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java index 0741c46ea6d..14d2f7a263f 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -262,11 +263,11 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -274,7 +275,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -285,8 +286,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java index 30c1ca58a93..fb6fb93f516 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -206,11 +207,11 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -218,7 +219,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -229,8 +230,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java index 1046eefc491..8dac1d91417 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -241,11 +242,11 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -253,7 +254,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -264,12 +265,12 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printResults_shipmentPlan(controler.getControlerIO().getOutputPath(), lsp); - ResourceImplementationUtils.printResults_shipmentLog(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printResults_shipmentPlan(controller.getControlerIO().getOutputPath(), lsp); + ResourceImplementationUtils.printResults_shipmentLog(controller.getControlerIO().getOutputPath(), lsp); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java index c0a54bf98d3..6a6c4aafdb6 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -164,10 +165,10 @@ public void initialize() { lspList.add(collectionLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -178,8 +179,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java index c15ce76cb22..984027f50d9 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java @@ -29,8 +29,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -40,7 +40,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -49,8 +50,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -65,7 +66,7 @@ import org.matsim.vehicles.VehicleUtils; public class MultipleShipmentsCompleteLSPMobsimTest { - + private static final Logger log = LogManager.getLogger(MultipleShipmentsCompleteLSPMobsimTest.class); @RegisterExtension public final MatsimTestUtils utils = new MatsimTestUtils(); @@ -299,11 +300,11 @@ public void initialize() { lspList.add(completeLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -311,7 +312,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -322,12 +323,12 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printResults_shipmentPlan(controler.getControlerIO().getOutputPath(), lsp); - ResourceImplementationUtils.printResults_shipmentLog(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printResults_shipmentPlan(controller.getControlerIO().getOutputPath(), lsp); + ResourceImplementationUtils.printResults_shipmentLog(controller.getControlerIO().getOutputPath(), lsp); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java index 0cf80a23fc6..37d260c2f28 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -47,8 +48,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.CarrierCapabilities.FleetSize; -import org.matsim.freight.carriers.controler.CarrierControlerUtils; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierControllerUtils; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.logistics.*; import org.matsim.freight.logistics.examples.lspReplanning.AssignmentStrategyFactory; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils; @@ -261,11 +262,11 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new LSPModule()); - controler.addOverridingModule( new AbstractModule(){ + controller.addOverridingModule(new LSPModule()); + controller.addOverridingModule( new AbstractModule(){ @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); @@ -273,7 +274,7 @@ public void initialize() { return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { - CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new RandomPlanSelector<>()), null, 1); return strategyManager; }); @@ -284,8 +285,8 @@ public void initialize() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java index c9857e222ef..7b75f3a8fd7 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -202,10 +203,10 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -216,12 +217,12 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printResults_shipmentPlan(controler.getControlerIO().getOutputPath(), lsp); - ResourceImplementationUtils.printResults_shipmentLog(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printResults_shipmentPlan(controller.getControlerIO().getOutputPath(), lsp); + ResourceImplementationUtils.printResults_shipmentLog(controller.getControlerIO().getOutputPath(), lsp); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java index 8c5767d0d8f..d0119ec03a2 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -236,10 +237,10 @@ public void initialize() { lspList.add(lsp); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -250,12 +251,12 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); - for (LSP lsp : LSPUtils.getLSPs(controler.getScenario()).getLSPs().values()) { - ResourceImplementationUtils.printResults_shipmentPlan(controler.getControlerIO().getOutputPath(), lsp); - ResourceImplementationUtils.printResults_shipmentLog(controler.getControlerIO().getOutputPath(), lsp); + for (LSP lsp : LSPUtils.getLSPs(controller.getScenario()).getLSPs().values()) { + ResourceImplementationUtils.printResults_shipmentPlan(controller.getControlerIO().getOutputPath(), lsp); + ResourceImplementationUtils.printResults_shipmentLog(controller.getControlerIO().getOutputPath(), lsp); } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java index 7018f2e6a07..f14a75d3802 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java @@ -27,8 +27,8 @@ import java.util.LinkedList; import java.util.List; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.TransportMode; @@ -38,7 +38,8 @@ import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; import org.matsim.core.controler.OutputDirectoryHierarchy.OverwriteFileSetting; import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.network.io.MatsimNetworkReader; @@ -290,10 +291,10 @@ public void initialize() { lspList.add(completeLSP); LSPs lsps = new LSPs(lspList); - Controler controler = new Controler(scenario); + Controller controller = ControllerUtils.createController(scenario); LSPUtils.addLSPs(scenario, lsps); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { install(new LSPModule()); @@ -304,8 +305,8 @@ public void install() { config.controller().setOverwriteFileSetting(OverwriteFileSetting.deleteDirectoryIfExists); config.controller().setOutputDirectory(utils.getOutputDirectory()); //The VSP default settings are designed for person transport simulation. After talking to Kai, they will be set to WARN here. Kai MT may'23 - controler.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); - controler.run(); + controller.getConfig().vspExperimental().setVspDefaultsCheckingLevel(VspExperimentalConfigGroup.VspDefaultsCheckingLevel.warn); + controller.run(); } @Test diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadResourceTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadResourceTest.java index d69105472f6..b98bb40a884 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadResourceTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadResourceTest.java @@ -56,8 +56,8 @@ public void TranshipmentHubTest() { // assertSame(TranshipmentHub.getClassOfResource(), TranshipmentHub.class); assertNotNull(transshipmentHubResource.getClientElements()); assertTrue(transshipmentHubResource.getClientElements().isEmpty()); - assertSame(transshipmentHubResource.getEndLinkId(), hubLinkId); - assertSame(transshipmentHubResource.getStartLinkId(), hubLinkId); + assertSame(hubLinkId, transshipmentHubResource.getEndLinkId()); + assertSame(hubLinkId, transshipmentHubResource.getStartLinkId()); assertNotNull(transshipmentHubResource.getSimulationTrackers()); assertFalse(transshipmentHubResource.getSimulationTrackers().isEmpty()); assertEquals(1, transshipmentHubResource.getSimulationTrackers().size()); diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierModuleTest/vehicleTypes.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierModuleTest/vehicleTypes.xml deleted file mode 100644 index 1ad295354d8..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierModuleTest/vehicleTypes.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - Light Vehicle - - - - - - - - - - - - - - - - Medium Vehicle - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test/carrierPlansEquils.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test/carrierPlansEquils.xml deleted file mode 100644 index 9c6165af57d..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV1Test/carrierPlansEquils.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquils.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquils.xml deleted file mode 100644 index 68337d77b88..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquils.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - drt - 50 - - - - - - - - - - - - - - someRandomCustomer - - - - - - - - - someRandomCustomer - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquilsWritten.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquilsWritten.xml deleted file mode 100644 index 5c122507f56..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierPlanXmlWriterV2Test/carrierPlansEquilsWritten.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - drt - 50 - - - - - - - - - - - - - - someRandomCustomer - - - - - - - - - someRandomCustomer - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - - - 2 3 4 - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/carriers.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/carriers.xml index 88124972eec..3d2ae8952c2 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/carriers.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/carriers.xml @@ -8,8 +8,8 @@ - - + + @@ -115,8 +115,8 @@ - - + + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/vehicles.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/vehicles.xml deleted file mode 100644 index 3ff84f751a1..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierReadWriteV2_1Test/vehicles.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes.xml deleted file mode 100644 index f4087007a6d..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - Medium Vehicle - - 30 - - - - - Light Vehicle - 15 - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest/vehicleTypes.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_deprecated_v1.xml similarity index 76% rename from contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest/vehicleTypes.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_deprecated_v1.xml index 4913dba6c79..703e60cd498 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeLoaderTest/vehicleTypes.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_deprecated_v1.xml @@ -14,9 +14,9 @@ - Heavy Vehicle - 15 - - + Medium Vehicle + 30 + + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_v2.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_v2.xml deleted file mode 100644 index 8568206c736..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderTest/vehicleTypes_v2.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - Light Vehicle - - - - - - - - 0.02 - gasoline - - - - - - - - - - - - - Medium Vehicle - - - - - - - - 0.02 - gasoline - - - - - - - - - - - - - \ No newline at end of file diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderWithDtdV1Test/carrierVehicleTypes_v2.xsd b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderWithDtdV1Test/carrierVehicleTypes_v2.xsd index 043b44666d5..e35fcb0c615 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderWithDtdV1Test/carrierVehicleTypes_v2.xsd +++ b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeReaderWithDtdV1Test/carrierVehicleTypes_v2.xsd @@ -4,85 +4,86 @@ elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest/vehicleTypes.xml b/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest/vehicleTypes.xml deleted file mode 100644 index 9ac37fd0dfe..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/CarrierVehicleTypeWriterTest/vehicleTypes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - Medium Vehicle - - 30 - - - - - Light Vehicle - 15 - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runServiceEventTest/Load_perVehicle.tsv b/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runServiceEventTest/Load_perVehicle.tsv index 67fb0e5f002..a1e0058ce5b 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runServiceEventTest/Load_perVehicle.tsv +++ b/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runServiceEventTest/Load_perVehicle.tsv @@ -1 +1 @@ -vehicleId capacity maxLoad load state during tour +vehicleId vehicleTypeId capacity maxLoad load state during tour diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runShipmentEventTest/Load_perVehicle.tsv b/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runShipmentEventTest/Load_perVehicle.tsv index cf7f4992d37..d61ddd36308 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runShipmentEventTest/Load_perVehicle.tsv +++ b/contribs/freight/test/input/org/matsim/freight/carriers/analysis/FreightAnalysisEventBasedTest/runShipmentEventTest/Load_perVehicle.tsv @@ -1,2 +1,2 @@ -vehicleId capacity maxLoad load state during tour -freight_carrier1_veh_freight_carrier1_veh_heavyVehicle_1_1 50.0 26 [3, 8, 18, 25, 26, 23, 13, 12, 7, 0] +vehicleId vehicleTypeId capacity maxLoad load state during tour +freight_carrier1_veh_freight_carrier1_veh_heavyVehicle_1_1 heavy 50.0 26 [3, 8, 18, 25, 26, 23, 13, 12, 7, 0] diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/vehicleTypes_v2.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controler/vehicleTypes_v2.xml deleted file mode 100644 index d29386a7a2a..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/controler/vehicleTypes_v2.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - Light Vehicle - - - - - - - - 0.02 - gasoline - - - - - - - - - - - - - Medium Vehicle - - - - - - - - 0.02 - gasoline - - - - - - - - - - - - - Medium Vehicle - - - - - - - - 0.03 - gasoline - - - - - - - - - - - - - Medium Vehicle - - - - - - - - 0.03 - gasoline - - - - - - - - - - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml similarity index 91% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml index 1a7369f8abf..0971f759480 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/carrierPlansEquils.xml @@ -31,17 +31,17 @@ - - + + - + - + @@ -58,7 +58,7 @@ - + @@ -76,18 +76,18 @@ - + - + - + - + @@ -106,18 +106,18 @@ - + - + - + - + @@ -136,7 +136,6 @@ - + - - \ No newline at end of file + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/network.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/network.xml old mode 100755 new mode 100644 similarity index 100% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/network.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/network.xml diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/plans100.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/plans100.xml similarity index 100% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithPersonsIT/plans100.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithPersonsIT/plans100.xml diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml similarity index 91% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml index 4fd1e13d09d..e7374870fc3 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/carrierPlansEquils.xml @@ -31,17 +31,17 @@ - - + + - + - + @@ -58,7 +58,7 @@ - + @@ -76,18 +76,18 @@ - + - + - + - + @@ -106,18 +106,18 @@ - + - + - + - + @@ -136,6 +136,6 @@ - + - + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/network.xml b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/network.xml old mode 100755 new mode 100644 similarity index 100% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/network.xml rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/network.xml diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/output_events.xml.gz b/contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/output_events.xml.gz similarity index 100% rename from contribs/freight/test/input/org/matsim/freight/carriers/controler/EquilWithCarrierWithoutPersonsIT/output_events.xml.gz rename to contribs/freight/test/input/org/matsim/freight/carriers/controller/EquilWithCarrierWithoutPersonsIT/output_events.xml.gz diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/carrier.xml b/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/carrier.xml index e14845dfaff..3f7eaf626e1 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/carrier.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/carrier.xml @@ -3,19 +3,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -197,8 +197,8 @@ - - + + diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/vehicleTypes.xml b/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/vehicleTypes.xml deleted file mode 100644 index 5f3ad64ff22..00000000000 --- a/contribs/freight/test/input/org/matsim/freight/carriers/jsprit/IntegrationIT/vehicleTypes.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - null - 6000 - - - - null - 7000 - - - - null - 12000 - - - - null - 3000 - - - - null - 15000 - - - - diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT/runChessboard/output_events.xml.gz b/contribs/freight/test/input/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT/runChessboard/output_events.xml.gz index 8057a55fbcc..bf5ebee32b8 100644 Binary files a/contribs/freight/test/input/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT/runChessboard/output_events.xml.gz and b/contribs/freight/test/input/org/matsim/freight/carriers/usecases/chessboard/RunChessboardIT/runChessboard/output_events.xml.gz differ diff --git a/contribs/freight/test/input/org/matsim/freight/carriers/vehicleTypes_v2.xml b/contribs/freight/test/input/org/matsim/freight/carriers/vehicleTypes_v2.xml index c9b487b48b9..f78dccd883c 100644 --- a/contribs/freight/test/input/org/matsim/freight/carriers/vehicleTypes_v2.xml +++ b/contribs/freight/test/input/org/matsim/freight/carriers/vehicleTypes_v2.xml @@ -2,29 +2,7 @@ - - - Light Vehicle - - - - - - - - 0.02 - gasoline - - - - - - - - - - - + Medium Vehicle @@ -34,11 +12,11 @@ - 0.02 - gasoline + gasoline + 0.03 - + @@ -46,21 +24,21 @@ - + - Medium Vehicle - + Light Vehicle + - 0.03 - gasoline + gasoline + 0.02 - + @@ -68,7 +46,7 @@ - + Medium Vehicle @@ -78,11 +56,11 @@ - 0.03 - gasoline + gasoline + 0.02 - + diff --git a/contribs/freightreceiver/pom.xml b/contribs/freightreceiver/pom.xml index 9b9a8fdc2c9..1e69c51d40d 100644 --- a/contribs/freightreceiver/pom.xml +++ b/contribs/freightreceiver/pom.xml @@ -28,13 +28,13 @@ org.matsim.contrib freight - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim matsim-examples - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/UsecasesCarrierScoringFunctionFactory.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/UsecasesCarrierScoringFunctionFactory.java index f1287ff4de3..ba49d350c14 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/UsecasesCarrierScoringFunctionFactory.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/UsecasesCarrierScoringFunctionFactory.java @@ -8,8 +8,8 @@ import org.matsim.api.core.v01.population.Activity; import org.matsim.api.core.v01.population.Leg; import org.matsim.freight.carriers.*; -import org.matsim.freight.carriers.controler.CarrierScoringFunctionFactory; -import org.matsim.freight.carriers.controler.FreightActivity; +import org.matsim.freight.carriers.controller.CarrierScoringFunctionFactory; +import org.matsim.freight.carriers.controller.FreightActivity; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.scoring.ScoringFunction; import org.matsim.core.scoring.SumScoringFunction; diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/replanning/ReceiverStrategyManager.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/replanning/ReceiverStrategyManager.java index f10d7d98145..f697154a305 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/replanning/ReceiverStrategyManager.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/replanning/ReceiverStrategyManager.java @@ -20,7 +20,7 @@ package org.matsim.freight.receiver.replanning; -import org.matsim.freight.carriers.controler.CarrierStrategyManager; +import org.matsim.freight.carriers.controller.CarrierStrategyManager; import org.matsim.freight.receiver.Receiver; import org.matsim.freight.receiver.ReceiverPlan; import org.matsim.core.replanning.GenericStrategyManager; diff --git a/contribs/informed-mode-choice/pom.xml b/contribs/informed-mode-choice/pom.xml index 04b54d402cb..d28005db983 100644 --- a/contribs/informed-mode-choice/pom.xml +++ b/contribs/informed-mode-choice/pom.xml @@ -16,7 +16,7 @@ org.matsim.contrib application - 2025.0-SNAPSHOT + ${project.parent.version} xerces diff --git a/contribs/integration/pom.xml b/contribs/integration/pom.xml index 05bc09e61a9..95a7a2dfd5c 100644 --- a/contribs/integration/pom.xml +++ b/contribs/integration/pom.xml @@ -80,7 +80,7 @@ org.matsim.contrib accessibility - 2025.0-SNAPSHOT + ${project.parent.version} org.geotools.jdbc @@ -90,18 +90,18 @@ org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} test org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} test diff --git a/contribs/locationchoice/pom.xml b/contribs/locationchoice/pom.xml index 955d0dd364c..33de35d8866 100644 --- a/contribs/locationchoice/pom.xml +++ b/contribs/locationchoice/pom.xml @@ -24,12 +24,12 @@ org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} test diff --git a/contribs/minibus/pom.xml b/contribs/minibus/pom.xml index c9b6f4eb0fb..374288785e9 100644 --- a/contribs/minibus/pom.xml +++ b/contribs/minibus/pom.xml @@ -45,7 +45,7 @@ org.matsim matsim - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/noise/pom.xml b/contribs/noise/pom.xml index ac1c5fbd32b..920c9b58606 100644 --- a/contribs/noise/pom.xml +++ b/contribs/noise/pom.xml @@ -13,7 +13,7 @@ org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/parking/pom.xml b/contribs/parking/pom.xml index f6d4bbf3c76..8dd4d6c1af9 100644 --- a/contribs/parking/pom.xml +++ b/contribs/parking/pom.xml @@ -12,17 +12,17 @@ org.matsim.contrib multimodal - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/pom.xml b/contribs/pom.xml index c8b2dd3620c..ae36adaea70 100644 --- a/contribs/pom.xml +++ b/contribs/pom.xml @@ -115,14 +115,14 @@ org.matsim matsim - ${project.version} + ${project.parent.version} jar compile org.matsim matsim - ${project.version} + ${project.parent.version} test-jar test @@ -133,7 +133,7 @@ org.matsim matsim-examples test - ${project.version} + ${project.parent.version} diff --git a/contribs/pseudosimulation/pom.xml b/contribs/pseudosimulation/pom.xml index 9d9ec4449f2..dbb6f00a75e 100644 --- a/contribs/pseudosimulation/pom.xml +++ b/contribs/pseudosimulation/pom.xml @@ -13,7 +13,7 @@ org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} commons-cli diff --git a/contribs/shared_mobility/pom.xml b/contribs/shared_mobility/pom.xml index d97630a3c64..24edfc4a3ce 100644 --- a/contribs/shared_mobility/pom.xml +++ b/contribs/shared_mobility/pom.xml @@ -16,12 +16,12 @@ org.matsim matsim-examples - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/signals/pom.xml b/contribs/signals/pom.xml index 15dc9962de4..23d03270960 100644 --- a/contribs/signals/pom.xml +++ b/contribs/signals/pom.xml @@ -22,12 +22,12 @@ org.matsim matsim-examples - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} compile diff --git a/contribs/simulatedannealing/pom.xml b/contribs/simulatedannealing/pom.xml index fbe7ed06b54..a3a2688d16e 100644 --- a/contribs/simulatedannealing/pom.xml +++ b/contribs/simulatedannealing/pom.xml @@ -16,7 +16,7 @@ org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/simwrapper/pom.xml b/contribs/simwrapper/pom.xml index 499bf95af87..cf59db1d70d 100644 --- a/contribs/simwrapper/pom.xml +++ b/contribs/simwrapper/pom.xml @@ -16,7 +16,7 @@ org.matsim.contrib application - 2025.0-SNAPSHOT + ${project.parent.version} @@ -55,7 +55,7 @@ org.matsim.contrib vsp - 2025.0-SNAPSHOT + ${project.parent.version} test diff --git a/contribs/small-scale-traffic-generation/pom.xml b/contribs/small-scale-traffic-generation/pom.xml index 46ea6a80936..07314d16da1 100644 --- a/contribs/small-scale-traffic-generation/pom.xml +++ b/contribs/small-scale-traffic-generation/pom.xml @@ -15,13 +15,13 @@ org.matsim.contrib application - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib freight - 2025.0-SNAPSHOT + ${project.parent.version} diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java index 094c2f753f4..c3aa017dc39 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/GenerateSmallScaleCommercialTrafficDemand.java @@ -70,7 +70,7 @@ import org.matsim.facilities.ActivityFacility; import org.matsim.freight.carriers.*; import org.matsim.freight.carriers.analysis.RunFreightAnalysisEventBased; -import org.matsim.freight.carriers.controler.*; +import org.matsim.freight.carriers.controller.*; import org.matsim.freight.carriers.usecases.chessboard.CarrierTravelDisutilities; import org.matsim.smallScaleCommercialTrafficGeneration.data.CommercialTourSpecifications; import org.matsim.smallScaleCommercialTrafficGeneration.data.DefaultTourSpecificationsByUsingKID2002; @@ -1063,7 +1063,7 @@ public CarrierStrategyManager get() { travelDisutility, modeTravelTimes.get(TransportMode.car)); // final GenericStrategyManager strategyManager = new GenericStrategyManager<>(); - final CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); + final CarrierStrategyManager strategyManager = CarrierControllerUtils.createDefaultCarrierStrategyManager(); strategyManager.setMaxPlansPerAgent(5); { GenericPlanStrategyImpl strategy = new GenericPlanStrategyImpl<>( diff --git a/contribs/sumo/pom.xml b/contribs/sumo/pom.xml index da11bdf4865..fb52edc379c 100644 --- a/contribs/sumo/pom.xml +++ b/contribs/sumo/pom.xml @@ -16,7 +16,7 @@ org.matsim.contrib osm - ${project.version} + ${project.parent.version} diff --git a/contribs/taxi/pom.xml b/contribs/taxi/pom.xml index 33a2ceb4c42..b94a6ed2d99 100644 --- a/contribs/taxi/pom.xml +++ b/contribs/taxi/pom.xml @@ -28,17 +28,17 @@ org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib ev - 2025.0-SNAPSHOT + ${project.parent.version} org.assertj diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiChargingTask.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiChargingTask.java index 8f7f9b018ca..afb1b839bd5 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiChargingTask.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiChargingTask.java @@ -20,6 +20,7 @@ package org.matsim.contrib.etaxi; import org.matsim.contrib.evrp.ChargingTaskImpl; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; import org.matsim.contrib.taxi.schedule.TaxiTaskType; @@ -28,7 +29,7 @@ public class ETaxiChargingTask extends ChargingTaskImpl { public static final TaxiTaskType TYPE = new TaxiTaskType("CHARGING"); public ETaxiChargingTask(double beginTime, double endTime, Charger charger, ElectricVehicle ev, - double totalEnergy) { - super(TYPE, beginTime, endTime, charger, ev, totalEnergy); + double totalEnergy, ChargingStrategy chargingStrategy) { + super(TYPE, beginTime, endTime, charger, ev, totalEnergy, chargingStrategy); } } diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiScheduler.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiScheduler.java index 79999d4b140..16850cf1004 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiScheduler.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/ETaxiScheduler.java @@ -34,6 +34,7 @@ import org.matsim.contrib.dvrp.schedule.Schedules; import org.matsim.contrib.dvrp.schedule.Task; import org.matsim.contrib.ev.charging.ChargingEstimations; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithAssignmentLogic; import org.matsim.contrib.ev.fleet.ElectricVehicle; import org.matsim.contrib.ev.infrastructure.Charger; @@ -50,10 +51,13 @@ public class ETaxiScheduler extends TaxiScheduler { public static final TaxiTaskType DRIVE_TO_CHARGER = new TaxiTaskType("DRIVE_TO_CHARGER", EMPTY_DRIVE); + private final ChargingStrategy.Factory chargingStrategyFactory; + public ETaxiScheduler(TaxiConfigGroup taxiCfg, Fleet fleet, TaxiScheduleInquiry taxiScheduleInquiry, TravelTime travelTime, Supplier routerCreator, EventsManager eventsManager, - MobsimTimer mobsimTimer) { + MobsimTimer mobsimTimer, ChargingStrategy.Factory chargingStrategyFactory) { super(taxiCfg, fleet, taxiScheduleInquiry, travelTime, routerCreator, eventsManager, mobsimTimer); + this.chargingStrategyFactory = chargingStrategyFactory; } // FIXME underestimated due to the ongoing AUX/drive consumption @@ -65,12 +69,13 @@ public void scheduleCharging(DvrpVehicle vehicle, ElectricVehicle ev, Charger ch divertOrAppendDrive(schedule, vrpPath, DRIVE_TO_CHARGER); ChargingWithAssignmentLogic logic = (ChargingWithAssignmentLogic)charger.getLogic(); + ChargingStrategy strategy = chargingStrategyFactory.createStrategy(charger.getSpecification(), ev); double chargingEndTime = vrpPath.getArrivalTime() + ChargingEstimations.estimateMaxWaitTimeForNextVehicle( charger)// TODO not precise!!! - + logic.getChargingStrategy().calcRemainingTimeToCharge(ev);// TODO not precise !!! (SOC will be lower) + + strategy.calcRemainingTimeToCharge();// TODO not precise !!! (SOC will be lower) schedule.addTask(new ETaxiChargingTask(vrpPath.getArrivalTime(), chargingEndTime, charger, ev, - -logic.getChargingStrategy().calcRemainingEnergyToCharge(ev)));// TODO not precise !!! (ditto) - logic.assignVehicle(ev); + -strategy.calcRemainingEnergyToCharge(), strategy));// TODO not precise !!! (ditto) + logic.assignVehicle(ev, strategy); appendStayTask(vehicle); } diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/ETaxiModeOptimizerQSimModule.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/ETaxiModeOptimizerQSimModule.java index 5860bea3890..a713f20796c 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/ETaxiModeOptimizerQSimModule.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/ETaxiModeOptimizerQSimModule.java @@ -34,6 +34,7 @@ import org.matsim.contrib.etaxi.ETaxiActionCreator; import org.matsim.contrib.etaxi.ETaxiScheduler; import org.matsim.contrib.etaxi.util.ETaxiStayTaskEndTimeCalculator; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructure; import org.matsim.contrib.ev.infrastructure.ChargingInfrastructureUtils; import org.matsim.contrib.taxi.analysis.TaxiEventSequenceCollector; @@ -113,8 +114,9 @@ public ETaxiScheduler get() { var speedyALTFactory = new SpeedyALTFactory(); Supplier routerCreator = () -> speedyALTFactory.createPathCalculator( network, travelDisutility, travelTime); + ChargingStrategy.Factory chargingStrategyFactory = getModalInstance(ChargingStrategy.Factory.class); return new ETaxiScheduler(taxiCfg, fleet, taxiScheduleInquiry, travelTime, routerCreator, - events, timer); + events, timer, chargingStrategyFactory); } }); diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/assignment/AssignmentChargerPlugData.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/assignment/AssignmentChargerPlugData.java index 6f3a1105fc3..3d3e4b720e8 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/assignment/AssignmentChargerPlugData.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/optimizer/assignment/AssignmentChargerPlugData.java @@ -71,7 +71,7 @@ static AssignmentDestinationData create(double currentTime, Iterabl } // does not include AUX+driving for assigned vehs - double assignedWorkload = ChargingEstimations.estimateTotalTimeToCharge(logic.getChargingStrategy(), + double assignedWorkload = ChargingEstimations.estimateTotalTimeToCharge( Streams.concat(logic.getPluggedVehicles().stream(), logic.getQueuedVehicles().stream(), logic.getAssignedVehicles().stream())); diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java index 5e67a5e2105..68d20b5263b 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiBenchmark.java @@ -27,6 +27,7 @@ import org.matsim.contrib.dvrp.fleet.FleetSpecification; import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; +import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; import org.matsim.contrib.ev.EvConfigGroup; import org.matsim.contrib.ev.EvModule; @@ -34,6 +35,7 @@ import org.matsim.contrib.ev.charging.ChargingEventSequenceCollector; import org.matsim.contrib.ev.charging.ChargingLogic; import org.matsim.contrib.ev.charging.ChargingPower; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithQueueingAndAssignmentLogic; import org.matsim.contrib.ev.charging.FixedSpeedCharging; import org.matsim.contrib.ev.discharging.IdleDischargingHandler; @@ -53,6 +55,8 @@ import org.matsim.core.mobsim.qsim.AbstractQSimModule; import org.matsim.core.scenario.ScenarioUtils; +import com.google.inject.Key; + /** * For a fair and consistent benchmarking of taxi dispatching algorithms we assume that link travel times are * deterministic. To simulate this property, we remove (1) all other traffic, and (2) link capacity constraints (e.g. by @@ -111,8 +115,8 @@ protected void configureQSim() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - bind(ChargingLogic.Factory.class).toProvider(new ChargingWithQueueingAndAssignmentLogic.FactoryProvider( - charger -> new ChargeUpToMaxSocStrategy(charger, MAX_SOC))); + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingAndAssignmentLogic.Factory.class); + bind(Key.get(ChargingStrategy.Factory.class, DvrpModes.mode(mode))).toInstance(new ChargeUpToMaxSocStrategy.Factory(MAX_SOC)); //TODO switch to VariableSpeedCharging for Nissan bind(ChargingPower.Factory.class).toInstance(ev -> new FixedSpeedCharging(ev, CHARGING_SPEED_FACTOR)); bind(TemperatureService.class).toInstance(linkId -> TEMPERATURE); diff --git a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java index f5598174103..bd266b4b0f2 100644 --- a/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java +++ b/contribs/taxi/src/main/java/org/matsim/contrib/etaxi/run/RunETaxiScenario.java @@ -23,6 +23,7 @@ import org.matsim.api.core.v01.Scenario; import org.matsim.contrib.dvrp.run.DvrpConfigGroup; +import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.dvrp.run.DvrpModule; import org.matsim.contrib.dvrp.run.DvrpQSimComponents; import org.matsim.contrib.ev.EvConfigGroup; @@ -30,12 +31,13 @@ import org.matsim.contrib.ev.charging.ChargeUpToMaxSocStrategy; import org.matsim.contrib.ev.charging.ChargingLogic; import org.matsim.contrib.ev.charging.ChargingPower; +import org.matsim.contrib.ev.charging.ChargingStrategy; import org.matsim.contrib.ev.charging.ChargingWithQueueingAndAssignmentLogic; import org.matsim.contrib.ev.charging.FixedSpeedCharging; import org.matsim.contrib.ev.discharging.IdleDischargingHandler; +import org.matsim.contrib.ev.temperature.TemperatureService; import org.matsim.contrib.evrp.EvDvrpFleetQSimModule; import org.matsim.contrib.evrp.OperatingVehicleProvider; -import org.matsim.contrib.ev.temperature.TemperatureService; import org.matsim.contrib.otfvis.OTFVisLiveModule; import org.matsim.contrib.taxi.run.MultiModeTaxiConfigGroup; import org.matsim.contrib.taxi.run.TaxiConfigGroup; @@ -48,6 +50,8 @@ import org.matsim.core.scenario.ScenarioUtils; import org.matsim.vis.otfvis.OTFVisConfigGroup; +import com.google.inject.Key; + public class RunETaxiScenario { private static final double CHARGING_SPEED_FACTOR = 1.5; // > 1 in this example private static final double MAX_SOC = 0.8; // charge up to 80% SOC @@ -91,11 +95,14 @@ protected void configureQSim() { controler.addOverridingModule(new AbstractModule() { @Override public void install() { - bind(ChargingLogic.Factory.class).toProvider(new ChargingWithQueueingAndAssignmentLogic.FactoryProvider( - charger -> new ChargeUpToMaxSocStrategy(charger, MAX_SOC))); + bind(ChargingLogic.Factory.class).to(ChargingWithQueueingAndAssignmentLogic.Factory.class); //TODO switch to VariableSpeedCharging for Nissan bind(ChargingPower.Factory.class).toInstance(ev -> new FixedSpeedCharging(ev, CHARGING_SPEED_FACTOR)); bind(TemperatureService.class).toInstance(linkId -> TEMPERATURE); + + for (TaxiConfigGroup taxiCfg : multiModeTaxiConfig.getModalElements()) { + bind(Key.get(ChargingStrategy.Factory.class, DvrpModes.mode(taxiCfg.getMode()))).toInstance(new ChargeUpToMaxSocStrategy.Factory(MAX_SOC)); + } } }); diff --git a/contribs/vsp/pom.xml b/contribs/vsp/pom.xml index 8f4e01bec37..29cbf1de5d6 100644 --- a/contribs/vsp/pom.xml +++ b/contribs/vsp/pom.xml @@ -22,59 +22,59 @@ org.matsim.contrib multimodal - 2025.0-SNAPSHOT + ${project.parent.version} compile org.matsim.contrib taxi - 2025.0-SNAPSHOT + ${project.parent.version} compile org.matsim.contrib dvrp - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib parking - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib freight - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib accessibility - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib emissions - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib minibus - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib common - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib analysis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib informed-mode-choice - 2025.0-SNAPSHOT + ${project.parent.version} @@ -97,17 +97,17 @@ org.matsim.contrib otfvis - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib noise - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib signals - 2025.0-SNAPSHOT + ${project.parent.version} org.openstreetmap.osmosis @@ -145,7 +145,7 @@ org.matsim.contrib cadyts-integration - 2025.0-SNAPSHOT + ${project.parent.version} org.apache.poi @@ -174,12 +174,12 @@ org.matsim matsim-examples - 2025.0-SNAPSHOT + ${project.parent.version} org.matsim.contrib drt - 2025.0-SNAPSHOT + ${project.parent.version} org.openjfx diff --git a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanVehicleChargingHandler.java b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanVehicleChargingHandler.java index 592722998fe..8e40eb18120 100644 --- a/contribs/vsp/src/main/java/playground/vsp/ev/UrbanVehicleChargingHandler.java +++ b/contribs/vsp/src/main/java/playground/vsp/ev/UrbanVehicleChargingHandler.java @@ -61,13 +61,16 @@ class UrbanVehicleChargingHandler private final ElectricFleet electricFleet; private final ImmutableListMultimap, Charger> chargersAtLinks; + private final ChargingStrategy.Factory chargingStrategyFactory; + private Map, Map, Tuple, Id>>> chargingProcedures = new HashMap<>(); @Inject - UrbanVehicleChargingHandler(ChargingInfrastructure chargingInfrastructure, ElectricFleet electricFleet) { + UrbanVehicleChargingHandler(ChargingInfrastructure chargingInfrastructure, ElectricFleet electricFleet, ChargingStrategy.Factory chargingStrategyFactory) { this.chargingInfrastructure = chargingInfrastructure; this.electricFleet = electricFleet; this.chargersAtLinks = ChargingInfrastructureUtils.getChargersAtLinks(chargingInfrastructure ); + this.chargingStrategyFactory = chargingStrategyFactory; } /** @@ -89,7 +92,8 @@ public void handleEvent(ActivityStartEvent event) { .findAny() .get(); - charger.getLogic().addVehicle(ev, event.getTime()); + ChargingStrategy strategy = chargingStrategyFactory.createStrategy(charger.getSpecification(), ev); + charger.getLogic().addVehicle(ev, strategy, event.getTime()); Map, Tuple, Id>> proceduresOnLink = this.chargingProcedures.get(event.getLinkId()); if(proceduresOnLink != null && proceduresOnLink.containsKey(event.getPersonId())){ throw new RuntimeException("person " + event.getPersonId() + " tries to charge 2 vehicles at the same time on link " + event.getLinkId() + diff --git a/matsim/src/main/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinks.java b/matsim/src/main/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinks.java index d0532315137..02ea9efcf79 100644 --- a/matsim/src/main/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinks.java +++ b/matsim/src/main/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinks.java @@ -20,7 +20,6 @@ package org.matsim.pt.utils; -import com.google.common.annotations.Beta; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; @@ -40,11 +39,8 @@ * is assigned to a loop link, located in a node with the same coordinates as the stop. * The stop facility ID is used for node and link IDs. * - * @author mrieser, davibicudo - * - * @implNote THis functionality might be merged with {@link CreatePseudoNetwork}. + * @author mrieser, davibicudo, rakow */ -@Beta public class CreatePseudoNetworkWithLoopLinks { private final TransitSchedule schedule; @@ -82,23 +78,29 @@ public void createNetwork() { List> toBeRemoved = new LinkedList<>(); for (TransitLine tLine : this.schedule.getTransitLines().values()) { for (TransitRoute tRoute : tLine.getRoutes().values()) { - ArrayList> routeLinks = new ArrayList<>(); + + if (tRoute.getStops().size() < 2) { + System.err.println("Line " + tLine.getId() + " route " + tRoute.getId() + " has less than two stops. Removing this route from schedule."); + toBeRemoved.add(new Tuple<>(tLine, tRoute)); + continue; + } + + List> routeLinks = new ArrayList<>(); TransitRouteStop prevStop = null; + for (TransitRouteStop stop : tRoute.getStops()) { if (prevStop != null) { Link link = getNetworkLink(prevStop, stop); routeLinks.add(link.getId()); } + + // Add the loop links of all stops to the route + routeLinks.add(getLoopLink(stop.getStopFacility()).getId()); prevStop = stop; } - if (!routeLinks.isEmpty()) { - NetworkRoute route = RouteUtils.createNetworkRoute(routeLinks); - tRoute.setRoute(route); - } else { - System.err.println("Line " + tLine.getId() + " route " + tRoute.getId() + " has less than two stops. Removing this route from schedule."); - toBeRemoved.add(new Tuple<>(tLine, tRoute)); - } + NetworkRoute route = RouteUtils.createNetworkRoute(routeLinks); + tRoute.setRoute(route); } } @@ -114,6 +116,14 @@ private void createStopNodesAndLoopLinks() { this.nodes.put(stop, node); Link loopLink = this.network.getFactory().createLink(Id.createLinkId (this.prefix + stop.getId()), node, node); + // Loop links needs to have a length so that the travel time is not zero + loopLink.setLength(1); + loopLink.setFreespeed(linkFreeSpeed); + loopLink.setCapacity(linkCapacity); + // Ensure enough vehicles can be placed on the loop link + loopLink.setNumberOfLanes(linkCapacity); + loopLink.setAllowedModes(transitModes); + stop.setLinkId(loopLink.getId()); this.network.addLink(loopLink); Tuple connection = new Tuple<>(node, node); @@ -121,6 +131,15 @@ private void createStopNodesAndLoopLinks() { } } + /** + * Get the loop link for a stop facility. + */ + private Link getLoopLink(final TransitStopFacility stop) { + Node node = this.nodes.get(stop); + Tuple connection = new Tuple<>(node, node); + return this.links.get(connection); + } + private Link getNetworkLink(final TransitRouteStop fromStop, final TransitRouteStop toStop) { TransitStopFacility fromFacility = fromStop.getStopFacility(); TransitStopFacility toFacility = toStop.getStopFacility(); @@ -137,13 +156,15 @@ private Link createAndAddLink(Tuple connection) { Node fromNode = connection.getFirst(); Node toNode = connection.getSecond(); Link link; - link = this.network.getFactory().createLink(Id.createLinkId(this.prefix + fromNode.getId() + "-" + toNode.getId()), fromNode, - toNode); - link.setLength(CoordUtils.calcEuclideanDistance(fromNode.getCoord(), toNode.getCoord())); + link = this.network.getFactory().createLink(Id.createLinkId(fromNode.getId() + "-" + toNode.getId()), + fromNode, toNode); + double dist = CoordUtils.calcEuclideanDistance(fromNode.getCoord(), toNode.getCoord()); + link.setLength(dist); link.setFreespeed(linkFreeSpeed); link.setCapacity(linkCapacity); link.setNumberOfLanes(1); + this.network.addLink(link); link.setAllowedModes(this.transitModes); this.links.put(connection, link); diff --git a/matsim/src/main/java/org/matsim/vehicles/VehicleUtils.java b/matsim/src/main/java/org/matsim/vehicles/VehicleUtils.java index 7c263b086e3..d149ad07eb2 100644 --- a/matsim/src/main/java/org/matsim/vehicles/VehicleUtils.java +++ b/matsim/src/main/java/org/matsim/vehicles/VehicleUtils.java @@ -299,16 +299,24 @@ public static void setAccessTime(VehicleType vehicleType, double accessTime) { vehicleType.getAttributes().putAttribute(ACCESSTIME, accessTime); } + /** + * @deprecated use getFuelConsumptionPerMeter instead + */ + @Deprecated public static Double getFuelConsumption(VehicleType vehicleType) { - return getFuelConsumption(vehicleType.getEngineInformation()); + return getFuelConsumptionLitersPerMeter(vehicleType.getEngineInformation()); } + /** + * @deprecated use setFuelConsumptionPerMeter instead + */ + @Deprecated public static void setFuelConsumption(VehicleType vehicleType, double literPerMeter) { - setFuelConsumption(vehicleType.getEngineInformation(), literPerMeter); + setFuelConsumptionLitersPerMeter(vehicleType.getEngineInformation(), literPerMeter); } //******** EngineInformation attributes ************ - + //TODO create enum for fuel type public static String getHbefaTechnology( EngineInformation ei ){ return (String) ei.getAttributes().getAttribute( HBEFA_TECHNOLOGY ) ; } @@ -345,6 +353,14 @@ public static void setEnergyConsumptionKWhPerMeter(EngineInformation engineInfor engineInformation.getAttributes().putAttribute(ENERGYCONSUMPTION, energyConsumptionKWhPerMeter); } + public static Double getFuelConsumptionLitersPerMeter(EngineInformation engineInformation) { + return (Double) engineInformation.getAttributes().getAttribute(FUELCONSUMPTION); + } + + public static void setFuelConsumptionLitersPerMeter(EngineInformation engineInformation, double fuelConsumptionLitersPerMeter) { + engineInformation.getAttributes().putAttribute(FUELCONSUMPTION, fuelConsumptionLitersPerMeter); + } + public static Double getEnergyCapacity(EngineInformation engineInformation) { return (Double) engineInformation.getAttributes().getAttribute(ENERGYCAPACITY); } @@ -377,21 +393,33 @@ public static Vehicle createVehicle( Id id , VehicleType type ){ return new VehicleImpl( id , type ); } + /** + * @deprecated use getHbefaTechnology instead + */ @Deprecated static EngineInformation.FuelType getFuelType(EngineInformation engineInformation ){ return (EngineInformation.FuelType) engineInformation.getAttributes().getAttribute( FUEL_TYPE ); } + /** + * @deprecated use setHbefaTechnology instead + */ @Deprecated static void setFuelType(EngineInformation engineInformation, EngineInformation.FuelType fuelType ){ engineInformation.getAttributes().putAttribute( FUEL_TYPE, fuelType); } + /** + * @Deprecated use getFuelConsumptionPerMeter instead + */ @Deprecated static Double getFuelConsumption(EngineInformation engineInformation ){ return (Double) engineInformation.getAttributes().getAttribute( FUELCONSUMPTION ); } + /** + * @Deprecated use setFuelConsumptionPerMeter instead + */ @Deprecated static void setFuelConsumption(EngineInformation engineInformation, double fuelConsumption ){ engineInformation.getAttributes().putAttribute( FUELCONSUMPTION, fuelConsumption); diff --git a/matsim/src/test/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinksTest.java b/matsim/src/test/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinksTest.java new file mode 100644 index 00000000000..431c0c87bcd --- /dev/null +++ b/matsim/src/test/java/org/matsim/pt/utils/CreatePseudoNetworkWithLoopLinksTest.java @@ -0,0 +1,28 @@ +package org.matsim.pt.utils; + +import org.junit.jupiter.api.Test; +import org.matsim.api.core.v01.Scenario; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.scenario.ScenarioUtils; + +import static org.assertj.core.api.Assertions.assertThat; + +class CreatePseudoNetworkWithLoopLinksTest { + + @Test + void createValidSchedule() { + + Scenario scenario = ScenarioUtils.loadScenario(ConfigUtils.loadConfig("test/scenarios/pt-tutorial/0.config.xml")); + + CreatePseudoNetworkWithLoopLinks creator = new CreatePseudoNetworkWithLoopLinks(scenario.getTransitSchedule(), scenario.getNetwork(), "pt_"); + creator.createNetwork(); + + + TransitScheduleValidator.ValidationResult result = TransitScheduleValidator.validateAll(scenario.getTransitSchedule(), scenario.getNetwork()); + + assertThat(result.getWarnings()).isEmpty(); + assertThat(result.getErrors()).isEmpty(); + assertThat(result.isValid()).isTrue(); + + } +}