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..5483167fcdf 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; @@ -85,8 +86,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 +101,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 { @@ -183,6 +203,13 @@ public Integer call() throws Exception { Scenario ptScenario = getScenarioWithPseudoPtNetworkAndTransitVehicles(network, scenario.getTransitSchedule(), "pt_"); + for (TransitLine line : new ArrayList<>(scenario.getTransitSchedule().getTransitLines().values())) { + if (line.getRoutes().isEmpty()) { + log.warn("Line {} with no routes removed.", line.getId()); + scenario.getTransitSchedule().removeTransitLine(line); + } + } + if (validate) { //Check schedule and network TransitScheduleValidator.ValidationResult checkResult = TransitScheduleValidator.validateAll(ptScenario.getTransitSchedule(), ptScenario.getNetwork()); @@ -237,14 +264,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 @@ -449,8 +481,12 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network // so we need to add time for passengers to board and alight double minStopTime = 30.0; + List> routeIds = new LinkedList<>(); + routeIds.add(route.getRoute().getStartLinkId()); + routeIds.addAll(route.getRoute().getLinkIds()); + routeIds.add(route.getRoute().getEndLinkId()); + for (int i = 1; i < routeStops.size(); i++) { - // TODO cater for loop link at first stop? Seems to just work without. TransitRouteStop routeStop = routeStops.get(i); // if there is no departure offset set (or infinity), it is the last stop of the line, // so we don't need to care about the stop duration @@ -462,8 +498,23 @@ private static Scenario getScenarioWithPseudoPtNetworkAndTransitVehicles(Network // Math.max to avoid negative values of travelTime double travelTime = Math.max(1, routeStop.getArrivalOffset().seconds() - lastDepartureOffset - 1.0 - (stopDuration >= minStopTime ? 0 : (minStopTime - stopDuration))); - Link link = network.getLinks().get(routeStop.getStopFacility().getLinkId()); - increaseLinkFreespeedIfLower(link, link.getLength() / travelTime); + + + Id stopLink = routeStop.getStopFacility().getLinkId(); + List> subRoute = new LinkedList<>(); + do { + Id linkId = routeIds.removeFirst(); + subRoute.add(linkId); + } while (!subRoute.contains(stopLink)); + + List links = subRoute.stream().map(scenario.getNetwork().getLinks()::get) + .toList(); + + double length = links.stream().mapToDouble(Link::getLength).sum(); + + for (Link link : links) { + increaseLinkFreespeedIfLower(link, length / travelTime); + } lastDepartureOffset = routeStop.getDepartureOffset().seconds(); } @@ -481,20 +532,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/application/prepare/scenario/CreateScenarioCutOut.java b/contribs/application/src/main/java/org/matsim/application/prepare/scenario/CreateScenarioCutOut.java index 4dcd8a6bf5a..909d311d64f 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/scenario/CreateScenarioCutOut.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/scenario/CreateScenarioCutOut.java @@ -590,9 +590,12 @@ public void run(Person person) { } // Remove all unselected plans because these are not handled - person.getPlans().stream() - .filter(p -> p != person.getSelectedPlan()) - .forEach(person::removePlan); + List plans = new ArrayList<>(person.getPlans()); + for(Plan p : plans){ + if (p != person.getSelectedPlan()){ + person.removePlan(p); + } + } } 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/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategy.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategy.java index 4e06666ed05..f3892019345 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategy.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategy.java @@ -40,6 +40,9 @@ */ public class MinCostFlowRebalancingStrategy implements RebalancingStrategy { + public static final String REBALANCING_ZONAL_TARGET_ALPHA = "rebalalpha"; + public static final String REBALANCING_ZONAL_TARGET_BETA = "rebalbeta"; + private final RebalancingTargetCalculator rebalancingTargetCalculator; private final ZoneSystem zonalSystem; private final Fleet fleet; @@ -68,18 +71,37 @@ public List calcRelocations(Stream rebalancab return calculateMinCostRelocations(time, rebalancableVehiclesPerZone, soonIdleVehiclesPerZone); } - private List calculateMinCostRelocations(double time, + List calculateMinCostRelocations(double time, Map> rebalancableVehiclesPerZone, Map> soonIdleVehiclesPerZone) { ToDoubleFunction targetFunction = rebalancingTargetCalculator.calculate(time, rebalancableVehiclesPerZone); var minCostFlowRebalancingStrategyParams = (MinCostFlowRebalancingStrategyParams)params.getRebalancingStrategyParams(); - double alpha = minCostFlowRebalancingStrategyParams.targetAlpha; - double beta = minCostFlowRebalancingStrategyParams.targetBeta; - List vehicleSurpluses = zonalSystem.getZones().values().stream().map(z -> { + List vehicleSurpluses = zonalSystem.getZones().values().stream().map(z -> { + double alpha; + double beta; int rebalancable = rebalancableVehiclesPerZone.getOrDefault(z, List.of()).size(); int soonIdle = soonIdleVehiclesPerZone.getOrDefault(z, List.of()).size(); + + switch (minCostFlowRebalancingStrategyParams.targetCoefficientSource) { + case Static -> { + alpha = minCostFlowRebalancingStrategyParams.targetAlpha; + beta = minCostFlowRebalancingStrategyParams.targetBeta; + } + case FromZoneAttribute -> { + alpha = (Double) z.getAttributes().getAttribute(REBALANCING_ZONAL_TARGET_ALPHA); + beta = (Double) z.getAttributes().getAttribute(REBALANCING_ZONAL_TARGET_BETA); + } + case FromZoneAttributeOrStatic -> { + Object alphaAttribute = z.getAttributes().getAttribute(REBALANCING_ZONAL_TARGET_ALPHA); + alpha = alphaAttribute == null ? minCostFlowRebalancingStrategyParams.targetAlpha : (Double) alphaAttribute; + Object betaAttribute = z.getAttributes().getAttribute(REBALANCING_ZONAL_TARGET_BETA); + beta = betaAttribute == null ? minCostFlowRebalancingStrategyParams.targetBeta : (Double) betaAttribute; + } + default -> throw new IllegalStateException("Unknown target coefficient source " + minCostFlowRebalancingStrategyParams.targetCoefficientSource); + } + int target = (int)Math.floor(alpha * targetFunction.applyAsDouble(z) + beta); int surplus = Math.min(rebalancable + soonIdle - target, rebalancable); return new DrtZoneVehicleSurplus(z, surplus); diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyParams.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyParams.java index 7c0a72e3a07..a09867d4785 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyParams.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyParams.java @@ -56,6 +56,19 @@ public enum RebalancingTargetCalculatorType { @NotNull public RebalancingTargetCalculatorType rebalancingTargetCalculatorType = RebalancingTargetCalculatorType.EstimatedDemand; + + public enum TargetCoefficientSource { + Static, FromZoneAttribute, FromZoneAttributeOrStatic + } + + @Parameter + @Comment("Defines whether the alpha and beta of the target function should be" + + " [Static] or [FromZoneAttribute] in which case alpha and beta can be provided per zone as an attribute." + + " [FromZoneAttributeOrStatic] will fall back to the static coefficients if no attribute is found for a given zone." + + " Use " + MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_ALPHA + " and " + MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_BETA + + " to set values accordingly.") + public TargetCoefficientSource targetCoefficientSource = TargetCoefficientSource.Static; + public enum ZonalDemandEstimatorType {PreviousIterationDemand, None} @Parameter 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/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java index 7f43fd42d8b..cca630fcf0c 100644 --- a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/demandestimator/PreviousIterationDrtDemandEstimatorTest.java @@ -199,9 +199,9 @@ static Network createNetwork() { network.addNode(b); Link ab = network.getFactory().createLink(Id.createLinkId("link_1"), a, b); - Link bc = network.getFactory().createLink(Id.createLinkId("link_2"), b, a); + Link ba = network.getFactory().createLink(Id.createLinkId("link_2"), b, a); network.addLink(ab); - network.addLink(bc); + network.addLink(ba); return network; } } diff --git a/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyTest.java b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyTest.java new file mode 100644 index 00000000000..8aba7eefc00 --- /dev/null +++ b/contribs/drt/src/test/java/org/matsim/contrib/drt/optimizer/rebalancing/mincostflow/MinCostFlowRebalancingStrategyTest.java @@ -0,0 +1,279 @@ +package org.matsim.contrib.drt.optimizer.rebalancing.mincostflow; + +import com.google.common.collect.ImmutableMap; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.locationtech.jts.geom.prep.PreparedPolygon; +import org.matsim.api.core.v01.Coord; +import org.matsim.api.core.v01.Id; +import org.matsim.api.core.v01.TransportMode; +import org.matsim.api.core.v01.events.PersonDepartureEvent; +import org.matsim.api.core.v01.network.Link; +import org.matsim.api.core.v01.network.Network; +import org.matsim.api.core.v01.network.Node; +import org.matsim.contrib.common.zones.Zone; +import org.matsim.contrib.common.zones.ZoneImpl; +import org.matsim.contrib.common.zones.ZoneSystem; +import org.matsim.contrib.common.zones.ZoneSystemImpl; +import org.matsim.contrib.drt.analysis.zonal.MostCentralDrtZoneTargetLinkSelector; +import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams; +import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingStrategy; +import org.matsim.contrib.drt.optimizer.rebalancing.demandestimator.PreviousIterationDrtDemandEstimator; +import org.matsim.contrib.drt.optimizer.rebalancing.targetcalculator.DemandEstimatorAsTargetCalculator; +import org.matsim.contrib.drt.run.DrtConfigGroup; +import org.matsim.contrib.dvrp.fleet.*; +import org.matsim.core.network.NetworkUtils; +import org.matsim.core.utils.geometry.GeometryUtils; + +import java.util.*; + +public class MinCostFlowRebalancingStrategyTest { + + private static final int ESTIMATION_PERIOD = 1800; + + private final Network network = createNetwork(); + + private final Link link1 = network.getLinks().get(Id.createLinkId("link_1")); + private final Link link2 = network.getLinks().get(Id.createLinkId("link_2")); + + private final Zone zone1 = new ZoneImpl( + Id.create("zone_1", Zone.class), + new PreparedPolygon(GeometryUtils.createGeotoolsPolygon( + List.of( + new Coord(0, 0), + new Coord(0, 500), + new Coord(500, 500), + new Coord(500, 0), + new Coord(0, 0) + ))), "dummy"); + + private final Zone zone2 = new ZoneImpl( + Id.create("zone_2", Zone.class), + new PreparedPolygon(GeometryUtils.createGeotoolsPolygon( + List.of( + new Coord(500, 0), + new Coord(500, 500), + new Coord(1000, 500), + new Coord(1000, 0), + new Coord(500, 0) + ))), "dummy"); + + private final ZoneSystem zonalSystem = new ZoneSystemImpl(List.of(zone1, zone2), coord -> { + if (coord == link1.getToNode().getCoord()) { + return Optional.of(zone1); + } else if (coord == link2.getToNode().getCoord()) { + return Optional.of(zone2); + } else { + throw new RuntimeException(); + } + }, network); + + + @Test + void testEmptyDemandAndTarget() { + PreviousIterationDrtDemandEstimator estimator = createEstimator(); + DemandEstimatorAsTargetCalculator targetCalculator = new DemandEstimatorAsTargetCalculator(estimator, ESTIMATION_PERIOD); + + RebalancingParams rebalancingParams = new RebalancingParams(); + MinCostFlowRebalancingStrategyParams minCostFlowRebalancingStrategyParams = new MinCostFlowRebalancingStrategyParams(); + minCostFlowRebalancingStrategyParams.targetAlpha = 1.; + minCostFlowRebalancingStrategyParams.targetBeta = 0.; + rebalancingParams.addParameterSet(minCostFlowRebalancingStrategyParams); + + AggregatedMinCostRelocationCalculator relocationCalculator = new AggregatedMinCostRelocationCalculator(new MostCentralDrtZoneTargetLinkSelector(zonalSystem)); + MinCostFlowRebalancingStrategy strategy = new MinCostFlowRebalancingStrategy(targetCalculator, + zonalSystem, createEmptyFleet(), relocationCalculator, rebalancingParams); + + Map> rebalanceableVehicles = new HashMap<>(); + List relocations = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations.isEmpty()); + } + + @Test + void testDemandWithoutSurplus() { + PreviousIterationDrtDemandEstimator estimator = createEstimator(); + DemandEstimatorAsTargetCalculator targetCalculator = new DemandEstimatorAsTargetCalculator(estimator, ESTIMATION_PERIOD); + + RebalancingParams rebalancingParams = new RebalancingParams(); + MinCostFlowRebalancingStrategyParams minCostFlowRebalancingStrategyParams = new MinCostFlowRebalancingStrategyParams(); + minCostFlowRebalancingStrategyParams.targetAlpha = 1.; + minCostFlowRebalancingStrategyParams.targetBeta = 0.; + rebalancingParams.addParameterSet(minCostFlowRebalancingStrategyParams); + + AggregatedMinCostRelocationCalculator relocationCalculator = new AggregatedMinCostRelocationCalculator(new MostCentralDrtZoneTargetLinkSelector(zonalSystem)); + MinCostFlowRebalancingStrategy strategy = new MinCostFlowRebalancingStrategy(targetCalculator, + zonalSystem, createEmptyFleet(), relocationCalculator, rebalancingParams); + + //time bin 0-1800 + estimator.handleEvent(departureEvent(100, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(200, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(500, link2, TransportMode.drt)); + estimator.handleEvent(departureEvent(1500, link1, TransportMode.drt)); + estimator.reset(1); + + Map> rebalanceableVehicles = new HashMap<>(); + List relocations = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations.isEmpty()); + } + + @Test + void testDemandWithSurplus() { + PreviousIterationDrtDemandEstimator estimator = createEstimator(); + DemandEstimatorAsTargetCalculator targetCalculator = new DemandEstimatorAsTargetCalculator(estimator, ESTIMATION_PERIOD); + + RebalancingParams rebalancingParams = new RebalancingParams(); + MinCostFlowRebalancingStrategyParams minCostFlowRebalancingStrategyParams = new MinCostFlowRebalancingStrategyParams(); + minCostFlowRebalancingStrategyParams.targetAlpha = 1.; + minCostFlowRebalancingStrategyParams.targetBeta = 0.; + rebalancingParams.addParameterSet(minCostFlowRebalancingStrategyParams); + + AggregatedMinCostRelocationCalculator relocationCalculator = new AggregatedMinCostRelocationCalculator(new MostCentralDrtZoneTargetLinkSelector(zonalSystem)); + MinCostFlowRebalancingStrategy strategy = new MinCostFlowRebalancingStrategy(targetCalculator, + zonalSystem, createEmptyFleet(), relocationCalculator, rebalancingParams); + + // 3 expected trips in zone 1 + estimator.handleEvent(departureEvent(100, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(200, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(300, link1, TransportMode.drt)); + // 1 expected trip in zone 2 + estimator.handleEvent(departureEvent(100, link2, TransportMode.drt)); + estimator.reset(1); + + Map> rebalanceableVehicles = new HashMap<>(); + + // 4 vehicles in zone 1 (surplus = 1) + List rebalanceableVehiclesZone1 = new ArrayList<>(); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a1", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a2", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a3", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a4", DvrpVehicle.class), link1)); + rebalanceableVehicles.put(zone1, rebalanceableVehiclesZone1); + + List relocations = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations.size()).isEqualTo(1); + Assertions.assertThat(relocations.getFirst().link.getId()).isEqualTo(link2.getId()); + + rebalanceableVehicles.clear(); + + // 5 vehicles in zone 1 (surplus = 2) + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a1", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a2", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a3", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a4", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a5", DvrpVehicle.class), link1)); + rebalanceableVehicles.put(zone1, rebalanceableVehiclesZone1); + + //set alpha to 2 -> send two vehicles to zone 2 + minCostFlowRebalancingStrategyParams.targetAlpha = 2.; + List relocations2 = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations2.size()).isEqualTo(2); + Assertions.assertThat(relocations2.getFirst().link.getId()).isEqualTo(link2.getId()); + Assertions.assertThat(relocations2.getLast().link.getId()).isEqualTo(link2.getId()); + } + + @Test + void testDemandWithSurplusZoneBasedTargetRates() { + + // set attributes + zone1.getAttributes().putAttribute(MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_ALPHA, 0.); + zone1.getAttributes().putAttribute(MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_BETA, 0.); + zone2.getAttributes().putAttribute(MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_ALPHA, 1.); + zone2.getAttributes().putAttribute(MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_BETA, 0.); + + + PreviousIterationDrtDemandEstimator estimator = createEstimator(); + DemandEstimatorAsTargetCalculator targetCalculator = new DemandEstimatorAsTargetCalculator(estimator, ESTIMATION_PERIOD); + + RebalancingParams rebalancingParams = new RebalancingParams(); + MinCostFlowRebalancingStrategyParams minCostFlowRebalancingStrategyParams = new MinCostFlowRebalancingStrategyParams(); + minCostFlowRebalancingStrategyParams.targetCoefficientSource = MinCostFlowRebalancingStrategyParams.TargetCoefficientSource.FromZoneAttribute; + rebalancingParams.addParameterSet(minCostFlowRebalancingStrategyParams); + + AggregatedMinCostRelocationCalculator relocationCalculator = new AggregatedMinCostRelocationCalculator(new MostCentralDrtZoneTargetLinkSelector(zonalSystem)); + MinCostFlowRebalancingStrategy strategy = new MinCostFlowRebalancingStrategy(targetCalculator, + zonalSystem, createEmptyFleet(), relocationCalculator, rebalancingParams); + + // 3 expected trips in zone 1 + estimator.handleEvent(departureEvent(100, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(200, link1, TransportMode.drt)); + estimator.handleEvent(departureEvent(300, link1, TransportMode.drt)); + // 1 expected trip in zone 2 + estimator.handleEvent(departureEvent(100, link2, TransportMode.drt)); + estimator.reset(1); + + Map> rebalanceableVehicles = new HashMap<>(); + + // 4 vehicles in zone 1 (surplus = 1) + List rebalanceableVehiclesZone1 = new ArrayList<>(); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a1", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a2", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a3", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a4", DvrpVehicle.class), link1)); + rebalanceableVehicles.put(zone1, rebalanceableVehiclesZone1); + + List relocations = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations.size()).isEqualTo(1); + Assertions.assertThat(relocations.getFirst().link.getId()).isEqualTo(link2.getId()); + + rebalanceableVehicles.clear(); + + // 5 vehicles in zone 1 (surplus = 2) + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a1", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a2", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a3", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a4", DvrpVehicle.class), link1)); + rebalanceableVehiclesZone1.add(getDvrpVehicle(Id.create("a5", DvrpVehicle.class), link1)); + rebalanceableVehicles.put(zone1, rebalanceableVehiclesZone1); + + //set alpha to 2 -> send two vehicles to zone 2 + zone2.getAttributes().putAttribute(MinCostFlowRebalancingStrategy.REBALANCING_ZONAL_TARGET_ALPHA, 2.); + List relocations2 = strategy.calculateMinCostRelocations(0, rebalanceableVehicles, Collections.emptyMap()); + Assertions.assertThat(relocations2.size()).isEqualTo(2); + Assertions.assertThat(relocations2.getFirst().link.getId()).isEqualTo(link2.getId()); + Assertions.assertThat(relocations2.getLast().link.getId()).isEqualTo(link2.getId()); + } + + private DvrpVehicleImpl getDvrpVehicle(Id id, Link link) { + return new DvrpVehicleImpl( + ImmutableDvrpVehicleSpecification.newBuilder() + .id(id) + .capacity(0) + .serviceBeginTime(0) + .serviceEndTime(0) + .startLinkId(link.getId()) + .build(), link); + } + + private static Fleet createEmptyFleet() { + return () -> ImmutableMap., DvrpVehicle>builder().build(); + } + + + private PreviousIterationDrtDemandEstimator createEstimator() { + RebalancingParams rebalancingParams = new RebalancingParams(); + rebalancingParams.interval = ESTIMATION_PERIOD; + + DrtConfigGroup drtConfigGroup = new DrtConfigGroup(); + drtConfigGroup.addParameterSet(rebalancingParams); + + return new PreviousIterationDrtDemandEstimator(zonalSystem, drtConfigGroup, ESTIMATION_PERIOD); + } + + private PersonDepartureEvent departureEvent(double time, Link link, String mode) { + return new PersonDepartureEvent(time, null, link.getId(), mode, mode); + } + + static Network createNetwork() { + Network network = NetworkUtils.createNetwork(); + Node a = network.getFactory().createNode(Id.createNodeId("a"), new Coord(0,0)); + Node b = network.getFactory().createNode(Id.createNodeId("b"), new Coord(500,0)); + network.addNode(a); + network.addNode(b); + + Link ab = network.getFactory().createLink(Id.createLinkId("link_1"), a, b); + Link ba = network.getFactory().createLink(Id.createLinkId("link_2"), b, a); + network.addLink(ab); + network.addLink(ba); + return network; + } +} 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/dynagent/DynAgent.java b/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/DynAgent.java index 8915326d992..d7c15d7552f 100644 --- a/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/DynAgent.java +++ b/contribs/dvrp/src/main/java/org/matsim/contrib/dynagent/DynAgent.java @@ -19,8 +19,6 @@ package org.matsim.contrib.dynagent; -import java.util.List; - import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.events.ActivityEndEvent; import org.matsim.api.core.v01.events.ActivityStartEvent; @@ -40,6 +38,8 @@ import org.matsim.pt.transitSchedule.api.TransitStopFacility; import org.matsim.vehicles.Vehicle; +import java.util.List; + public final class DynAgent implements MobsimDriverPassengerAgent { private final DynAgentLogic agentLogic; @@ -83,11 +83,11 @@ private void computeNextAction(DynAction oldDynAction, double now) { DynAction nextDynAction = agentLogic.computeNextAction(oldDynAction, now); if (nextDynAction instanceof DynActivity) { - dynActivity = (DynActivity)nextDynAction; + dynActivity = (DynActivity) nextDynAction; state = MobsimAgent.State.ACTIVITY; events.processEvent(new ActivityStartEvent(now, id, currentLinkId, null, dynActivity.getActivityType())); } else { - dynLeg = (DynLeg)nextDynAction; + dynLeg = (DynLeg) nextDynAction; state = MobsimAgent.State.LEG; } } @@ -145,7 +145,7 @@ public String getMode() { // VehicleUsingAgent @Override public final Id getPlannedVehicleId() { - Id vehId = ((DriverDynLeg)dynLeg).getPlannedVehicleId(); + Id vehId = ((DriverDynLeg) dynLeg).getPlannedVehicleId(); // according to BasicPlanAgentImpl return vehId != null ? vehId : Id.create(id, Vehicle.class); } @@ -177,13 +177,13 @@ public Id getDestinationLinkId() { // DriverAgent @Override public Id chooseNextLinkId() { - return ((DriverDynLeg)dynLeg).getNextLinkId(); + return ((DriverDynLeg) dynLeg).getNextLinkId(); } // DriverAgent @Override public void notifyMoveOverNode(Id newLinkId) { - ((DriverDynLeg)dynLeg).movedOverNode(newLinkId); + ((DriverDynLeg) dynLeg).movedOverNode(newLinkId); currentLinkId = newLinkId; } @@ -226,26 +226,28 @@ public boolean isWantingToArriveOnCurrentLink() { // PTPassengerAgent @Override public boolean getEnterTransitRoute(TransitLine line, TransitRoute transitRoute, List stopsToCome, - TransitVehicle transitVehicle) { - return ((PTPassengerDynLeg)dynLeg).getEnterTransitRoute(line, transitRoute, stopsToCome, transitVehicle); + TransitVehicle transitVehicle) { + return ((PTPassengerDynLeg) dynLeg).getEnterTransitRoute(line, transitRoute, stopsToCome, transitVehicle); } // PTPassengerAgent + // yyyy seems a bit odd, that this and the following methods are implemented for DynAgent as not every DynAgent is a PTPassengerAgent. paul, + // nov'24 @Override public boolean getExitAtStop(TransitStopFacility stop) { - return ((PTPassengerDynLeg)dynLeg).getExitAtStop(stop); + return ((PTPassengerDynLeg) dynLeg).getExitAtStop(stop); } // PTPassengerAgent @Override public Id getDesiredAccessStopId() { - return ((PTPassengerDynLeg)dynLeg).getDesiredAccessStopId(); + return ((PTPassengerDynLeg) dynLeg).getDesiredAccessStopId(); } // PTPassengerAgent @Override public Id getDesiredDestinationStopId() { - return ((PTPassengerDynLeg)dynLeg).getDesiredDestinationStopId(); + return ((PTPassengerDynLeg) dynLeg).getDesiredDestinationStopId(); } // PTPassengerAgent 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..1f81bac495c 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)); @@ -57,5 +54,18 @@ public void install() { // this.addMobsimListenerBinding().to( ChargingHandler.class ).in( Singleton.class ); // does not work since ChargingInfrastructure is not available. + + // standard charging priority for all chargers + bind(ChargingPriority.Factory.class).toInstance(ChargingPriority.FIFO); + } + + @Provides @Singleton + ChargingWithQueueingLogic.Factory provideChargingWithQueueingLogicFactory(EventsManager eventsManager, ChargingPriority.Factory chargingPriorityFactory) { + return new ChargingWithQueueingLogic.Factory(eventsManager, chargingPriorityFactory); + } + + @Provides @Singleton + ChargingWithQueueingAndAssignmentLogic.Factory provideChargingWithQueueingAndAssignmentLogicFactory(EventsManager eventsManager, ChargingPriority.Factory chargingPriorityFactory) { + return new ChargingWithQueueingAndAssignmentLogic.Factory(eventsManager, chargingPriorityFactory); } } diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingPriority.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingPriority.java new file mode 100644 index 00000000000..83087a37f79 --- /dev/null +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/charging/ChargingPriority.java @@ -0,0 +1,29 @@ +package org.matsim.contrib.ev.charging; + +import org.matsim.contrib.ev.charging.ChargingLogic.ChargingVehicle; +import org.matsim.contrib.ev.infrastructure.ChargerSpecification; + +/** + * This interface is supposed to decide if a vehicle can be plugged right now or + * if it needs to go to / remain in the queue. While the condition whether + * enough of empty plugs are available is *always* checked, the presented method + * allows to define a more complex logic beyond that. + * + * @author Sebastian Hörl (sebhoerl), IRT SystemX + */ +public interface ChargingPriority { + /** + * The vehicle can start charging if the method returns true, otherwise it stays + * in the queue. + */ + boolean requestPlugNext(ChargingVehicle cv, double now); + + public interface Factory { + ChargingPriority create(ChargerSpecification charger); + } + + /** + * The default charging priority: first-in first-out. + */ + static public final Factory FIFO = charger -> (ev, now) -> true; +} \ No newline at end of file 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..1a0aa853af0 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, ChargingPriority priority) { + super(charger, eventsManager, priority); } @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,31 @@ 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; + private final ChargingPriority.Factory priorityFactory; - public FactoryProvider(Function chargingStrategyCreator) { - this.chargingStrategyCreator = chargingStrategyCreator; + public Factory(EventsManager eventsManager, ChargingPriority.Factory priorityFactory) { + this.eventsManager = eventsManager; + this.priorityFactory = priorityFactory; } @Override - public ChargingLogic.Factory get() { - return charger -> new ChargingWithQueueingAndAssignmentLogic(charger, - chargingStrategyCreator.apply(charger), eventsManager); + public ChargingLogic create(ChargerSpecification charger) { + return new ChargingWithQueueingAndAssignmentLogic(charger, eventsManager, priorityFactory.create(charger)); } } } 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..0e0de973ffe 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,78 +19,87 @@ 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 ChargingPriority priority; - 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, ChargingPriority priority) { this.charger = Objects.requireNonNull(charger); this.eventsManager = Objects.requireNonNull(eventsManager); + this.priority = priority; } @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); } } - int queuedToPluggedCount = Math.min(queuedVehicles.size(), charger.getPlugCount() - pluggedVehicles.size()); - for (int i = 0; i < queuedToPluggedCount; i++) { - plugVehicle(queuedVehicles.poll(), now); + var queuedVehiclesIter = queuedVehicles.iterator(); + while (queuedVehiclesIter.hasNext() && pluggedVehicles.size() < charger.getPlugCount()) { + var cv = queuedVehiclesIter.next(); + if (plugVehicle(cv, now)) { + queuedVehiclesIter.remove(); + } } var arrivingVehiclesIter = arrivingVehicles.iterator(); while (arrivingVehiclesIter.hasNext()) { - var ev = arrivingVehiclesIter.next(); - if (pluggedVehicles.size() < charger.getPlugCount()) { - plugVehicle(ev, now); - } else { - queueVehicle(ev, now); + var cv = arrivingVehiclesIter.next(); + if (pluggedVehicles.size() >= charger.getPlugCount() || !plugVehicle(cv, now)) { + queueVehicle(cv, now); } - arrivingVehiclesIter.remove(); } + arrivingVehicles.clear(); } @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); } @@ -100,47 +109,79 @@ public void removeVehicle(ElectricVehicle ev, double now) { eventsManager.processEvent(new ChargingEndEvent(now, charger.getId(), ev.getId(), ev.getBattery().getCharge())); listeners.remove(ev.getId()).notifyChargingEnded(ev, now); - if (!queuedVehicles.isEmpty()) { - plugVehicle(queuedVehicles.poll(), now); + var queuedVehiclesIter = queuedVehicles.iterator(); + while (queuedVehiclesIter.hasNext()) { + var queuedVehicle = queuedVehiclesIter.next(); + if (plugVehicle(queuedVehicle, now)) { + queuedVehiclesIter.remove(); + break; + } } } else { - // make sure ev was in the queue - Preconditions.checkState(queuedVehicles.remove(ev), "Vehicle (%s) is neither queued nor plugged at charger (%s)", ev.getId(), - charger.getId()); - eventsManager.processEvent(new QuitQueueAtChargerEvent(now, charger.getId(), ev.getId())); + var queuedVehiclesIter = queuedVehicles.iterator(); + while (queuedVehiclesIter.hasNext()) { + var queuedVehicle = queuedVehiclesIter.next(); + + if (queuedVehicle.ev() == ev) { + queuedVehiclesIter.remove(); + eventsManager.processEvent(new QuitQueueAtChargerEvent(now, charger.getId(), ev.getId())); + return; // found the vehicle + } + } + + throw new IllegalStateException(String.format("Vehicle (%s) is neither queued nor plugged at charger (%s)", ev.getId(), + charger.getId())); } } - 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 boolean plugVehicle(ChargingVehicle cv, double now) { + assert pluggedVehicles.size() < charger.getPlugCount(); + + if (!priority.requestPlugNext(cv, now)) { + return false; + } + + 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); + + return true; } - 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; + private final ChargingPriority.Factory chargingPriorityFactory; + + public Factory(EventsManager eventsManager, ChargingPriority.Factory chargingPriorityFactory) { + this.eventsManager = eventsManager; + this.chargingPriorityFactory = chargingPriorityFactory; + } + + @Override + public ChargingLogic create(ChargerSpecification charger) { + return new ChargingWithQueueingLogic(charger, eventsManager, chargingPriorityFactory.create(charger)); + } } } 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/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricFleetSpecificationDefaultImpl.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricFleetSpecificationDefaultImpl.java index b24583feb13..6b9b30e8cfd 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricFleetSpecificationDefaultImpl.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricFleetSpecificationDefaultImpl.java @@ -30,7 +30,7 @@ /** * @author Michal Maciejewski (michalm) */ -final class ElectricFleetSpecificationDefaultImpl implements ElectricFleetSpecification { +public final class ElectricFleetSpecificationDefaultImpl implements ElectricFleetSpecification { private final Map, ElectricVehicleSpecification> specifications = new LinkedHashMap<>(); @Override diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricVehicleSpecificationDefaultImpl.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricVehicleSpecificationDefaultImpl.java index ef18ae6cce6..e3a4caca03e 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricVehicleSpecificationDefaultImpl.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/fleet/ElectricVehicleSpecificationDefaultImpl.java @@ -33,7 +33,7 @@ /** * @author Michal Maciejewski (michalm) */ -final class ElectricVehicleSpecificationDefaultImpl implements ElectricVehicleSpecification { +public final class ElectricVehicleSpecificationDefaultImpl implements ElectricVehicleSpecification { private final Vehicle matsimVehicle; diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/infrastructure/ChargingInfrastructureSpecificationDefaultImpl.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/infrastructure/ChargingInfrastructureSpecificationDefaultImpl.java index 48a27563616..763a2cd70e1 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/infrastructure/ChargingInfrastructureSpecificationDefaultImpl.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/infrastructure/ChargingInfrastructureSpecificationDefaultImpl.java @@ -28,7 +28,7 @@ /** * @author Michal Maciejewski (michalm) */ -final class ChargingInfrastructureSpecificationDefaultImpl implements ChargingInfrastructureSpecification { +public final class ChargingInfrastructureSpecificationDefaultImpl implements ChargingInfrastructureSpecification { private final SpecificationContainer container = new SpecificationContainer<>(); @Override diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationManager.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationManager.java new file mode 100644 index 00000000000..6e6fa1e77c9 --- /dev/null +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationManager.java @@ -0,0 +1,106 @@ +package org.matsim.contrib.ev.reservation; + +import java.util.LinkedList; +import java.util.List; + +import org.matsim.api.core.v01.IdMap; +import org.matsim.contrib.ev.fleet.ElectricVehicle; +import org.matsim.contrib.ev.infrastructure.Charger; +import org.matsim.contrib.ev.infrastructure.ChargerSpecification; +import org.matsim.core.controler.events.IterationStartsEvent; +import org.matsim.core.controler.listener.IterationStartsListener; + +/** + * This class is a singleton service that keeps a list of reservations for + * chargers. It can be used in combination with the + * ReservationBasedChargingPriority to let vehicle pass on to charging only if + * they have a proper reservation. + * + * @author Sebastian Hörl (sebhoerl), IRT SystemX + */ +public class ChargerReservationManager implements IterationStartsListener { + private final IdMap> reservations = new IdMap<>(Charger.class); + + public boolean isAvailable(ChargerSpecification charger, ElectricVehicle vehicle, double startTile, + double endTime) { + if (charger.getPlugCount() == 0) { + return false; + } + + if (!reservations.containsKey(charger.getId())) { + return true; + } + + int remaining = charger.getPlugCount(); + for (Reservation reservation : reservations.get(charger.getId())) { + if (reservation.vehicle != vehicle && isOverlapping(reservation, startTile, endTime)) { + remaining--; + } + } + + return remaining > 0; + } + + private boolean isOverlapping(Reservation reservation, double startTime, double endTime) { + if (startTime >= reservation.startTime && startTime <= reservation.endTime) { + return true; // start time within existing range + } else if (endTime >= reservation.startTime && endTime <= reservation.endTime) { + return true; // end time within existing range + } else if (startTime <= reservation.startTime && endTime >= reservation.endTime) { + return true; // new range covers existing range + } else { + return false; + } + } + + public Reservation addReservation(ChargerSpecification charger, ElectricVehicle vehicle, double startTime, + double endTime) { + if (isAvailable(charger, vehicle, startTime, endTime)) { + List chargerReservations = reservations.get(charger.getId()); + + if (chargerReservations == null) { + chargerReservations = new LinkedList<>(); + reservations.put(charger.getId(), chargerReservations); + } + + Reservation reservation = new Reservation(charger, vehicle, startTime, endTime); + chargerReservations.add(reservation); + + return reservation; + } + + return null; + } + + public boolean removeReservation(Reservation reservation) { + List chargerReservations = reservations.get(reservation.charger.getId()); + + if (chargerReservations != null) { + return chargerReservations.remove(reservation); + } + + return false; + } + + public Reservation findReservation(ChargerSpecification charger, ElectricVehicle vehicle, double now) { + List chargerReservations = reservations.get(charger.getId()); + + if (chargerReservations != null) { + for (Reservation reservation : chargerReservations) { + if (reservation.vehicle == vehicle && now >= reservation.startTime && now <= reservation.endTime) { + return reservation; + } + } + } + + return null; + } + + public record Reservation(ChargerSpecification charger, ElectricVehicle vehicle, double startTime, double endTime) { + } + + @Override + public void notifyIterationStarts(IterationStartsEvent event) { + reservations.clear(); + } +} \ No newline at end of file diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationModule.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationModule.java new file mode 100644 index 00000000000..9a17f208055 --- /dev/null +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ChargerReservationModule.java @@ -0,0 +1,35 @@ +package org.matsim.contrib.ev.reservation; + +import org.matsim.contrib.ev.charging.ChargingPriority; +import org.matsim.core.controler.AbstractModule; + +import com.google.inject.Provides; +import com.google.inject.Singleton; + +/** + * This module enables the reservation-based charging logic that requires + * vehicles to have or make a reservation when attempting to charge at a + * charger. + * + * @author Sebastian Hörl (sebhoerl), IRT SystemX + */ +public class ChargerReservationModule extends AbstractModule { + @Override + public void install() { + addControlerListenerBinding().to(ChargerReservationManager.class); + bind(ChargingPriority.Factory.class).to(ReservationBasedChargingPriority.Factory.class); + } + + @Provides + @Singleton + ReservationBasedChargingPriority.Factory provideReservationBasedChargingPriorityFactory( + ChargerReservationManager reservationManager) { + return new ReservationBasedChargingPriority.Factory(reservationManager); + } + + @Provides + @Singleton + ChargerReservationManager provideChargerReservationManager() { + return new ChargerReservationManager(); + } +} \ No newline at end of file diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ReservationBasedChargingPriority.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ReservationBasedChargingPriority.java new file mode 100644 index 00000000000..8ac5a79a8ad --- /dev/null +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/reservation/ReservationBasedChargingPriority.java @@ -0,0 +1,64 @@ +package org.matsim.contrib.ev.reservation; + +import org.matsim.contrib.ev.charging.ChargingLogic.ChargingVehicle; +import org.matsim.contrib.ev.charging.ChargingPriority; +import org.matsim.contrib.ev.infrastructure.ChargerSpecification; +import org.matsim.contrib.ev.reservation.ChargerReservationManager.Reservation; + +/** + * This is an implementation of a charging priority which is backed by the + * ReservationManager: When a vehicle arrives, it is checked whether a + * reservation for this vehicle exists for the respective charger and the + * current time. In that case, the vehicle can be plugged if it is on top of the + * queue. If not, the ChargingPriority will try to make a reservation and if it + * is successful, the vehicle can start charging. In all other cases, the + * vehicle will stay in the queue until it is removed manually or a successful + * reservation can be made at a future time. + * + * @author Sebastian Hörl (sebhoerl), IRT SystemX + */ +public class ReservationBasedChargingPriority implements ChargingPriority { + private final ChargerReservationManager manager; + private final ChargerSpecification charger; + + public ReservationBasedChargingPriority(ChargerReservationManager manager, ChargerSpecification charger) { + this.charger = charger; + this.manager = manager; + } + + @Override + public boolean requestPlugNext(ChargingVehicle cv, double now) { + Reservation reservation = manager.findReservation(charger, cv.ev(), now); + + if (reservation != null) { + // vehicle has a reservation, can be plugged right away, consume reservation + manager.removeReservation(reservation); + return true; + } + + double endTime = cv.strategy().calcRemainingTimeToCharge() + now; + reservation = manager.addReservation(charger, cv.ev(), now, endTime); + + if (reservation != null) { + // vehicle did not have a reservation, but managed to create one on the fly, + // consume it directly + manager.removeReservation(reservation); + return true; + } + + return false; + } + + static public class Factory implements ChargingPriority.Factory { + private final ChargerReservationManager reservationManager; + + public Factory(ChargerReservationManager reservationManager) { + this.reservationManager = reservationManager; + } + + @Override + public ChargingPriority create(ChargerSpecification charger) { + return new ReservationBasedChargingPriority(reservationManager, charger); + } + } +} \ No newline at end of file diff --git a/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargingProceduresCSVWriter.java b/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargingProceduresCSVWriter.java index ae1c9d0c013..4cef65da81b 100644 --- a/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargingProceduresCSVWriter.java +++ b/contribs/ev/src/main/java/org/matsim/contrib/ev/stats/ChargingProceduresCSVWriter.java @@ -83,8 +83,12 @@ private void proccessChargingEventSequences(CSVPrinter csvPrinter, Collection() { - @Inject - private ChargerPowerTimeProfileCalculator calculator; - @Inject - private MatsimServices matsimServices; + }); + bind(ChargerPowerTimeProfileCalculator.class).asEagerSingleton(); + addEventHandlerBinding().to(ChargerPowerTimeProfileCalculator.class); + addControlerListenerBinding().toProvider(new Provider<>() { + @Inject + private ChargerPowerTimeProfileCalculator calculator; + @Inject + private MatsimServices matsimServices; - @Override - public ControlerListener get() { - var profileView = new ChargerPowerTimeProfileView(calculator); - return new ProfileWriter(matsimServices,"ev",profileView,"charger_power_time_profiles"); + @Override + public ControlerListener get() { + var profileView = new ChargerPowerTimeProfileView(calculator); + return new ProfileWriter(matsimServices, "ev", profileView, "charger_power_time_profiles"); - } - }); + } + }); + } } } 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/README.md b/contribs/parking/README.md index a9e090515c3..1285c0d5f86 100644 --- a/contribs/parking/README.md +++ b/contribs/parking/README.md @@ -12,4 +12,34 @@ approaches as to how parking can be handled in MATSim, depending on the use case . This was designed for large scenarios where it's not feasable to fully simulate parking agents. Rather, the additional time needed for parking is estimated - Parking Costs, developed by Marcel Rieser and Joschka Bischoff at SBB. This modules allows the integration of parking - costs based on link attribute data. \ No newline at end of file + costs based on link attribute data. + +## Implementations + +### Parking Search + +Model parking search, including walking segments and parking search traffic. + +Different Parking Search Logics: + +1. **Random:** + 1. Drive to the destination. + 2. The next link is chosen randomly. +2. **DistanceMemoryParkingSearch:** + 1. Drive to the destination. + 2. Select the next link: + 1. Choose an unknown link with the shortest straight-line distance to the destination. + 2. If all links are known, choose randomly. +3. **NearestParkingSpotSearchLogic:** + 1. Drive to the destination (??). + 2. Search for the facility with the shortest distance to the current location, considering the expected driving time and parking duration (and + possibly parking time restrictions). + 3. If no suitable facility is found ? +4. **BenensonParkingSearchLogic:** A more sophisticated strategy based on the Benenson + model: https://www.sciencedirect.com/science/article/pii/S0198971508000689 + +### Parking Proxy + +### Parking Costs + +### Parking Choice 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/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/BenensonDynLeg.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/BenensonDynLeg.java index 5bd6ca248bb..c7b041ba21a 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/BenensonDynLeg.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/BenensonDynLeg.java @@ -21,30 +21,30 @@ /** * @author schlenther *

- * Benenson et al defined 3 phases of parking search + * Benenson et al. defined 3 phases of parking search * OBSERVING: observation of parking situation while driving towards destination * SEARCH_WHILE_APPROACH: estimating the amount of free parking lots on the way to destination * and if applicable parking before arriving * SEARCH_FOR_NEXT: taking the next free parking space if it isn't too far away from destination */ enum ParkingMode { - DRIVING, OBSERVING, SEARCH_WHILE_APPROACH, SEARCH_FOR_NEXT + DRIVING, OBSERVING, SEARCH_WHILE_APPROACH, SEARCH_FOR_NEXT } -public class BenensonDynLeg extends ParkingDynLeg{ +public class BenensonDynLeg extends ParkingDynLeg { private static final Logger logger = LogManager.getLogger(BenensonDynLeg.class); private static final boolean logForDebug = false; private double totalObservedParkingSpaces = 0.0; private double observedFreeParkingSpaces = 0.0; - private double firstDestinationLinkEnterTime = 0; - private ParkingMode legStage = ParkingMode.DRIVING; + private double firstDestinationLinkEnterTime = 0; + private ParkingMode legStage = ParkingMode.DRIVING; public BenensonDynLeg(String mode, NetworkRoute route, ParkingSearchLogic logic, - ParkingSearchManager parkingManager, Id vehicleId, MobsimTimer timer, EventsManager events) { + ParkingSearchManager parkingManager, Id vehicleId, MobsimTimer timer, EventsManager events) { super(mode, route, logic, parkingManager, vehicleId, timer, events); - if (!(logic instanceof BenensonParkingSearchLogic)){ + if (!(logic instanceof BenensonParkingSearchLogic)) { throw new RuntimeException(); } } @@ -55,56 +55,68 @@ public void movedOverNode(Id newLinkId) { currentLinkId = newLinkId; if (this.legStage == ParkingMode.DRIVING) { - if (((BenensonParkingSearchLogic) this.logic).transitionToObservingBehaviour(currentLinkId, this.route.getEndLinkId())) { - this.legStage = ParkingMode.OBSERVING; + if (((BenensonParkingSearchLogic) this.logic).transitionToObservingBehaviour(currentLinkId, this.route.getEndLinkId())) { + this.legStage = ParkingMode.OBSERVING; this.events.processEvent(new StartParkingSearchEvent(timer.getTimeOfDay(), vehicleId, currentLinkId)); - if(logForDebug)logger.error("vehicle " + this.vehicleId + " goes into observing on link " + this.currentLinkId); + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " goes into observing on link " + this.currentLinkId); + } } } - if(this.legStage == ParkingMode.OBSERVING ){ + if (this.legStage == ParkingMode.OBSERVING) { memorizeParkingSituationAndIsSomethingFree(); - if (((BenensonParkingSearchLogic) this.logic).transitionToParkingBehaviour(currentLinkId, this.route.getEndLinkId())) { - this.legStage = ParkingMode.SEARCH_WHILE_APPROACH; - if(logForDebug)logger.error("vehicle " + this.vehicleId + " goes into parking on link " + this.currentLinkId); + if (((BenensonParkingSearchLogic) this.logic).transitionToParkingBehaviour(currentLinkId, this.route.getEndLinkId())) { + this.legStage = ParkingMode.SEARCH_WHILE_APPROACH; + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " goes into parking on link " + this.currentLinkId); + } } } - if(this.legStage == ParkingMode.SEARCH_WHILE_APPROACH){ - if(currentLinkId.equals(route.getEndLinkId())){ + if (this.legStage == ParkingMode.SEARCH_WHILE_APPROACH) { + if (currentLinkId.equals(route.getEndLinkId())) { this.legStage = ParkingMode.SEARCH_FOR_NEXT; - this.firstDestinationLinkEnterTime = timer.getTimeOfDay(); - } - else{ - if(memorizeParkingSituationAndIsSomethingFree()){ + this.firstDestinationLinkEnterTime = timer.getTimeOfDay(); + } else { + if (memorizeParkingSituationAndIsSomethingFree()) { double pUnoccupied = 0; - if(this.totalObservedParkingSpaces > 0){ + if (this.totalObservedParkingSpaces > 0) { pUnoccupied = this.observedFreeParkingSpaces / this.totalObservedParkingSpaces; } - if ( ((BenensonParkingSearchLogic)this.logic).wantToParkHere(pUnoccupied, currentLinkId, route.getEndLinkId())){ - if (logForDebug) logger.error("vehicle " + this.vehicleId + " would like to park on link" + currentLinkId - + "\n \t pUnoccupied = " + pUnoccupied + "\n\t totalObservedParkingSpaces = " + totalObservedParkingSpaces + "\n\t observedFreeSpaces = " + this.observedFreeParkingSpaces); - hasFoundParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, currentLinkId); - } - } - else{ - if(logForDebug)logger.error("nothing free for vehicle " + vehicleId + " on link " + currentLinkId); + if (((BenensonParkingSearchLogic) this.logic).wantToParkHere(pUnoccupied, currentLinkId, route.getEndLinkId())) { + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " would like to park on link" + currentLinkId + + "\n \t pUnoccupied = " + pUnoccupied + "\n\t totalObservedParkingSpaces = " + totalObservedParkingSpaces + "\n\t " + + "observedFreeSpaces = " + this.observedFreeParkingSpaces); + } + hasFoundParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, currentLinkId); + } + } else { + if (logForDebug) { + logger.error("nothing free for vehicle " + vehicleId + " on link " + currentLinkId); + } } } } - if (this.legStage == ParkingMode.SEARCH_FOR_NEXT){ - if (logForDebug) logger.error("vehicle " + this.vehicleId + " is in PHASE3 on link " + this.currentLinkId); - //if( ((BenensonParkingSearchLogic)this.logic).isDriverInAcceptableDistance(currentLinkId, route.getEndLinkId(), this.firstDestLinkEnterTimer, timer.getTimeOfDay()) ){ + if (this.legStage == ParkingMode.SEARCH_FOR_NEXT) { + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " is in PHASE3 on link " + this.currentLinkId); + } + //if( ((BenensonParkingSearchLogic)this.logic).isDriverInAcceptableDistance(currentLinkId, route.getEndLinkId(), this + // .firstDestLinkEnterTimer, timer.getTimeOfDay()) ){ - hasFoundParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, currentLinkId); + hasFoundParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, currentLinkId); - if (logForDebug) logger.error("vehicle " + this.vehicleId + " tries in PHASE3 to park on link " + this.currentLinkId + ", " + - (int) (timer.getTimeOfDay() - this.firstDestinationLinkEnterTime) / 60 + ":" + (int) (timer.getTimeOfDay() - this.firstDestinationLinkEnterTime) % 60 - + " min after passing destination. Result: " + hasFoundParking); - //} - } - } + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " tries in PHASE3 to park on link " + this.currentLinkId + ", " + + (int) (timer.getTimeOfDay() - this.firstDestinationLinkEnterTime) / 60 + ":" + (int) (timer.getTimeOfDay() - this.firstDestinationLinkEnterTime) % 60 + + " min after passing destination. Result: " + hasFoundParking); + } + //} + } + } - /** + /** * returns true if there is at least one empty slot on the current link */ private boolean memorizeParkingSituationAndIsSomethingFree() { @@ -124,13 +136,14 @@ public Id getNextLinkId() { return route.getEndLinkId(); } return linkIds.get(currentLinkIdx + 1); - } - else { + } else { if (hasFoundParking) { - if(logForDebug)logger.error("vehicle " + this.vehicleId + " has found a parking on link " + this.currentLinkId + " after passing " + Math.abs((this.route.getLinkIds().size() - this.currentLinkIdx - 3)) + " links"); + if (logForDebug) { + logger.error("vehicle " + this.vehicleId + " has found a parking on link " + this.currentLinkId + " after passing " + Math.abs((this.route.getLinkIds() + .size() - this.currentLinkIdx - 3)) + " links"); + } return null; - } - else { + } else { if (this.currentAndNextParkLink != null) { if (currentAndNextParkLink.getFirst().equals(currentLinkId)) { // we already calculated this @@ -139,15 +152,15 @@ public Id getNextLinkId() { } Id nextLinkId; - if(this.legStage == ParkingMode.SEARCH_FOR_NEXT){ - nextLinkId = ((BenensonParkingSearchLogic) this.logic).getNextLinkRandomInAcceptableDistance(currentLinkId, this.route.getEndLinkId(), - vehicleId, firstDestinationLinkEnterTime, this.timer.getTimeOfDay(), mode); - } - else{ + if (this.legStage == ParkingMode.SEARCH_FOR_NEXT) { + nextLinkId = ((BenensonParkingSearchLogic) this.logic).getNextLinkRandomInAcceptableDistance(currentLinkId, + this.route.getEndLinkId(), + vehicleId, firstDestinationLinkEnterTime, this.timer.getTimeOfDay(), mode); + } else { nextLinkId = ((BenensonParkingSearchLogic) (this.logic)).getNextLinkBenensonRouting(currentLinkId, route.getEndLinkId(), mode); - } - currentAndNextParkLink = new Tuple<>(currentLinkId, nextLinkId); - return nextLinkId; + } + currentAndNextParkLink = new Tuple<>(currentLinkId, nextLinkId); + return nextLinkId; } } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/NearestParkingDynLeg.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/NearestParkingDynLeg.java index a5f4cdcf143..ba81ede9c1d 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/NearestParkingDynLeg.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/NearestParkingDynLeg.java @@ -45,10 +45,12 @@ public NearestParkingDynLeg(Leg currentPlannedLeg, NetworkRoute route, Plan plan this.currentPlannedLeg = currentPlannedLeg; this.plan = plan; this.planIndexNextActivity = planIndexNextActivity; - if (ParkingUtils.checkIfActivityHasNoParking(followingActivity)) + if (ParkingUtils.checkIfActivityHasNoParking(followingActivity)) { parkingAtEndOfLeg = false; - if (ParkingUtils.checkIfActivityHasPassengerInteraction(followingActivity)) + } + if (ParkingUtils.checkIfActivityHasPassengerInteraction(followingActivity)) { passangerInteractionAtParkingFacilityAtEndOfLeg = true; + } } @Override @@ -67,20 +69,22 @@ public void movedOverNode(Id newLinkId) { if (hasFoundParking) { this.events.processEvent(new ReserveParkingLocationEvent(timer.getTimeOfDay(), vehicleId, currentLinkId, currentLinkId)); nextSelectedParkingLink = currentLinkId; - } else + } else { ((FacilityBasedParkingManager) parkingManager).registerRejectedReservation(timer.getTimeOfDay()); + } } } } else if (followingActivity.getLinkId().equals(newLinkId)) { - if (alreadyReservedParking) + if (alreadyReservedParking) { hasFoundParking = true; - else { + } else { hasFoundParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, currentLinkId); if (hasFoundParking) { this.events.processEvent(new ReserveParkingLocationEvent(timer.getTimeOfDay(), vehicleId, currentLinkId, currentLinkId)); nextSelectedParkingLink = currentLinkId; - } else + } else { ((FacilityBasedParkingManager) parkingManager).registerRejectedReservation(timer.getTimeOfDay()); + } } } } @@ -138,11 +142,10 @@ public Id getNextLinkId() { // need to find the next link double nextPickupTime; double maxParkingDuration; - if (passangerInteractionAtParkingFacilityAtEndOfLeg){ + if (passangerInteractionAtParkingFacilityAtEndOfLeg) { nextPickupTime = 0.; maxParkingDuration = followingActivity.getMaximumDuration().seconds(); - } - else { + } else { nextPickupTime = currentPlannedLeg.getDepartureTime().seconds() + followingActivity.getMaximumDuration().seconds(); maxParkingDuration = nextPickupTime - timer.getTimeOfDay(); } @@ -163,11 +166,12 @@ public Id getNextLinkId() { nextSelectedParkingLink = nextPlanedParkingLink; if (((NearestParkingSpotSearchLogic) this.logic).canReserveParkingSlot()) { alreadyReservedParking = parkingManager.reserveSpaceIfVehicleCanParkHere(vehicleId, nextSelectedParkingLink); - if (alreadyReservedParking) + if (alreadyReservedParking) { this.events.processEvent( new ReserveParkingLocationEvent(timer.getTimeOfDay(), vehicleId, currentLinkId, nextSelectedParkingLink)); - else + } else { ((FacilityBasedParkingManager) parkingManager).registerRejectedReservation(timer.getTimeOfDay()); + } } else { this.events.processEvent( new SelectNewParkingLocationEvent(timer.getTimeOfDay(), vehicleId, currentLinkId, nextSelectedParkingLink)); @@ -176,13 +180,16 @@ public Id getNextLinkId() { } } currentAndNextParkLink = new Tuple<>(currentLinkId, nextLinkId); - if (((NearestParkingSpotSearchLogic) this.logic).getNextRoute() != null) + if (((NearestParkingSpotSearchLogic) this.logic).getNextRoute() != null) { currentPlannedLeg.setRoute(((NearestParkingSpotSearchLogic) this.logic).getNextRoute()); + } return nextLinkId; } } } + //yyyy I assume, the vehicle is removed from the link's queue and thus waiting for parking does not influence the behaviour of the mobsim? + // Does this make sense? paul, nov'24 private void createWaitingActivityUntilPassengerInteractionIsPossible(Id newLinkId, Id vehicleId, double now) { Activity waitingActivity = PopulationUtils.createActivityFromLinkId(ParkingUtils.WaitingForParkingActivityType, newLinkId); ParkingUtils.setNoParkingForActivity(waitingActivity); @@ -195,7 +202,8 @@ private void removeNextActivityAndFollowingLeg() { plan.getPlanElements().remove(planIndexNextActivity); plan.getPlanElements().remove(planIndexNextActivity); // log.info( -// plan.getPerson().getId().toString() + ": Parking activity after getOff point '" + ((Activity)plan.getPlanElements().get(planIndexNextActivity - 2)).getType() + "' is removed, because no parking facility was found."); +// plan.getPerson().getId().toString() + ": Parking activity after getOff point '" + ((Activity)plan.getPlanElements().get +// (planIndexNextActivity - 2)).getType() + "' is removed, because no parking facility was found."); } public boolean driveToBaseWithoutParking() { diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/NearestParkingSpotAgentLogic.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/NearestParkingSpotAgentLogic.java index f3a7e671b14..b0095eb5cf7 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/NearestParkingSpotAgentLogic.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/NearestParkingSpotAgentLogic.java @@ -52,19 +52,20 @@ public DynAction computeNextAction(DynAction oldAction, double now) { // unpark activity: find the way to the next route & start leg //if a parking activity was skipped we need no change the nexParkActionState - if (lastParkActionState.equals(LastParkActionState.CARTRIP) && ((NearestParkingDynLeg) oldAction).driveToBaseWithoutParking()) + if (lastParkActionState.equals(LastParkActionState.CARTRIP) && ((NearestParkingDynLeg) oldAction).driveToBaseWithoutParking()) { this.lastParkActionState = LastParkActionState.WALKFROMPARK; + } - return switch (lastParkActionState) { - case ACTIVITY -> nextStateAfterActivity(oldAction, now); - case CARTRIP -> nextStateAfterCarTrip(oldAction, now); - case NONCARTRIP -> nextStateAfterNonCarTrip(oldAction, now); - case PARKACTIVITY -> nextStateAfterParkActivity(oldAction, now); - case UNPARKACTIVITY -> nextStateAfterUnParkActivity(oldAction, now); - case WALKFROMPARK -> nextStateAfterWalkFromPark(oldAction, now); - case WALKTOPARK -> nextStateAfterWalkToPark(oldAction, now); - }; - } + return switch (lastParkActionState) { + case ACTIVITY -> nextStateAfterActivity(oldAction, now); + case CARTRIP -> nextStateAfterCarTrip(oldAction, now); + case NONCARTRIP -> nextStateAfterNonCarTrip(oldAction, now); + case PARKACTIVITY -> nextStateAfterParkActivity(oldAction, now); + case UNPARKACTIVITY -> nextStateAfterUnParkActivity(oldAction, now); + case WALKFROMPARK -> nextStateAfterWalkFromPark(oldAction, now); + case WALKTOPARK -> nextStateAfterWalkToPark(oldAction, now); + }; + } @Override protected DynAction nextStateAfterUnParkActivity(DynAction oldAction, double now) { @@ -75,20 +76,24 @@ protected DynAction nextStateAfterUnParkActivity(DynAction oldAction, double now Route plannedRoute = currentPlannedLeg.getRoute(); NetworkRoute actualRoute = this.parkingRouter.getRouteFromParkingToDestination(plannedRoute.getEndLinkId(), now, agent.getCurrentLinkId()); actualRoute.setVehicleId(currentlyAssignedVehicleId); - if (!plannedRoute.getStartLinkId().equals(actualRoute.getStartLinkId())) + if (!plannedRoute.getStartLinkId().equals(actualRoute.getStartLinkId())) { currentPlannedLeg.setRoute(actualRoute); + } if ((this.parkingManager.unParkVehicleHere(currentlyAssignedVehicleId, agent.getCurrentLinkId(), now)) || (isInitialLocation)) { this.lastParkActionState = LastParkActionState.CARTRIP; isInitialLocation = false; // Leg currentLeg = (Leg) this.currentPlanElement; int planIndexNextActivity = planIndex + 1; Activity nextPlanElement = (Activity) plan.getPlanElements().get(planIndexNextActivity); - if (ParkingUtils.checkIfActivityHasNoParking(nextPlanElement)) + if (ParkingUtils.checkIfActivityHasNoParking(nextPlanElement)) { this.lastParkActionState = LastParkActionState.WALKFROMPARK; + } //this could be Car, Carsharing, Motorcylce, or whatever else mode we have, so we want our leg to reflect this. return new NearestParkingDynLeg(currentPlannedLeg, actualRoute, plan, planIndexNextActivity, parkingLogic, parkingManager, currentlyAssignedVehicleId, timer, events); - } else throw new RuntimeException("parking location mismatch"); + } else { + throw new RuntimeException("parking location mismatch"); + } } @@ -101,17 +106,19 @@ protected DynAction nextStateAfterParkActivity(DynAction oldAction, double now) List walkTrip = walkRouter.calcRoute( DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, now, plan.getPerson())); if (walkTrip.size() != 1 || !(walkTrip.get(0) instanceof Leg)) { - String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to access the network. Not implemented in parking yet!"; + String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to " + + "access the network. Not implemented in parking yet!"; log.error(message); throw new RuntimeException(message); } Leg walkLeg = (Leg) walkTrip.get(0); this.lastParkActionState = LastParkActionState.WALKFROMPARK; this.stageInteractionType = null; - if (!walkLeg.getTravelTime().equals(OptionalTime.defined(0.))) + if (!walkLeg.getTravelTime().equals(OptionalTime.defined(0.))) { return new StaticPassengerDynLeg(walkLeg.getRoute(), walkLeg.getMode()); - else + } else { return nextStateAfterWalkFromPark(oldAction, now); + } } @Override @@ -125,15 +132,20 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { this.parkingManager.parkVehicleHere(Id.create(this.agent.getId(), Vehicle.class), agent.getCurrentLinkId(), now); return nextStateAfterNonCarTrip(oldAction, now); } - if (plan.getPlanElements().get(planIndex + 1) instanceof Activity) + if (plan.getPlanElements().get(planIndex + 1) instanceof Activity) { return nextStateAfterNonCarTrip(oldAction, now); - if (plan.getPlanElements().get(planIndex) instanceof Activity && ((Activity) plan.getPlanElements().get(planIndex)).getType().contains("_GetOff")) { + } + if (plan.getPlanElements().get(planIndex) instanceof Activity && ((Activity) plan.getPlanElements().get(planIndex)).getType() + .contains("_GetOff")) { ((Activity) plan.getPlanElements().get(planIndex)).setEndTime(now); - ((Activity) plan.getPlanElements().get(planIndex + 4)).setStartTime(now + ((Activity) plan.getPlanElements().get(planIndex + 2)).getMaximumDuration().seconds()); + ((Activity) plan.getPlanElements().get(planIndex + 4)).setStartTime(now + ((Activity) plan.getPlanElements() + .get(planIndex + 2)).getMaximumDuration() + .seconds()); // checks if it is possible to stay from getOff until getIn - boolean possibleToStay = checkIfParkingIsPossibleUntilNextActivities(this.planIndex,this.planIndex + 2); - if (possibleToStay) + boolean possibleToStay = checkIfParkingIsPossibleUntilNextActivities(this.planIndex, this.planIndex + 2); + if (possibleToStay) { return nextStateAfterNonCarTrip(oldAction, now); + } } planIndex++; this.currentPlanElement = plan.getPlanElements().get(planIndex); @@ -143,7 +155,8 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { Id parkLink = this.parkingManager.getVehicleParkingLocation(vehicleId); if (parkLink == null) { - //this is the first activity of a day and our parking manager does not provide information about initial stages. We suppose the car is parked where we are + //this is the first activity of a day and our parking manager does not provide information about initial stages. We suppose the + // car is parked where we are parkLink = agent.getCurrentLinkId(); } @@ -154,7 +167,8 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { List walkTrip = walkRouter.calcRoute( DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, now, plan.getPerson())); if (walkTrip.size() != 1 || !(walkTrip.get(0) instanceof Leg walkLeg)) { - String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to access the network. Not implemented in parking yet!"; + String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk" + + " to access the network. Not implemented in parking yet!"; log.error(message); throw new RuntimeException(message); } @@ -180,9 +194,12 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { return new StaticPassengerDynLeg(currentLeg.getRoute(), currentLeg.getMode()); } - } else throw new RuntimeException( - "no more leg to follow but activity is ending\nLastPlanElement: " + currentPlanElement.toString() + "\n Agent " + this.agent.getId() + "\nTime: " + Time.writeTime( - now)); + } else { + throw new RuntimeException( + "no more leg to follow but activity is ending\nLastPlanElement: " + currentPlanElement.toString() + "\n Agent " + this.agent.getId() + + "\nTime: " + Time.writeTime( + now)); + } } @Override @@ -190,8 +207,9 @@ protected DynAction nextStateAfterWalkToPark(DynAction oldAction, double now) { //walk2park is complete, we can unpark. this.lastParkActionState = LastParkActionState.UNPARKACTIVITY; Activity beforePlanElement = (Activity) plan.getPlanElements().get(planIndex - 1); - if (ParkingUtils.checkIfActivityHasNoParking(beforePlanElement)) + if (ParkingUtils.checkIfActivityHasNoParking(beforePlanElement)) { return nextStateAfterUnParkActivity(oldAction, now); // wenn kein Parken dann einfach weiter + } return new IdleDynActivity(this.stageInteractionType, now + configGroup.getUnparkduration()); } @@ -211,7 +229,9 @@ protected DynAction nextStateAfterCarTrip(DynAction oldAction, double now) { this.currentlyAssignedVehicleId = null; this.parkingLogic.reset(); return new IdleDynActivity(this.stageInteractionType, now + configGroup.getParkduration()); - } else throw new RuntimeException("No parking possible"); + } else { + throw new RuntimeException("No parking possible"); + } } @Override @@ -221,7 +241,7 @@ protected DynAction nextStateAfterNonCarTrip(DynAction oldAction, double now) { Activity nextPlannedActivity = (Activity) this.currentPlanElement; // checks if you can extend parking here until getIn if (nextPlannedActivity.getType().equals(ParkingUtils.ParkingActivityType) && plan.getPlanElements().get(planIndex + 2) instanceof Leg) { - checkIfParkingIsPossibleUntilNextActivities(planIndex + 1,planIndex + 1); + checkIfParkingIsPossibleUntilNextActivities(planIndex + 1, planIndex + 1); } // switch back to activity planIndex++; @@ -249,11 +269,11 @@ private boolean checkIfParkingIsPossibleUntilNextActivities(int indexOfCurrentAc Activity currentActivity = ((Activity) plan.getPlanElements().get(this.planIndex)); Activity activityAfterFollowing = ((Activity) plan.getPlanElements().get(this.planIndex + 4)); if (agent.getCurrentLinkId().equals(activityAfterFollowing.getLinkId()) && !ParkingUtils.checkIfActivityHasNoParking( - (Activity) currentPlanElement)) { + (Activity) currentPlanElement)) { boolean canParkAtFacilityUntilGetIn = ((FacilityBasedParkingManager) parkingManager).canParkAtThisFacilityUntilEnd( agent.getCurrentLinkId(), - followingActivity.getMaximumDuration().seconds(), currentActivity.getMaximumDuration().seconds(), - activityAfterFollowing.getMaximumDuration().seconds(), timer.getTimeOfDay()); + timer.getTimeOfDay(), currentActivity.getMaximumDuration().seconds(), followingActivity.getMaximumDuration().seconds(), + activityAfterFollowing.getMaximumDuration().seconds()); if (canParkAtFacilityUntilGetIn) { plan.getPlanElements().remove(this.planIndex + 3); plan.getPlanElements().remove(this.planIndex + 1); @@ -269,8 +289,8 @@ else if (indexOfCurrentActivity == indexOfParkingActivity) { followingActivity)) { boolean canParkAtFacilityUntilGetIn = ((FacilityBasedParkingManager) parkingManager).canParkAtThisFacilityUntilEnd( agent.getCurrentLinkId(), - currentActivity.getMaximumDuration().seconds(), 0., - followingActivity.getMaximumDuration().seconds(), timer.getTimeOfDay()); + timer.getTimeOfDay(), 0., currentActivity.getMaximumDuration().seconds(), + followingActivity.getMaximumDuration().seconds()); if (canParkAtFacilityUntilGetIn) { plan.getPlanElements().remove(indexOfParkingActivity + 1); currentActivity.setEndTime(followingActivity.getStartTime().seconds()); diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/ParkingAgentLogic.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/ParkingAgentLogic.java index dd2fb4fa74b..31e175a3d30 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/ParkingAgentLogic.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/DynAgent/agentLogic/ParkingAgentLogic.java @@ -19,25 +19,14 @@ package org.matsim.contrib.parking.parkingsearch.DynAgent.agentLogic; -import java.util.List; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; -import org.matsim.api.core.v01.population.Activity; -import org.matsim.api.core.v01.population.Leg; -import org.matsim.api.core.v01.population.Plan; -import org.matsim.api.core.v01.population.PlanElement; -import org.matsim.api.core.v01.population.Route; -import org.matsim.contrib.dynagent.DynAction; -import org.matsim.contrib.dynagent.DynActivity; -import org.matsim.contrib.dynagent.DynAgent; -import org.matsim.contrib.dynagent.DynAgentLogic; -import org.matsim.contrib.dynagent.IdleDynActivity; -import org.matsim.contrib.dynagent.StaticPassengerDynLeg; +import org.matsim.api.core.v01.population.*; +import org.matsim.contrib.dynagent.*; import org.matsim.contrib.parking.parkingsearch.DynAgent.ParkingDynLeg; import org.matsim.contrib.parking.parkingsearch.ParkingUtils; import org.matsim.contrib.parking.parkingsearch.manager.ParkingSearchManager; @@ -56,8 +45,12 @@ import org.matsim.pt.routes.TransitPassengerRoute; import org.matsim.vehicles.Vehicle; +import java.util.List; + /** + * This class represents the logic for a {@link DynAgent}. It can only handle car legs for parking. + * * @author jbischoff */ public class ParkingAgentLogic implements DynAgentLogic { @@ -139,17 +132,17 @@ public DynAction computeNextAction(DynAction oldAction, double now) { // ordinary activity: get next Leg, if car: go to car, otherwise add ordinary leg by other mode // walk-leg to car: add unpark activity // unpark activity: find the way to the next route & start leg - return switch (lastParkActionState) { - case ACTIVITY -> nextStateAfterActivity(oldAction, now); - case CARTRIP -> nextStateAfterCarTrip(oldAction, now); - case NONCARTRIP -> nextStateAfterNonCarTrip(oldAction, now); - case PARKACTIVITY -> nextStateAfterParkActivity(oldAction, now); - case UNPARKACTIVITY -> nextStateAfterUnParkActivity(oldAction, now); - case WALKFROMPARK -> nextStateAfterWalkFromPark(oldAction, now); - case WALKTOPARK -> nextStateAfterWalkToPark(oldAction, now); - }; + return switch (lastParkActionState) { + case ACTIVITY -> nextStateAfterActivity(oldAction, now); + case CARTRIP -> nextStateAfterCarTrip(oldAction, now); + case NONCARTRIP -> nextStateAfterNonCarTrip(oldAction, now); + case PARKACTIVITY -> nextStateAfterParkActivity(oldAction, now); + case UNPARKACTIVITY -> nextStateAfterUnParkActivity(oldAction, now); + case WALKFROMPARK -> nextStateAfterWalkFromPark(oldAction, now); + case WALKTOPARK -> nextStateAfterWalkToPark(oldAction, now); + }; - } + } protected DynAction nextStateAfterUnParkActivity(DynAction oldAction, double now) { // we have unparked, now we need to get going by car again. @@ -164,7 +157,9 @@ protected DynAction nextStateAfterUnParkActivity(DynAction oldAction, double now //this could be Car, Carsharing, Motorcylce, or whatever else mode we have, so we want our leg to reflect this. return new ParkingDynLeg(currentLeg.getMode(), actualRoute, parkingLogic, parkingManager, currentlyAssignedVehicleId, timer, events); - } else throw new RuntimeException("parking location mismatch"); + } else { + throw new RuntimeException("parking location mismatch"); + } } @@ -175,19 +170,25 @@ protected DynAction nextStateAfterWalkToPark(DynAction oldAction, double now) { } protected DynAction nextStateAfterWalkFromPark(DynAction oldAction, double now) { - //walkleg complete, time to get the next activity from the plan Elements and start it, this is basically the same as arriving on any other mode + //walkleg complete, time to get the next activity from the plan Elements and start it, this is basically the same as arriving on any other + // mode return nextStateAfterNonCarTrip(oldAction, now); } protected DynAction nextStateAfterParkActivity(DynAction oldAction, double now) { // add a walk leg after parking Leg currentPlannedLeg = (Leg) currentPlanElement; + + // yyyy I think we don't want LinkWrapperFacilities but the actual facilities. Right now, only calculates the teleportation from link to + // link, but if the parking happens on the same link as the activity, then it does not consider the coordinates. Thus, it produces a + // degenerated (0m and 0s) walk leg. paul, nov'24 Facility fromFacility = new LinkWrapperFacility(network.getLinks().get(agent.getCurrentLinkId())); Facility toFacility = new LinkWrapperFacility(network.getLinks().get(currentPlannedLeg.getRoute().getEndLinkId())); List walkTrip = walkRouter.calcRoute( DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, now, plan.getPerson())); if (walkTrip.size() != 1 || !(walkTrip.get(0) instanceof Leg walkLeg)) { - String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to access the network. Not implemented in parking yet!"; + String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to " + + "access the network. Not implemented in parking yet!"; log.error(message); throw new RuntimeException(message); } @@ -224,7 +225,9 @@ protected DynAction nextStateAfterCarTrip(DynAction oldAction, double now) { this.currentlyAssignedVehicleId = null; this.parkingLogic.reset(); return new IdleDynActivity(this.stageInteractionType, now + configGroup.getParkduration()); - } else throw new RuntimeException("No parking possible"); + } else { + throw new RuntimeException("No parking possible"); + } } protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { @@ -233,15 +236,22 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { planIndex++; this.currentPlanElement = plan.getPlanElements().get(planIndex); Leg currentLeg = (Leg) currentPlanElement; + + // yyyy can only handle car legs for parking :-( paul, nov'24 if (currentLeg.getMode().equals(TransportMode.car)) { Id vehicleId = Id.create(this.agent.getId(), Vehicle.class); Id parkLink = this.parkingManager.getVehicleParkingLocation(vehicleId); if (parkLink == null) { - //this is the first activity of a day and our parking manager does not provide informations about initial stages. We suppose the car is parked where we are + //this is the first activity of a day and our parking manager does not provide information about initial stages. We suppose the + // car is parked where we are parkLink = agent.getCurrentLinkId(); } + // yyyy I think we don't want LinkWrapperFacilities but the actual facilities. Right now, only calculates the teleportation from + // link to + // link, but if the parking happens on the same link as the activity, then it does not consider the coordinates. Thus, it produces a + // degenerated (0m and 0s) walk leg. paul, nov'24 Facility fromFacility = new LinkWrapperFacility(network.getLinks().get(agent.getCurrentLinkId())); Id teleportedParkLink = this.teleportationLogic.getVehicleLocation(agent.getCurrentLinkId(), vehicleId, parkLink, now, currentLeg.getMode()); @@ -249,7 +259,8 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { List walkTrip = walkRouter.calcRoute( DefaultRoutingRequest.withoutAttributes(fromFacility, toFacility, now, plan.getPerson())); if (walkTrip.size() != 1 || !(walkTrip.get(0) instanceof Leg walkLeg)) { - String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with non_network_walk to access the network. Not implemented in parking yet!"; + String message = "walkRouter returned something else than a single Leg, e.g. it routes walk on the network with " + + "non_network_walk to access the network. Not implemented in parking yet!"; log.error(message); throw new RuntimeException(message); } @@ -271,9 +282,11 @@ protected DynAction nextStateAfterActivity(DynAction oldAction, double now) { return new StaticPassengerDynLeg(currentLeg.getRoute(), currentLeg.getMode()); } - } else throw new RuntimeException( - "no more leg to follow but activity is ending\nLastPlanElement: " + currentPlanElement.toString() + "\n Agent " + this.agent.getId() + "\nTime: " + Time.writeTime( - now)); + } else { + throw new RuntimeException( + "no more leg to follow but activity is ending\nLastPlanElement: " + currentPlanElement.toString() + "\n Agent " + this.agent.getId() + + "\nTime: " + Time.writeTime(now)); + } } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ParkingListener.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ParkingListener.java deleted file mode 100644 index 41e370c8065..00000000000 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/evaluation/ParkingListener.java +++ /dev/null @@ -1,117 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2016 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.contrib.parking.parkingsearch.evaluation; - - -import com.google.inject.Inject; -import org.matsim.contrib.parking.parkingsearch.manager.FacilityBasedParkingManager; -import org.matsim.contrib.parking.parkingsearch.manager.ParkingSearchManager; -import org.matsim.core.controler.OutputDirectoryHierarchy; -import org.matsim.core.controler.events.IterationEndsEvent; -import org.matsim.core.controler.listener.IterationEndsListener; -import org.matsim.core.mobsim.framework.events.MobsimBeforeSimStepEvent; -import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; -import org.matsim.core.mobsim.framework.listeners.MobsimBeforeSimStepListener; -import org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener; -import org.matsim.core.mobsim.qsim.QSim; -import org.matsim.core.utils.io.IOUtils; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.List; - -/** - * @author jbischoff - * - */ - -public class ParkingListener implements IterationEndsListener, MobsimBeforeSimStepListener, MobsimInitializedListener { - - @Inject - ParkingSearchManager manager; - @Inject - OutputDirectoryHierarchy output; - - /* (non-Javadoc) - * @see org.matsim.core.controler.listener.IterationEndsListener#notifyIterationEnds(org.matsim.core.controler.events.IterationEndsEvent) - */ - @Override - public void notifyIterationEnds(IterationEndsEvent event) { - writeStats(manager.produceStatistics(), event.getIteration()); - writeStatsByTimesteps(((FacilityBasedParkingManager)manager).produceTimestepsStatistics(), event.getIteration()); - manager.reset(event.getIteration()); - } - - private void writeStatsByTimesteps(List produceBeneStatistics, int iteration) { - BufferedWriter bw = IOUtils.getBufferedWriter(output.getIterationFilename(iteration, "parkingStatsPerTimeSteps.csv")); - try { - - String header = "time;rejectedParkingRequest;foundParking;unpark"; - bw.write(header); - bw.newLine(); - for (String s : produceBeneStatistics){ - bw.write(s); - bw.newLine(); - } - bw.flush(); - bw.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - - /** - * @param produceStatistics - */ - private void writeStats(List produceStatistics, int iteration) { - BufferedWriter bw = IOUtils.getBufferedWriter(output.getIterationFilename(iteration, "parkingStats.csv")); - try { - - String header = "linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn"; - bw.write(header); - bw.newLine(); - for (String s : produceStatistics){ - bw.write(s); - bw.newLine(); - } - bw.flush(); - bw.close(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - - @Override - public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent event) { - ((FacilityBasedParkingManager) manager).checkFreeCapacitiesForWaitingVehicles((QSim) event.getQueueSimulation(), event.getSimulationTime()); - } - - @Override - public void notifyMobsimInitialized(final MobsimInitializedEvent e) { - QSim qSim = (QSim) e.getQueueSimulation(); - ((FacilityBasedParkingManager) manager).setQSim(qSim); - - } -} diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/FacilityBasedParkingManager.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/FacilityBasedParkingManager.java index 9b3b8eff107..8c8491381c3 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/FacilityBasedParkingManager.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/FacilityBasedParkingManager.java @@ -22,231 +22,232 @@ import com.google.inject.Inject; import org.apache.commons.lang3.mutable.MutableLong; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.dynagent.DynAgent; import org.matsim.contrib.parking.parkingsearch.ParkingUtils; import org.matsim.contrib.parking.parkingsearch.sim.ParkingSearchConfigGroup; +import org.matsim.core.controler.events.IterationEndsEvent; +import org.matsim.core.gbl.Gbl; +import org.matsim.core.mobsim.framework.events.MobsimBeforeSimStepEvent; +import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; import org.matsim.core.mobsim.qsim.QSim; import org.matsim.core.utils.misc.Time; import org.matsim.facilities.ActivityFacility; import org.matsim.facilities.ActivityOption; +import org.matsim.facilities.OpeningTime; import org.matsim.vehicles.Vehicle; import java.util.*; import java.util.Map.Entry; /** + * Manages vehicles parking actions at facilities or freely on the street. I.e. keeps track of the capacity of the facilities. This class has + * additional functionality: + * - It can handle parking reservations. + * - It triggers reporting of parking statistics. + * - It can handle vehicles waiting for a parking space. * + * * @author jbischoff, schlenther, Ricardo Ewert */ public class FacilityBasedParkingManager implements ParkingSearchManager { + private static final Logger logger = LogManager.getLogger(FacilityBasedParkingManager.class); + private static final int REPORTING_TIME_BIN_SIZE = 15 * 60; + + protected Map, ParkingFacilityInfo> infoByFacilityId = new HashMap<>(); + + protected Map, TreeMap>> waitingVehiclesByLinkId = new HashMap<>(); + protected Map, ActivityFacility> parkingFacilitiesById; + protected Map, Id> parkingFacilityLocationByVehicleId = new HashMap<>(); + protected Map, Id> parkingReservationByVehicleId = new HashMap<>(); + //stores the parking location of vehicles that are parked outside of facilities (e.g. at the side of a link. therefore, there are no capacity + // checks) + protected Map, Id> freeParkingLinkByVehicleId = new HashMap<>(); + protected Map, Set>> parkingFacilitiesByLink = new HashMap<>(); + protected ParkingSearchConfigGroup psConfigGroup; + private QSim qsim; - protected Map, Integer> capacity = new HashMap<>(); - protected Map, MutableLong> occupation = new HashMap<>(); - protected Map, MutableLong> reservationsRequests = new HashMap<>(); - protected Map, MutableLong> rejectedParkingRequest = new HashMap<>(); - protected Map, MutableLong> numberOfParkedVehicles = new HashMap<>(); - protected Map, MutableLong> numberOfWaitingActivities = new HashMap<>(); - protected Map, MutableLong> numberOfStaysFromGetOffUntilGetIn = new HashMap<>(); - protected Map, MutableLong> numberOfParkingBeforeGetIn = new HashMap<>(); - protected Map, TreeMap>> waitingVehicles = new HashMap<>(); + //The following maps are used for reporting + @Inject + private ParkingStatsWriter writer; protected TreeMap rejectedReservationsByTime = new TreeMap<>(); protected TreeMap foundParkingByTime = new TreeMap<>(); protected TreeMap unparkByTime = new TreeMap<>(); - protected Map, ActivityFacility> parkingFacilities; - protected Map, Id> parkingLocations = new HashMap<>(); - protected Map, Id> parkingReservation = new HashMap<>(); - protected Map, Id> parkingLocationsOutsideFacilities = new HashMap<>(); - protected Map, Set>> facilitiesPerLink = new HashMap<>(); - protected Network network; - protected ParkingSearchConfigGroup psConfigGroup; - protected boolean canParkOnlyAtFacilities; - private QSim qsim; - private final int maxSlotIndex; - private final int maxTime; - private final int timeBinSize; - private final int startTime; + private int reportingMaxSlotIndex; + private int reportingMaxTime; @Inject public FacilityBasedParkingManager(Scenario scenario) { - psConfigGroup = (ParkingSearchConfigGroup) scenario.getConfig().getModules().get( - ParkingSearchConfigGroup.GROUP_NAME); - canParkOnlyAtFacilities = psConfigGroup.getCanParkOnlyAtFacilities(); - this.network = scenario.getNetwork(); - parkingFacilities = scenario.getActivityFacilities() - .getFacilitiesForActivityType(ParkingUtils.ParkingStageInteractionType); - LogManager.getLogger(getClass()).info(parkingFacilities.toString()); - this.timeBinSize = 15 * 60; - this.maxTime = 24 * 3600 - 1; - this.maxSlotIndex = (this.maxTime / this.timeBinSize) + 1; - this.startTime = 9 * 3600; - - for (ActivityFacility fac : this.parkingFacilities.values()) { - Id linkId = fac.getLinkId(); - Set> parkingOnLink = new HashSet<>(); - if (this.facilitiesPerLink.containsKey(linkId)) { - parkingOnLink = this.facilitiesPerLink.get(linkId); - } - parkingOnLink.add(fac.getId()); - this.facilitiesPerLink.put(linkId, parkingOnLink); - this.waitingVehicles.computeIfAbsent(linkId, (k) -> new TreeMap<>()); - this.occupation.put(fac.getId(), new MutableLong(0)); - this.reservationsRequests.put(fac.getId(), new MutableLong(0)); - this.rejectedParkingRequest.put(fac.getId(), new MutableLong(0)); - this.numberOfParkedVehicles.put(fac.getId(), new MutableLong(0)); - this.numberOfWaitingActivities.put(fac.getId(), new MutableLong(0)); - this.numberOfStaysFromGetOffUntilGetIn.put(fac.getId(), new MutableLong(0)); - this.numberOfParkingBeforeGetIn.put(fac.getId(), new MutableLong(0)); - } - int slotIndex = getTimeSlotIndex(startTime); - while (slotIndex <= maxSlotIndex) { - rejectedReservationsByTime.put(slotIndex * timeBinSize, new MutableLong(0)); - foundParkingByTime.put(slotIndex * timeBinSize, new MutableLong(0)); - unparkByTime.put(slotIndex * timeBinSize, new MutableLong(0)); - slotIndex++; + psConfigGroup = (ParkingSearchConfigGroup) scenario.getConfig().getModules().get(ParkingSearchConfigGroup.GROUP_NAME); + parkingFacilitiesById = scenario.getActivityFacilities().getFacilitiesForActivityType(ParkingUtils.ParkingStageInteractionType); + + logger.info(parkingFacilitiesById.toString()); + + for (ActivityFacility fac : this.parkingFacilitiesById.values()) { + initParkingFacility(fac); } + + initReporting(scenario); } - @Override - public boolean reserveSpaceIfVehicleCanParkHere(Id vehicleId, Id linkId) { - boolean canPark = false; + private void initReporting(Scenario scenario) { + this.reportingMaxTime = (int) scenario.getConfig().qsim().getEndTime().seconds(); + this.reportingMaxSlotIndex = (this.reportingMaxTime / REPORTING_TIME_BIN_SIZE) + 1; + } - if (linkIdHasAvailableParkingForVehicle(linkId, vehicleId)) { - canPark = true; - // LogManager.getLogger(getClass()).info("veh: "+vehicleId+" link - // "+linkId + " can park "+canPark); - } + private void initParkingFacility(ActivityFacility fac) { + Id linkId = fac.getLinkId(); + Set> parkingOnLink = parkingFacilitiesByLink.getOrDefault(linkId, new HashSet<>()); + parkingOnLink.add(fac.getId()); + this.parkingFacilitiesByLink.put(linkId, parkingOnLink); + this.waitingVehiclesByLinkId.put(linkId, new TreeMap<>()); - return canPark; + ActivityOption activityOption = fac.getActivityOptions().get(ParkingUtils.ParkingStageInteractionType); + this.infoByFacilityId.put(fac.getId(), new ParkingFacilityInfo(activityOption)); + } + + @Override + public boolean reserveSpaceIfVehicleCanParkHere(Id vehicleId, Id linkId) { + return linkIdHasAvailableParkingForVehicle(linkId, vehicleId); } /** * Checks if it is possible if you can park at this link for the complete time. - * - * @param linkId - * @param stopDuration - * @param getOffDuration - * @param pickUpDuration - * @param now - * @return */ - public boolean canParkAtThisFacilityUntilEnd(Id linkId, double stopDuration, double getOffDuration, double pickUpDuration, double now) { - Set> facilities = this.facilitiesPerLink.get(linkId); - if (facilities != null) { - double totalNeededParkingDuration = getOffDuration + stopDuration + pickUpDuration; - for (Id facility : facilities) { - double maxParkingDurationAtFacilityInHours = Double.MAX_VALUE; - if (this.parkingFacilities.get(facility).getAttributes().getAsMap().containsKey("maxParkingDurationInHours")) - maxParkingDurationAtFacilityInHours = 3600 * (double) this.parkingFacilities.get(facility).getAttributes().getAsMap().get( - "maxParkingDurationInHours"); - if (maxParkingDurationAtFacilityInHours > totalNeededParkingDuration) { - ActivityOption parkingOptions = this.parkingFacilities.get(facility).getActivityOptions().get("parking"); - if (!parkingOptions.getOpeningTimes().isEmpty()) { - if ((parkingOptions.getOpeningTimes().first().getStartTime() == 0 && parkingOptions.getOpeningTimes().first().getEndTime() == 24 * 3600)) - if (parkingOptions.getOpeningTimes().first().getStartTime() <= now && parkingOptions.getOpeningTimes().first().getEndTime() >= now + totalNeededParkingDuration) - return true; - } else - return true; + public boolean canParkAtThisFacilityUntilEnd(Id linkId, double now, double getOffDuration, double stopDuration, double pickUpDuration) { + Set> facilities = this.parkingFacilitiesByLink.get(linkId); + if (facilities == null) { + //TODO really? if there is no facility we assume free parking with no time constraint. + return false; + } + double totalDuration = getOffDuration + stopDuration + pickUpDuration; + for (Id facility : facilities) { + double maxParkingDurationAtFacilityInSeconds = + Optional.ofNullable(this.parkingFacilitiesById.get(facility).getAttributes().getAsMap().get("maxParkingDurationInHours")) + .map(attribute -> 3600 * (double) attribute).orElse(Double.MAX_VALUE); + + if (maxParkingDurationAtFacilityInSeconds < totalDuration) { + //Parking duration is limited, so we can't park here. + return false; + } + + ActivityOption parkingOptions = this.infoByFacilityId.get(facility).activityOption; + if (parkingOptions.getOpeningTimes().isEmpty()) { + //No opening times defined, so we can park here. + return true; + } + + OpeningTime firstOpeningTimes = parkingOptions.getOpeningTimes().first(); + //TODO do we really want this constraint? if parking facility has other opening times than 0-24, we can't park here. + if ((firstOpeningTimes.getStartTime() == 0 && firstOpeningTimes.getEndTime() == 24 * 3600)) { + if (firstOpeningTimes.getStartTime() <= now && firstOpeningTimes.getEndTime() >= now + totalDuration) { + //Parking facility is open for the complete duration, so we can park here. + return true; } } + } + //No parking facility is open for the complete duration, so we can't park here. return false; } + /** + * Either parks the vehicle at a link freely (no capacity constraint) or at a facility (capacity constraint). + */ private boolean linkIdHasAvailableParkingForVehicle(Id linkId, Id vid) { - // LogManager.getLogger(getClass()).info("link "+linkId+" vehicle "+vid); - if (!this.facilitiesPerLink.containsKey(linkId) && !canParkOnlyAtFacilities) { - // this implies: If no parking facility is present, we suppose that - // we can park freely (i.e. the matsim standard approach) - // it also means: a link without any parking spaces should have a - // parking facility with 0 capacity. - // LogManager.getLogger(getClass()).info("link not listed as parking - // space, we will say yes "+linkId); - - return true; - } else if (!this.facilitiesPerLink.containsKey(linkId)) { - return false; + if (!this.parkingFacilitiesByLink.containsKey(linkId)) { + // No parking facility at this link. Either parking is allowed only at facilities or not. + // If not, we can park freely, so link has available parking. (MATSim standard approach) + // If yes, we can't park here. + return !psConfigGroup.getCanParkOnlyAtFacilities(); } - Set> parkingFacilitiesAtLink = this.facilitiesPerLink.get(linkId); + Set> parkingFacilitiesAtLink = this.parkingFacilitiesByLink.get(linkId); for (Id fac : parkingFacilitiesAtLink) { - double cap = this.parkingFacilities.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType) - .getCapacity(); - this.reservationsRequests.get(fac).increment(); - if (this.occupation.get(fac).doubleValue() < cap) { - // LogManager.getLogger(getClass()).info("occ: - // "+this.occupation.get(fac).toString()+" cap: "+cap); - this.occupation.get(fac).increment(); - this.parkingReservation.put(vid, fac); - + if (this.infoByFacilityId.get(fac).park()) { + this.parkingReservationByVehicleId.put(vid, fac); return true; } - this.rejectedParkingRequest.get(fac).increment(); } return false; } @Override public Id getVehicleParkingLocation(Id vehicleId) { - if (this.parkingLocations.containsKey(vehicleId)) { - return this.parkingFacilities.get(this.parkingLocations.get(vehicleId)).getLinkId(); - } else return this.parkingLocationsOutsideFacilities.getOrDefault(vehicleId, null); + if (this.parkingFacilityLocationByVehicleId.containsKey(vehicleId)) { + //parked at facility + return this.parkingFacilitiesById.get(this.parkingFacilityLocationByVehicleId.get(vehicleId)).getLinkId(); + } else { + //parked freely + return this.freeParkingLinkByVehicleId.getOrDefault(vehicleId, null); + } } + /** + * Parks a vehicle at a link. Either freely outside a facility or at a facility. + */ @Override public boolean parkVehicleHere(Id vehicleId, Id linkId, double time) { return parkVehicleAtLink(vehicleId, linkId, time); } protected boolean parkVehicleAtLink(Id vehicleId, Id linkId, double time) { - Set> parkingFacilitiesAtLink = this.facilitiesPerLink.get(linkId); + Set> parkingFacilitiesAtLink = this.parkingFacilitiesByLink.get(linkId); if (parkingFacilitiesAtLink == null) { - this.parkingLocationsOutsideFacilities.put(vehicleId, linkId); + //park freely + this.freeParkingLinkByVehicleId.put(vehicleId, linkId); return true; - } else { - Id fac = this.parkingReservation.remove(vehicleId); - if (fac != null) { - this.parkingLocations.put(vehicleId, fac); - this.numberOfParkedVehicles.get(fac).increment(); - foundParkingByTime.get(getTimeSlotIndex(time) * timeBinSize).increment(); - return true; - } else { - throw new RuntimeException("no parking reservation found for vehicle " + vehicleId.toString() - + " arrival on link " + linkId + " with parking restriction"); - } } + //park at facility + return parkVehicleInReservedFacility(vehicleId, linkId, time); + } + + private boolean parkVehicleInReservedFacility(Id vehicleId, Id linkId, double time) { + Id fac = this.parkingReservationByVehicleId.remove(vehicleId); + if (fac == null) { + throw new RuntimeException("no parking reservation found for vehicle " + vehicleId.toString() + + " arrival on link " + linkId + " with parking restriction"); + } + + Gbl.assertIf(parkingFacilitiesById.get(fac).getLinkId().equals(linkId)); + + this.parkingFacilityLocationByVehicleId.put(vehicleId, fac); + reportParking(time, fac); + return true; } + /** + * Unparks vehicle from a link. Either freely outside a facility or at a facility. + */ @Override public boolean unParkVehicleHere(Id vehicleId, Id linkId, double time) { - if (!this.parkingLocations.containsKey(vehicleId)) { - this.parkingLocationsOutsideFacilities.remove(vehicleId); - return true; - - // we assume the person parks somewhere else + if (!this.parkingFacilityLocationByVehicleId.containsKey(vehicleId)) { + //unpark freely + this.freeParkingLinkByVehicleId.remove(vehicleId); } else { - Id fac = this.parkingLocations.remove(vehicleId); - this.occupation.get(fac).decrement(); - unparkByTime.get(getTimeSlotIndex(time) * timeBinSize).increment(); - return true; + //unpark at facility + Id fac = this.parkingFacilityLocationByVehicleId.remove(vehicleId); + reportUnParking(time, fac); } + return true; } - @Override - public List produceStatistics() { + private List produceStatistics() { List stats = new ArrayList<>(); - for (Entry, MutableLong> e : this.occupation.entrySet()) { - Id linkId = this.parkingFacilities.get(e.getKey()).getLinkId(); - double capacity = this.parkingFacilities.get(e.getKey()).getActivityOptions() - .get(ParkingUtils.ParkingStageInteractionType).getCapacity(); - double x = this.parkingFacilities.get(e.getKey()).getCoord().getX(); - double y = this.parkingFacilities.get(e.getKey()).getCoord().getY(); - - String s = linkId.toString() + ";" + x + ";" + y + ";" + e.getKey().toString() + ";" + capacity + ";" + e.getValue().toString() + ";" + this.reservationsRequests.get( - e.getKey()).toString() + ";" + this.numberOfParkedVehicles.get(e.getKey()).toString() + ";" + this.rejectedParkingRequest.get( - e.getKey()).toString() + ";" + this.numberOfWaitingActivities.get( - e.getKey()).toString() + ";" + this.numberOfStaysFromGetOffUntilGetIn.get(e.getKey()).intValue() + ";" + this.numberOfParkingBeforeGetIn.get(e.getKey()).intValue(); + for (Entry, ParkingFacilityInfo> e : this.infoByFacilityId.entrySet()) { + Id linkId = this.parkingFacilitiesById.get(e.getKey()).getLinkId(); + double capacity = this.parkingFacilitiesById.get(e.getKey()).getActivityOptions() + .get(ParkingUtils.ParkingStageInteractionType).getCapacity(); + double x = this.parkingFacilitiesById.get(e.getKey()).getCoord().getX(); + double y = this.parkingFacilitiesById.get(e.getKey()).getCoord().getY(); + + String facilityId = e.getKey().toString(); + ParkingFacilityInfo info = e.getValue(); + String s = + linkId.toString() + ";" + x + ";" + y + ";" + facilityId + ";" + capacity + ";" + info.occupation + ";" + info.reservationRequests + + ";" + info.parkedVehiclesCount + ";" + info.rejectedParkingRequests + ";" + info.waitingActivitiesCount + ";" + + info.staysFromGetOffUntilGetIn + ";" + info.parkingBeforeGetInCount; stats.add(s); } return stats; @@ -266,10 +267,10 @@ public List produceTimestepsStatistics() { public double getNrOfAllParkingSpacesOnLink(Id linkId) { double allSpaces = 0; - Set> parkingFacilitiesAtLink = this.facilitiesPerLink.get(linkId); + Set> parkingFacilitiesAtLink = this.parkingFacilitiesByLink.get(linkId); if (!(parkingFacilitiesAtLink == null)) { for (Id fac : parkingFacilitiesAtLink) { - allSpaces += this.parkingFacilities.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType).getCapacity(); + allSpaces += this.parkingFacilitiesById.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType).getCapacity(); } } return allSpaces; @@ -277,97 +278,89 @@ public double getNrOfAllParkingSpacesOnLink(Id linkId) { public double getNrOfFreeParkingSpacesOnLink(Id linkId) { double allFreeSpaces = 0; - Set> parkingFacilitiesAtLink = this.facilitiesPerLink.get(linkId); + Set> parkingFacilitiesAtLink = this.parkingFacilitiesByLink.get(linkId); if (parkingFacilitiesAtLink == null) { return 0; } else { for (Id fac : parkingFacilitiesAtLink) { - int cap = (int) this.parkingFacilities.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType).getCapacity(); - allFreeSpaces += (cap - this.occupation.get(fac).intValue()); + int cap = (int) this.parkingFacilitiesById.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType).getCapacity(); + allFreeSpaces += (cap - this.infoByFacilityId.get(fac).occupation); } } return allFreeSpaces; } - public Map, ActivityFacility> getParkingFacilities() { - return this.parkingFacilities; + public Map, ActivityFacility> getParkingFacilitiesById() { + return this.parkingFacilitiesById; } public void registerRejectedReservation(double now) { - rejectedReservationsByTime.get(getTimeSlotIndex(now) * timeBinSize).increment(); - } - - public TreeSet getTimeSteps() { - TreeSet timeSteps = new TreeSet<>(); - int slotIndex = 0; - while (slotIndex <= maxSlotIndex) { - timeSteps.add(slotIndex * timeBinSize); - slotIndex++; - } - return timeSteps; + rejectedReservationsByTime.putIfAbsent(getTimeSlotIndex(now) * REPORTING_TIME_BIN_SIZE, new MutableLong(0)); + rejectedReservationsByTime.get(getTimeSlotIndex(now) * REPORTING_TIME_BIN_SIZE).increment(); } private int getTimeSlotIndex(final double time) { - if (time > this.maxTime) { - return this.maxSlotIndex; + if (time > this.reportingMaxTime) { + return this.reportingMaxSlotIndex; } - return ((int) time / this.timeBinSize); + return ((int) time / REPORTING_TIME_BIN_SIZE); } /** - * Gives the duration of the staging activity of parking - * - * @return + * Returns the duration of the staging activity of parking */ public double getParkStageActivityDuration() { return psConfigGroup.getParkduration(); } - /** - * Gives the duration of the staging activity of unparking - * - * @return - */ - public double getUnParkStageActivityDuration() { - return psConfigGroup.getUnparkduration(); - } - @Override public void reset(int iteration) { - for (Id fac : this.rejectedParkingRequest.keySet()) { - this.rejectedParkingRequest.get(fac).setValue(0); - this.reservationsRequests.get(fac).setValue(0); - this.numberOfParkedVehicles.get(fac).setValue(0); - this.numberOfWaitingActivities.get(fac).setValue(0); - } - waitingVehicles.clear(); + infoByFacilityId.replaceAll((k, v) -> new ParkingFacilityInfo(v.activityOption)); + waitingVehiclesByLinkId.clear(); } public void addVehicleForWaitingForParking(Id linkId, Id vehicleId, double now) { // System.out.println(now + ": vehicle " +vehicleId.toString() + " starts waiting here: " + linkId.toString()); - waitingVehicles.get(linkId).put(now + getParkStageActivityDuration() + 1, vehicleId); - for (Id fac : this.facilitiesPerLink.get(linkId)) { - this.numberOfWaitingActivities.get(fac).increment(); + waitingVehiclesByLinkId.get(linkId).put(now + getParkStageActivityDuration() + 1, vehicleId); + for (Id fac : this.parkingFacilitiesByLink.get(linkId)) { + this.infoByFacilityId.get(fac).waitingActivitiesCount++; break; } } + //@formatter:off + /** + * For all links l with waiting vehicles: + * For all facilities f located at l: + * While there is a free capacity at f and there are waiting vehicles: + * Remove the first waiting vehicle from the list of waiting vehicles. + * Reserve a parking space for this vehicle. + * End the activity of the vehicle. + * Reschedule the activity end of the vehicle. + * + */ + //@formatter:on public void checkFreeCapacitiesForWaitingVehicles(QSim qSim, double now) { - for (Id linkId : waitingVehicles.keySet()) { - if (!waitingVehicles.get(linkId).isEmpty()) { - for (Id fac : this.facilitiesPerLink.get(linkId)) { - int cap = (int) this.parkingFacilities.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType).getCapacity(); - while (this.occupation.get(fac).intValue() < cap && !waitingVehicles.get(linkId).isEmpty()) { - double startWaitingTime = waitingVehicles.get(linkId).firstKey(); - if (startWaitingTime > now) - break; - Id vehcileId = waitingVehicles.get(linkId).remove(startWaitingTime); - DynAgent agent = (DynAgent) qSim.getAgents().get(Id.createPersonId(vehcileId.toString())); - reserveSpaceIfVehicleCanParkHere(vehcileId, linkId); - agent.endActivityAndComputeNextState(now); - qsim.rescheduleActivityEnd(agent); + for (Id linkId : waitingVehiclesByLinkId.keySet()) { + TreeMap> vehicleIdByTime = waitingVehiclesByLinkId.get(linkId); + if (vehicleIdByTime.isEmpty()) { + break; + } + for (Id fac : this.parkingFacilitiesByLink.get(linkId)) { + int capacity = (int) this.parkingFacilitiesById.get(fac).getActivityOptions().get(ParkingUtils.ParkingStageInteractionType) + .getCapacity(); + + while (this.infoByFacilityId.get(fac).occupation < capacity && !vehicleIdByTime.isEmpty()) { + double startWaitingTime = vehicleIdByTime.firstKey(); + if (startWaitingTime > now) { + break; } + Id vehcileId = vehicleIdByTime.remove(startWaitingTime); + DynAgent agent = (DynAgent) qSim.getAgents().get(Id.createPersonId(vehcileId.toString())); + reserveSpaceIfVehicleCanParkHere(vehcileId, linkId); + agent.endActivityAndComputeNextState(now); + qsim.rescheduleActivityEnd(agent); } } } @@ -378,10 +371,69 @@ public void setQSim(QSim qSim) { } public void registerStayFromGetOffUntilGetIn(Id vehcileId) { - this.numberOfStaysFromGetOffUntilGetIn.get(parkingLocations.get(vehcileId)).increment(); + infoByFacilityId.get(parkingFacilityLocationByVehicleId.get(vehcileId)).staysFromGetOffUntilGetIn++; } public void registerParkingBeforeGetIn(Id vehcileId) { - this.numberOfParkingBeforeGetIn.get(parkingLocations.get(vehcileId)).increment(); + this.infoByFacilityId.get(parkingFacilityLocationByVehicleId.get(vehcileId)).parkingBeforeGetInCount++; + } + + private void reportParking(double time, Id fac) { + this.infoByFacilityId.get(fac).parkedVehiclesCount++; + int timeSlot = getTimeSlotIndex(time) * REPORTING_TIME_BIN_SIZE; + foundParkingByTime.putIfAbsent(timeSlot, new MutableLong(0)); + foundParkingByTime.get(timeSlot).increment(); + } + + private void reportUnParking(double time, Id fac) { + this.infoByFacilityId.get(fac).occupation--; + int timeSlot = getTimeSlotIndex(time) * REPORTING_TIME_BIN_SIZE; + unparkByTime.putIfAbsent(timeSlot, new MutableLong(0)); + unparkByTime.get(timeSlot).increment(); + } + + @Override + public void notifyIterationEnds(IterationEndsEvent event) { + writer.writeStatsByFacility(produceStatistics(), event.getIteration()); + writer.writeStatsByTimesteps(produceTimestepsStatistics(), event.getIteration()); + reset(event.getIteration()); + } + + + @Override + public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent event) { + checkFreeCapacitiesForWaitingVehicles((QSim) event.getQueueSimulation(), event.getSimulationTime()); + } + + @Override + public void notifyMobsimInitialized(final MobsimInitializedEvent e) { + QSim qSim = (QSim) e.getQueueSimulation(); + setQSim(qSim); + } + + protected static class ParkingFacilityInfo { + protected long occupation = 0; + protected final ActivityOption activityOption; + protected long reservationRequests = 0; + protected long rejectedParkingRequests = 0; + protected long parkedVehiclesCount = 0; + protected long waitingActivitiesCount = 0; + protected long staysFromGetOffUntilGetIn = 0; + protected long parkingBeforeGetInCount = 0; + + ParkingFacilityInfo(ActivityOption activityOption) { + this.activityOption = activityOption; + } + + protected boolean park() { + reservationRequests++; + //TODO check double vs long + if (occupation >= activityOption.getCapacity()) { + rejectedParkingRequests++; + return false; + } + occupation++; + return true; + } } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/LinkLengthBasedParkingManagerWithRandomInitialUtilisation.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/LinkLengthBasedParkingManagerWithRandomInitialUtilisation.java index 5600260ec7a..56f75d97d14 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/LinkLengthBasedParkingManagerWithRandomInitialUtilisation.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/LinkLengthBasedParkingManagerWithRandomInitialUtilisation.java @@ -19,42 +19,43 @@ package org.matsim.contrib.parking.parkingsearch.manager; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - import jakarta.inject.Inject; - import org.apache.commons.lang3.mutable.MutableLong; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; +import org.matsim.core.controler.events.IterationEndsEvent; import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.mobsim.framework.events.MobsimBeforeSimStepEvent; +import org.matsim.core.mobsim.framework.events.MobsimInitializedEvent; import org.matsim.vehicles.Vehicle; +import java.util.*; + /** - * @author jbischoff - * + * @author jbischoff */ public class LinkLengthBasedParkingManagerWithRandomInitialUtilisation implements ParkingSearchManager { - Map,Integer> capacity = new HashMap<>(); - Map,MutableLong> occupation = new HashMap<>(); - Map,Id> parkingPosition = new HashMap<>(); + Map, Integer> capacity = new HashMap<>(); + Map, MutableLong> occupation = new HashMap<>(); + Map, Id> parkingPosition = new HashMap<>(); Random rand = MatsimRandom.getLocalInstance(); int parkedVehicles = 0; int unparkedVehicles = 0; + + @Inject + private ParkingStatsWriter writer; + @Inject public LinkLengthBasedParkingManagerWithRandomInitialUtilisation(Network network, Config config) { - double assumedParkedVehicleLength = 4.0; - double shareOfLinkLengthUsedForParking = 0.7; + double assumedParkedVehicleLength = 4.0; + double shareOfLinkLengthUsedForParking = 0.7; - //TODO: Make this configurable - for (Link link : network.getLinks().values()){ - int maxCapacity = (int) (link.getLength()*shareOfLinkLengthUsedForParking / assumedParkedVehicleLength); + //TODO: Make this configurable + for (Link link : network.getLinks().values()) { + int maxCapacity = (int) (link.getLength() * shareOfLinkLengthUsedForParking / assumedParkedVehicleLength); this.capacity.put(link.getId(), maxCapacity); this.occupation.put(link.getId(), new MutableLong(rand.nextInt(maxCapacity))); @@ -63,7 +64,7 @@ public LinkLengthBasedParkingManagerWithRandomInitialUtilisation(Network network @Override public boolean reserveSpaceIfVehicleCanParkHere(Id vehicleId, Id linkId) { - return (this.occupation.get(linkId).intValue() getVehicleParkingLocation(Id vehicleId) { @Override public boolean parkVehicleHere(Id vehicleId, Id linkId, double time) { - if (this.occupation.get(linkId).intValue() vehicleId, Id linkId, double time) { - if (!linkId.equals(this.parkingPosition.get(vehicleId))) return false; - else { + if (!linkId.equals(this.parkingPosition.get(vehicleId))) { + return false; + } else { this.parkingPosition.remove(vehicleId); this.occupation.get(linkId).decrement(); unparkedVehicles++; @@ -95,11 +99,10 @@ public boolean unParkVehicleHere(Id vehicleId, Id linkId, double } - @Override public List produceStatistics() { List stats = new ArrayList<>(); - stats.add("parking occurences: "+ parkedVehicles); - stats.add("unparking occurences: "+ unparkedVehicles); + stats.add("parking occurences: " + parkedVehicles); + stats.add("unparking occurences: " + unparkedVehicles); return stats; } @@ -107,6 +110,18 @@ public List produceStatistics() { public void reset(int iteration) { } + @Override + public void notifyIterationEnds(IterationEndsEvent event) { + writer.writePlainStats(produceStatistics(), event.getIteration()); + } + + @Override + public void notifyMobsimBeforeSimStep(MobsimBeforeSimStepEvent e) { + } + + @Override + public void notifyMobsimInitialized(MobsimInitializedEvent e) { + } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingSearchManager.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingSearchManager.java index 7bdd6fb37c2..3cb029157f8 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingSearchManager.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingSearchManager.java @@ -19,25 +19,27 @@ package org.matsim.contrib.parking.parkingsearch.manager; -import java.util.List; - import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.network.Link; +import org.matsim.core.controler.listener.IterationEndsListener; +import org.matsim.core.mobsim.framework.listeners.MobsimBeforeSimStepListener; +import org.matsim.core.mobsim.framework.listeners.MobsimInitializedListener; import org.matsim.vehicles.Vehicle; /** - * @author jbischoff - * + * @author jbischoff */ -public interface ParkingSearchManager { +public interface ParkingSearchManager extends IterationEndsListener, MobsimBeforeSimStepListener, MobsimInitializedListener { boolean reserveSpaceIfVehicleCanParkHere(Id vehicleId, Id linkId); + Id getVehicleParkingLocation(Id vehicleId); + boolean parkVehicleHere(Id vehicleId, Id linkId, double time); + boolean unParkVehicleHere(Id vehicleId, Id linkId, double time); - - List produceStatistics(); + void reset(int iteration); - - + + } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingStatsWriter.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingStatsWriter.java new file mode 100644 index 00000000000..9b929dc53c3 --- /dev/null +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ParkingStatsWriter.java @@ -0,0 +1,74 @@ +package org.matsim.contrib.parking.parkingsearch.manager; + +import com.google.inject.Inject; +import org.matsim.core.controler.OutputDirectoryHierarchy; +import org.matsim.core.utils.io.IOUtils; + +import java.io.BufferedWriter; +import java.io.IOException; +import java.util.List; + +//the functionality of this class is mainly copied from old ParkingListener and could be improved +public class ParkingStatsWriter { + @Inject + OutputDirectoryHierarchy output; + + public void writeStatsByTimesteps(List produceBeneStatistics, int iteration) { + BufferedWriter bw = IOUtils.getBufferedWriter(output.getIterationFilename(iteration, "parkingStatsPerTimeSteps.csv")); + try { + + String header = "time;rejectedParkingRequest;foundParking;unpark"; + bw.write(header); + bw.newLine(); + for (String s : produceBeneStatistics) { + bw.write(s); + bw.newLine(); + } + bw.flush(); + bw.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + /** + * @param produceStatistics + */ + public void writeStatsByFacility(List produceStatistics, int iteration) { + BufferedWriter bw = IOUtils.getBufferedWriter(output.getIterationFilename(iteration, "parkingStats.csv")); + try { + + String header = "linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;" + + "numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn"; + bw.write(header); + bw.newLine(); + for (String s : produceStatistics) { + bw.write(s); + bw.newLine(); + } + bw.flush(); + bw.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writePlainStats(List produceStatistics, int iteration) { + BufferedWriter bw = IOUtils.getBufferedWriter(output.getIterationFilename(iteration, "parkingStats.txt")); + try { + for (String s : produceStatistics) { + bw.write(s); + bw.newLine(); + } + bw.flush(); + bw.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ZoneParkingManager.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ZoneParkingManager.java index b9fbebe4699..5dc503ac08a 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ZoneParkingManager.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/manager/ZoneParkingManager.java @@ -19,13 +19,16 @@ import java.util.Set; /** + * Extends the facility based manager, thus parks vehicles at facilities but also keeps track of the occupancy of zones. A zone is defined by a set + * of links. + * * @author tschlenther */ public class ZoneParkingManager extends FacilityBasedParkingManager { - private HashMap>> linksOfZone; - private HashMap totalCapOfZone; - private HashMap occupationOfZone; + private final HashMap>> linksByZone; + private final HashMap totalCapByZone; + private final HashMap occupationByZone; /** * @param scenario @@ -34,17 +37,17 @@ public class ZoneParkingManager extends FacilityBasedParkingManager { public ZoneParkingManager(Scenario scenario, String[] pathToZoneTxtFiles) { super(scenario); - this.linksOfZone = new HashMap>>(); - this.totalCapOfZone = new HashMap(); - this.occupationOfZone = new HashMap(); + this.linksByZone = new HashMap>>(); + this.totalCapByZone = new HashMap(); + this.occupationByZone = new HashMap(); for (String zone : pathToZoneTxtFiles) { readZone(zone); } - for (String zone : this.linksOfZone.keySet()) { + for (String zone : this.linksByZone.keySet()) { calculateTotalZoneParkCapacity(zone); - this.occupationOfZone.put(zone, 0.0); + this.occupationByZone.put(zone, 0.0); } } @@ -52,6 +55,7 @@ public ZoneParkingManager(Scenario scenario, String[] pathToZoneTxtFiles) { /** * reads in a tabular file that declares which link id's are in the monitored zone * the part between the last '/' and the file type extension in the given path is considered to be the zone name + * * @param pathToZoneFile */ void readZone(String pathToZoneFile) { @@ -72,61 +76,64 @@ public void startRow(String[] row) { }); - this.linksOfZone.put(zone, links); + this.linksByZone.put(zone, links); } private void calculateTotalZoneParkCapacity(String zoneName) { double cap = 0.0; - for (Id link : this.linksOfZone.get(zoneName)) { + for (Id link : this.linksByZone.get(zoneName)) { cap += getNrOfAllParkingSpacesOnLink(link); } - this.totalCapOfZone.put(zoneName, cap); + this.totalCapByZone.put(zoneName, cap); } @Override public boolean parkVehicleHere(Id vehicleId, Id linkId, double time) { if (parkVehicleAtLink(vehicleId, linkId, time)) { - for (String zone : this.linksOfZone.keySet()) { - if (linksOfZone.get(zone).contains(linkId) && this.facilitiesPerLink.containsKey(linkId)) { - double newOcc = this.occupationOfZone.get(zone) + 1; - if (this.totalCapOfZone.get(zone) < newOcc) { - String s = "FacilityID: " + this.parkingLocations.get(vehicleId); - String t = "Occupied: " + this.occupation.get(this.parkingLocations.get(vehicleId)); - String u = "Capacity: " + this.parkingFacilities.get(this.parkingLocations.get(vehicleId)).getActivityOptions().get( - ParkingUtils.ParkingStageInteractionType).getCapacity(); + for (String zone : this.linksByZone.keySet()) { + if (linksByZone.get(zone).contains(linkId) && this.parkingFacilitiesByLink.containsKey(linkId)) { + double newOcc = this.occupationByZone.get(zone) + 1; + if (this.totalCapByZone.get(zone) < newOcc) { + String s = "FacilityID: " + this.parkingFacilityLocationByVehicleId.get(vehicleId); + String t = "Occupied: " + this.infoByFacilityId.get(this.parkingFacilityLocationByVehicleId.get(vehicleId)).occupation; + String u = + "Capacity: " + this.parkingFacilitiesById.get(this.parkingFacilityLocationByVehicleId.get(vehicleId)).getActivityOptions() + .get( + ParkingUtils.ParkingStageInteractionType).getCapacity(); String v = "TotalCapacityOnLink: " + getNrOfAllParkingSpacesOnLink(linkId); - throw new RuntimeException("occupancy of zone " + zone + " is higher than 100%. Capacity= " + this.totalCapOfZone.get( + throw new RuntimeException("occupancy of zone " + zone + " is higher than 100%. Capacity= " + this.totalCapByZone.get( zone) + " occupancy=" + newOcc + "time = " + time + "\n" + s + "\n" + t + "\n" + u + "\n" + v); } - this.occupationOfZone.put(zone, newOcc); + this.occupationByZone.put(zone, newOcc); return true; // assumes: link is only part of exactly 1 zone } } return true; - } else + } else { return false; + } } @Override public boolean unParkVehicleHere(Id vehicleId, Id linkId, double time) { - if (!this.parkingLocations.containsKey(vehicleId)) { + if (!this.parkingFacilityLocationByVehicleId.containsKey(vehicleId)) { return true; // we assume the person parks somewhere else } else { - Id fac = this.parkingLocations.remove(vehicleId); - this.occupation.get(fac).decrement(); + Id fac = this.parkingFacilityLocationByVehicleId.remove(vehicleId); + this.infoByFacilityId.get(fac).occupation--; - Id parkingLink = this.parkingFacilities.get(fac).getLinkId(); - for (String zone : this.linksOfZone.keySet()) { - if (linksOfZone.get(zone).contains(parkingLink)) { - double newOcc = this.occupationOfZone.get(zone) - 1; + Id parkingLink = this.parkingFacilitiesById.get(fac).getLinkId(); + for (String zone : this.linksByZone.keySet()) { + if (linksByZone.get(zone).contains(parkingLink)) { + double newOcc = this.occupationByZone.get(zone) - 1; if (newOcc < 0) { //in iteration 0 agents can "leave parking spaces" (get into traffic), but the manager didn't record them to be parked newOcc = 0; } - this.occupationOfZone.put(zone, newOcc); + this.occupationByZone.put(zone, newOcc); } } return true; @@ -135,18 +142,19 @@ public boolean unParkVehicleHere(Id vehicleId, Id linkId, double public double getOccupancyRatioOfZone(String zone) { - if (!(this.linksOfZone.keySet().contains(zone))) + if (!(this.linksByZone.keySet().contains(zone))) { throw new RuntimeException("zone " + zone + " was not defined. thus, could'nt calculate occupancy ratio."); + } - return (this.occupationOfZone.get(zone) / this.totalCapOfZone.get(zone)); + return (this.occupationByZone.get(zone) / this.totalCapByZone.get(zone)); } public Set getZones() { - return this.linksOfZone.keySet(); + return this.linksByZone.keySet(); } public double getTotalCapacityOfZone(String zone) { - return this.totalCapOfZone.get(zone); + return this.totalCapByZone.get(zone); } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/BenensonParkingSearchLogic.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/BenensonParkingSearchLogic.java index 6b8d1f7bcff..adb5ee1dbb8 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/BenensonParkingSearchLogic.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/BenensonParkingSearchLogic.java @@ -19,58 +19,57 @@ /** * @author schlenther - * - *the matsim version of the parking strategy used in PARKAGENT. see the following paper for more information: - *doi: 10.1016/j.compenvurbsys.2008.09.011 - * + *

+ * the matsim version of the parking strategy used in PARKAGENT. see the following paper for more information: + * doi: 10.1016/j.compenvurbsys.2008.09.011 */ public class BenensonParkingSearchLogic implements ParkingSearchLogic { private static final Logger logger = LogManager.getLogger(BenensonDynLeg.class); private static final boolean logForDebug = false; - + private Network network; private static final double MIN_THRESHOLD_PROB_FUNCTION = 2; private static final double MAX_THRESHOLD_PROB_FUNCTION = 4; - //thresholds for phase transitions: 1->2 and 2->3 + //thresholds for phase transitions: 1->2 and 2->3 private static final double THRESHOLD_OBSERVING_METER = 1000; private static final double THRESHOLD_PARKING_METER = 500; - + private static final double ACCEPTED_DISTANCE_START = 100; private static final double ACCEPTED_DISTANCE_INCREASING_RATE_PER_MIN = 100; private static final double ACCEPTED_DISTANCE_MAX = 600; - + private final Random random = MatsimRandom.getLocalInstance(); - + private ParkingSearchConfigGroup configGroup; - + public BenensonParkingSearchLogic(Network network, ParkingSearchConfigGroup cfgGroup) { this.network = network; this.configGroup = cfgGroup; } - + @Override public void reset() { } - //----------------------------------------------------phase transitions---------------------------------------------------------------------------- + //----------------------------------------------------phase + // transitions---------------------------------------------------------------------------- - public boolean transitionToObservingBehaviour(Id currLinkId, Id endLinkId) { + public boolean transitionToObservingBehaviour(Id currLinkId, Id endLinkId) { double distToDest = NetworkUtils.getEuclideanDistance( - network.getLinks().get(currLinkId).getCoord(), network.getLinks().get(endLinkId).getCoord()); - return distToDest < THRESHOLD_OBSERVING_METER ; + network.getLinks().get(currLinkId).getCoord(), network.getLinks().get(endLinkId).getCoord()); + return distToDest < THRESHOLD_OBSERVING_METER; } - public boolean transitionToParkingBehaviour(Id currLinkId, Id endLinkId) { + public boolean transitionToParkingBehaviour(Id currLinkId, Id endLinkId) { double distToDest = NetworkUtils.getEuclideanDistance( - network.getLinks().get(currLinkId).getCoord(), network.getLinks().get(endLinkId).getCoord()); - return distToDest < THRESHOLD_PARKING_METER ; + network.getLinks().get(currLinkId).getCoord(), network.getLinks().get(endLinkId).getCoord()); + return distToDest < THRESHOLD_PARKING_METER; } - + //-------------------------------------------------------routing--------------------------------------------------------------------------- - + /** - * * @param currentLinkId * @param destinationLinkId * @return @@ -78,9 +77,9 @@ public boolean transitionToParkingBehaviour(Id currLinkId, Id endLin public Id getNextLinkBenensonRouting(Id currentLinkId, Id destinationLinkId, String mode) { Link currentLink = network.getLinks().get(currentLinkId); - //calculate the distance to fromNode of destination link instead of distance to activity + //calculate the distance to fromNode of destination link instead of distance to activity Node destination = network.getLinks().get(destinationLinkId).getFromNode(); - + double distanceToDest = Double.MAX_VALUE; Node nextNode; Id nextLinkId = null; @@ -91,13 +90,12 @@ public Id getNextLinkBenensonRouting(Id currentLinkId, Id dest return outLinkId; } nextNode = outLink.getToNode(); - double dd = NetworkUtils.getEuclideanDistance(destination.getCoord(),nextNode.getCoord()); - if( dd < distanceToDest){ + double dd = NetworkUtils.getEuclideanDistance(destination.getCoord(), nextNode.getCoord()); + if (dd < distanceToDest) { nextLinkId = outLinkId; distanceToDest = dd; - } - else if(dd == distanceToDest){ - if (Math.random() > 0.5){ + } else if (dd == distanceToDest) { + if (random.nextBoolean()) { nextLinkId = outLinkId; } } @@ -105,7 +103,8 @@ else if(dd == distanceToDest){ return nextLinkId; } - public Id getNextLinkRandomInAcceptableDistance(Id currentLinkId, Id endLinkId, Id vehicleId, double firstDestLinkEnterTime, double timeOfDay, String mode) { + public Id getNextLinkRandomInAcceptableDistance(Id currentLinkId, Id endLinkId, Id vehicleId, + double firstDestLinkEnterTime, double timeOfDay, String mode) { Link nextLink; Link currentLink = network.getLinks().get(currentLinkId); @@ -114,10 +113,14 @@ public Id getNextLinkRandomInAcceptableDistance(Id currentLinkId, Id int nrOfOutGoingLinks = outGoingLinks.size(); for (int i = 1; i <= nrOfOutGoingLinks; i++) { nextLink = outGoingLinks.get(random.nextInt(outGoingLinks.size())); - if (isDriverInAcceptableDistance(nextLink.getId(), endLinkId, firstDestLinkEnterTime, timeOfDay)) return nextLink.getId(); + if (isDriverInAcceptableDistance(nextLink.getId(), endLinkId, firstDestLinkEnterTime, timeOfDay)) { + return nextLink.getId(); + } outGoingLinks.remove(nextLink); - } - logger.error("vehicle " + vehicleId + " finds no outlink in acceptable distance going out from link " + currentLinkId + ". it just takes a random next link"); + } + logger.error("vehicle " + vehicleId + " finds no outlink in acceptable distance going out from link " + currentLinkId + ". it just takes a" + + " " + + "random next link"); return outGoingLinksCopy.get(random.nextInt(outGoingLinksCopy.size())).getId(); } @@ -125,63 +128,70 @@ public Id getNextLinkRandomInAcceptableDistance(Id currentLinkId, Id //---------------------------------------------------park decision----------------------------------------------------------------------- /** - * * estimate amount of free parking spaces on the way to destination Link and decide whether to park on currentLink - * + * * @param pUnoccupied * @param currentLinkId * @param endLinkId - * @return whether vehicle should be parked here + * @return whether vehicle should be parked here */ - public boolean wantToParkHere (double pUnoccupied, Id currentLinkId, Id endLinkId) { - - //if pUnoccupied = 0, no free slot has been detected, so it is realistic to accept the very next free slot + public boolean wantToParkHere(double pUnoccupied, Id currentLinkId, Id endLinkId) { + + //if pUnoccupied = 0, no free slot has been detected, so it is realistic to accept the very next free slot double distToDest = NetworkUtils.getEuclideanDistance( - network.getLinks().get(currentLinkId).getToNode().getCoord(), network.getLinks().get(endLinkId).getToNode().getCoord()); - double expectedFreeSlots = (pUnoccupied*distToDest/configGroup.getAvgparkingslotlength()); - double rnd = Math.random(); - if (logForDebug) - logger.error("\n current link: " + currentLinkId + "\n expected slots: " + expectedFreeSlots + "\n probabilty to continue driving: " + getProbabilityOfContinuingToDrive(expectedFreeSlots) + "\n rnd: " + rnd); - return rnd >= getProbabilityOfContinuingToDrive(expectedFreeSlots); + network.getLinks().get(currentLinkId).getToNode().getCoord(), network.getLinks().get(endLinkId).getToNode().getCoord()); + double expectedFreeSlots = (pUnoccupied * distToDest / configGroup.getAvgparkingslotlength()); + double rnd = random.nextDouble(); + if (logForDebug) { + logger.error("\n current link: " + currentLinkId + "\n expected slots: " + expectedFreeSlots + "\n probabilty to continue driving: " + getProbabilityOfContinuingToDrive(expectedFreeSlots) + "\n rnd: " + rnd); + } + return rnd >= getProbabilityOfContinuingToDrive(expectedFreeSlots); } - + /** - * linear probability function, depending on maximum and minimum threshold + * linear probability function, depending on maximum and minimum threshold */ - private double getProbabilityOfContinuingToDrive(double expectedFreeSlots) { - - if (expectedFreeSlots < MIN_THRESHOLD_PROB_FUNCTION) return 0.0; - else if(expectedFreeSlots > MAX_THRESHOLD_PROB_FUNCTION) return 1.0; - - return (expectedFreeSlots-MIN_THRESHOLD_PROB_FUNCTION)/(MAX_THRESHOLD_PROB_FUNCTION-MIN_THRESHOLD_PROB_FUNCTION); + private double getProbabilityOfContinuingToDrive(double expectedFreeSlots) { + + if (expectedFreeSlots < MIN_THRESHOLD_PROB_FUNCTION) { + return 0.0; + } else if (expectedFreeSlots > MAX_THRESHOLD_PROB_FUNCTION) { + return 1.0; + } + + return (expectedFreeSlots - MIN_THRESHOLD_PROB_FUNCTION) / (MAX_THRESHOLD_PROB_FUNCTION - MIN_THRESHOLD_PROB_FUNCTION); } /** - * * @param currentLinkId * @param endLinkId - * @param firstDestLinkEnterTime + * @param firstDestLinkEnterTime * @param timeOfDay * @return */ - private boolean isDriverInAcceptableDistance(Id currentLinkId, Id endLinkId, double firstDestLinkEnterTime, double timeOfDay) { + private boolean isDriverInAcceptableDistance(Id currentLinkId, Id endLinkId, double firstDestLinkEnterTime, double timeOfDay) { // if we're on the destinationLink, we always want to park - if(currentLinkId.equals(endLinkId)) return true; - - double distToDest = NetworkUtils.getEuclideanDistance(network.getLinks().get(currentLinkId).getCoord(), network.getLinks().get(endLinkId).getCoord()); + if (currentLinkId.equals(endLinkId)) { + return true; + } + + double distToDest = NetworkUtils.getEuclideanDistance(network.getLinks().get(currentLinkId).getCoord(), network.getLinks().get(endLinkId) + .getCoord()); double timeSpent = timeOfDay - firstDestLinkEnterTime; double acceptedDistance = ACCEPTED_DISTANCE_START + ACCEPTED_DISTANCE_INCREASING_RATE_PER_MIN * (timeSpent / 60); - - if (acceptedDistance > ACCEPTED_DISTANCE_MAX) acceptedDistance = ACCEPTED_DISTANCE_MAX; - - if (distToDest <= acceptedDistance){ - if(logForDebug){ + + if (acceptedDistance > ACCEPTED_DISTANCE_MAX) { + acceptedDistance = ACCEPTED_DISTANCE_MAX; + } + + if (distToDest <= acceptedDistance) { + if (logForDebug) { logger.error(" distance between link " + currentLinkId + " and destLink " + endLinkId + ": " + distToDest); logger.error("accepted : " + acceptedDistance); logger.error("time spent: " + timeSpent); } - return true; + return true; } return false; } @@ -190,5 +200,5 @@ private boolean isDriverInAcceptableDistance(Id currentLinkId, Id en public Id getNextLink(Id currentLinkId, Id vehicleId, String mode) { throw new RuntimeException("this should not happen!"); } - + } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/DistanceMemoryParkingSearchLogic.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/DistanceMemoryParkingSearchLogic.java index c4616c7df1e..5529e5b3c0a 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/DistanceMemoryParkingSearchLogic.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/DistanceMemoryParkingSearchLogic.java @@ -1,5 +1,5 @@ /** - * + * */ package org.matsim.contrib.parking.parkingsearch.search; @@ -19,24 +19,24 @@ /** * @author tschlenther - * - *Agents drive to destination first. Knowledge about surrounding streets is assumed. If no parking slot is available, they always look - *for a slot on the one outgoing link that has the shortest distance to their destination and is unknown to them so far. If every outlink - *is known they choose the next link to search on randomly. - * + *

+ * Agents drive to destination first. Knowledge about surrounding streets is assumed. If no parking slot is available, they always look + * for a slot on the one outgoing link that has the shortest distance to their destination and is unknown to them so far. If every outlink + * is known they choose the next link to search on randomly. */ public class DistanceMemoryParkingSearchLogic implements ParkingSearchLogic { private static final Logger logger = LogManager.getLogger(DistanceMemoryParkingSearchLogic.class); - private static final boolean doLogging = false; - +// static { +// Configurator.setRootLevel(org.apache.logging.log4j.Level.DEBUG); +// } + private Network network; - private HashSet> knownLinks; - + private HashSet> knownLinks; + /** - * @param network - * + * @param network */ public DistanceMemoryParkingSearchLogic(Network network) { this.network = network; @@ -49,49 +49,50 @@ public Id getNextLink(Id currentLinkId, Id destLinkId, Id nextLink = null; - - if(doLogging) logger.info("number of outlinks of link " + currentLinkId + ": " + outLinks.size()); + + logger.debug("number of outlinks of link {}: {}", currentLinkId, outLinks.size()); for (Link outLink : outLinks) { Id outLinkId = outLink.getId(); - if (this.knownLinks.contains(outLinkId)) nrKnownLinks++; - else{ + if (this.knownLinks.contains(outLinkId)) { + nrKnownLinks++; + } else { double distToDest = NetworkUtils.getEuclideanDistance(outLink.getCoord(), network.getLinks().get(destLinkId).getCoord()); - if (distToDest < shortestDistance){ + if (distToDest < shortestDistance) { nextLink = outLinkId; shortestDistance = distToDest; - if(doLogging) logger.info("currently chosen link: " + nextLink + " distToDest: " + shortestDistance); - } - else if(distToDest == shortestDistance){ + logger.debug("currently chosen link: {} distToDest: {}", nextLink, shortestDistance); + } else if (distToDest == shortestDistance) { String message = "link " + nextLink + " and link " + outLinkId + " both are " + distToDest + "m away from destination."; - if (Math.random() > 0.5) - nextLink = outLinkId; - if(doLogging) logger.info(message + " link " + nextLink + " is chosen."); - } - else{ - if (doLogging){ - logger.info("link " + outLinkId + " was not chosen because it is " + distToDest + "m away whereas shortest distance is " + shortestDistance); + if (MatsimRandom.getRandom().nextBoolean()) { + nextLink = outLinkId; } + logger.debug("{} link {} is chosen.", message, nextLink); + } else { + logger.debug("link {} was not chosen because it is {}m away whereas shortest distance is {}", outLinkId, distToDest, + shortestDistance); } } } - if(doLogging)logger.error("vehicle " + vehicleId + " knew " + nrKnownLinks + " out of " + outLinks.size() + " outlinks of link " + currentLinkId); - if(outLinks.size() == nrKnownLinks ){ - if(doLogging)logger.error("vehicle " + vehicleId + " knows all outlinks of link " + currentLinkId); - + logger.debug("vehicle {} knew {} out of {} outlinks of link {}", vehicleId, nrKnownLinks, outLinks.size(), currentLinkId); + if (outLinks.size() == nrKnownLinks) { + logger.debug("vehicle {} knows all outlinks of link {}", vehicleId, currentLinkId); + //return random Link int index = MatsimRandom.getRandom().nextInt(outLinks.size()); Iterator iter = outLinks.iterator(); for (int i = 0; i < index; i++) { - iter.next(); + iter.next(); } nextLink = iter.next().getId(); - } - - if(nextLink == null){ - throw new RuntimeException("the next Link Id for vehicle " + vehicleId + " on current link " + currentLinkId + " couldn't be calculated."); } - if(doLogging)logger.error("vehicle " + vehicleId + " takes link " + nextLink + " as next link"); + + if (nextLink == null) { + throw new RuntimeException("the next Link Id for vehicle " + vehicleId + " on current link " + currentLinkId + " couldn't be " + + "calculated" + + "."); + } + logger.debug("vehicle {} takes link {} as next link", vehicleId, nextLink); this.knownLinks.add(nextLink); return nextLink; } @@ -105,8 +106,8 @@ public Id getNextLink(Id currentLinkId, Id vehicleId, Strin throw new RuntimeException("shouldn't happen - method not implemented"); } - public void addToKnownLinks(Id linkId){ + public void addToKnownLinks(Id linkId) { this.knownLinks.add(linkId); } - + } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/NearestParkingSpotSearchLogic.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/NearestParkingSpotSearchLogic.java index d87bf0408fe..de4be67c97f 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/NearestParkingSpotSearchLogic.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/search/NearestParkingSpotSearchLogic.java @@ -69,7 +69,7 @@ public NearestParkingSpotSearchLogic(Network network, ParkingRouter parkingRoute this.parkingManager = parkingManager; this.canReserveParkingSlot = canReserveParkingSlot; this.canCheckParkingCapacitiesInAdvanced = canCheckParkingCapacitiesInAdvanced; - activityFacilities = ((FacilityBasedParkingManager) parkingManager).getParkingFacilities(); + activityFacilities = ((FacilityBasedParkingManager) parkingManager).getParkingFacilitiesById(); currentLinkIdx = 0; triedParking = new HashSet<>(); nextLink = null; @@ -83,26 +83,30 @@ public Id getNextLink(Id currentLinkId, Id baseLinkId, Id getNextLink(Id currentLinkId, Id baseLinkId, Id baseLinkId, Coord coordOfAttraction) { for (ActivityFacility activityFacility : activityFacilities.values()) { - if (activityFacility.getLinkId().equals(baseLinkId)) + if (activityFacility.getLinkId().equals(baseLinkId)) { distanceFromBaseToAttraction = NetworkUtils.getEuclideanDistance(activityFacility.getCoord(), coordOfAttraction); + } } } /** - * Checks if it is possible to drive to the new parking facility and to drive back to the base without extending the startTime of the following activity. + * Checks if it is possible to drive to the new parking facility and to drive back to the base without extending the startTime of the following + * activity. * If the resulting parking time at the new facility is less then 5 minutes the vehicle will drive directly to the next activity location. * * @param currentLinkId @@ -148,17 +154,20 @@ private void findDistanceBetweenBaseLinkAndAttraction(Id baseLinkId, Coord private void checkIfDrivingToNextParkingLocationIsPossible(Id currentLinkId, Id baseLinkId, double now, double nextPickupTime) { double expectedTravelTimeFromParkingToBase; - if (actualRoute == null) + if (actualRoute == null) { expectedTravelTimeFromParkingToBase = this.parkingRouter.getRouteFromParkingToDestination(baseLinkId, now, currentLinkId).getTravelTime().seconds(); //TODO better: use the nextLink for the check - else + } else { expectedTravelTimeFromParkingToBase = this.parkingRouter.getRouteFromParkingToDestination(baseLinkId, now, actualRoute.getEndLinkId()).getTravelTime().seconds(); + } double minimumExpectedParkingDuration = 5 * 60; double travelTimeNextPart; - if (actualRoute == null) + if (actualRoute == null) { travelTimeNextPart = 0.; - else travelTimeNextPart = actualRoute.getTravelTime().seconds(); + } else { + travelTimeNextPart = actualRoute.getTravelTime().seconds(); + } if ((nextPickupTime - now - travelTimeNextPart - expectedTravelTimeFromParkingToBase) < minimumExpectedParkingDuration) { actualRoute = this.parkingRouter.getRouteFromParkingToDestination(baseLinkId, now, @@ -168,8 +177,9 @@ private void checkIfDrivingToNextParkingLocationIsPossible(Id currentLinkI } public Id getNextParkingLocation() { - if (actualRoute == null) + if (actualRoute == null) { return null; + } return actualRoute.getEndLinkId(); } @@ -208,34 +218,42 @@ private NetworkRoute findRouteToNearestParkingFacility(Id baseLinkId, Id now && parkingOptions.getOpeningTimes().first().getEndTime() < latestEndOfParking) + if (parkingOptions.getOpeningTimes().first().getStartTime() > now && parkingOptions.getOpeningTimes().first() + .getEndTime() < latestEndOfParking) { continue; + } } //check if approx. the max parking time at facility will not exceed, assumption: "parking duration - 30 minutes" is parking Time. if (activityFacility.getAttributes().getAsMap().containsKey("maxParkingDurationInHours")) { //TODO vielleicht etwas sparsamer machen double maxParkingDurationAtFacility = 3600 * (double) activityFacility.getAttributes().getAsMap().get("maxParkingDurationInHours"); - if (maxParkingDuration - 30*60 > maxParkingDurationAtFacility) + if (maxParkingDuration - 30 * 60 > maxParkingDurationAtFacility) { continue; + } } //TODO beschreiben was passiert if (passangerInteractionAtParkingFacilityAtEndOfLeg) { double distanceBetweenThisParkingFacilityAndTheAttraction = NetworkUtils.getEuclideanDistance(activityFacility.getCoord(), coordOfAttraction); - if (distanceBetweenThisParkingFacilityAndTheAttraction - distanceFromBaseToAttraction > maxDistanceFromBase) + if (distanceBetweenThisParkingFacilityAndTheAttraction - distanceFromBaseToAttraction > maxDistanceFromBase) { continue; + } } // create Euclidean distances to the parking activities to find routes only to the nearest facilities in the next step Coord coordBaseLink = network.getLinks().get(baseLinkId).getCoord(); @@ -243,10 +261,11 @@ private NetworkRoute findRouteToNearestParkingFacility(Id baseLinkId, Id baseLinkId, Id maxParkingDurationAtFacility) + if (expectedParkingTime > maxParkingDurationAtFacility) { continue; + } } counter++; - if (passangerInteractionAtParkingFacilityAtEndOfLeg && euclideanDistanceToParkingFacilities.size() > triedParking.size()) - if (triedParking.contains(activityFacility.getId())) + if (passangerInteractionAtParkingFacilityAtEndOfLeg && euclideanDistanceToParkingFacilities.size() > triedParking.size()) { + if (triedParking.contains(activityFacility.getId())) { continue; - if (passangerInteractionAtParkingFacilityAtEndOfLeg && euclideanDistanceToParkingFacilities.size() == triedParking.size()) + } + } + if (passangerInteractionAtParkingFacilityAtEndOfLeg && euclideanDistanceToParkingFacilities.size() == triedParking.size()) { triedParking.clear(); + } NetworkRoute possibleRoute = this.parkingRouter.getRouteFromParkingToDestination(activityFacility.getLinkId(), now, currentLinkId); // reason is that we expect that the driver will always take the nearest possible getOff point to reduce the walk distance for the guests - if (passangerInteractionAtParkingFacilityAtEndOfLeg){ + if (passangerInteractionAtParkingFacilityAtEndOfLeg) { selectedRoute = possibleRoute; nearstActivityFacility = activityFacility; break; @@ -292,8 +315,9 @@ private NetworkRoute findRouteToNearestParkingFacility(Id baseLinkId, Id getComments() { - Map map = super.getComments(); + Map map = super.getComments(); map.put(UNPARKDURATION, "Duration to unpark a vehicle"); map.put(PARKDURATION, "Duration to park a vehicle"); - map.put(PARKINGSEARCH_STRATEGY, "The strategy to find a parking slot. Possible strategies: " + Arrays.toString(ParkingSearchStrategy.values())); + map.put(PARKINGSEARCH_STRATEGY, + "The strategy to find a parking slot. Possible strategies: " + Arrays.toString(ParkingSearchStrategy.values())); map.put(PARKINGSEARCH_MANAGER, "The type of the ParkingManager, may have the values: " + Arrays.toString(ParkingSearchManagerType.values())); - map.put(FRACTION_CAN_CHECK_FREE_CAPACITIES_IN_ADVANCED, "Fraction of agents who can check free capacities in advanced. This is currently developed for the FacilityBasedParkingManager"); - map.put(FRACTION_CAN_RESERVE_PARKING_IN_ADVANCED, "Fraction of agents who can reserve free capacities in advanced. This is currently developed for the FacilityBasedParkingManager\""); - map.put(CAN_PARK_ONLY_AT_FACILITIES, "Set if a vehicle can park only at given parking facilities or it can park freely at a link without a facility."); + map.put(FRACTION_CAN_CHECK_FREE_CAPACITIES_IN_ADVANCED, "Fraction of agents who can check free capacities in advanced. This is currently " + + "developed for the FacilityBasedParkingManager"); + map.put(FRACTION_CAN_RESERVE_PARKING_IN_ADVANCED, "Fraction of agents who can reserve free capacities in advanced. This is currently " + + "developed for the FacilityBasedParkingManager\""); + map.put(CAN_PARK_ONLY_AT_FACILITIES, "Set if a vehicle can park only at given parking facilities or it can park freely at a link without a" + + " " + + "facility."); return map; } @@ -162,11 +170,16 @@ protected void checkConsistency(Config config) { super.checkConsistency(config); - if (getFractionCanCheckFreeCapacitiesInAdvanced() != 0. && !getParkingSearchManagerType().equals(ParkingSearchManagerType.FacilityBasedParkingManager)) - log.warn("Fraction of agents who can check free capacities in advanced has no impact on your selected ParkingSearchManagerType, because it is only implemented for the FacilityBasedParkingManager."); + if (getFractionCanCheckFreeCapacitiesInAdvanced() != 0. && !getParkingSearchManagerType().equals(ParkingSearchManagerType.FacilityBasedParkingManager)) { + log.warn("Fraction of agents who can check free capacities in advanced has no impact on your selected ParkingSearchManagerType, " + + "because" + + " " + + "it is only implemented for the FacilityBasedParkingManager."); + } - if (getFractionCanCheckFreeCapacitiesInAdvanced() + getFractionCanReserveParkingInAdvanced() > 1.0) - throw new RuntimeException( "The sum of " + FRACTION_CAN_RESERVE_PARKING_IN_ADVANCED + " and " + FRACTION_CAN_CHECK_FREE_CAPACITIES_IN_ADVANCED + " is > 1.0. This should not happen."); + if (getFractionCanCheckFreeCapacitiesInAdvanced() + getFractionCanReserveParkingInAdvanced() > 1.0) { + throw new RuntimeException("The sum of " + FRACTION_CAN_RESERVE_PARKING_IN_ADVANCED + " and " + FRACTION_CAN_CHECK_FREE_CAPACITIES_IN_ADVANCED + " is > 1.0. This should not happen."); + } } diff --git a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/sim/SetupParking.java b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/sim/SetupParking.java index 5d8c657d9bb..288434518b1 100644 --- a/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/sim/SetupParking.java +++ b/contribs/parking/src/main/java/org/matsim/contrib/parking/parkingsearch/sim/SetupParking.java @@ -22,6 +22,8 @@ */ package org.matsim.contrib.parking.parkingsearch.sim; +import com.google.inject.Key; +import com.google.inject.name.Names; import org.matsim.api.core.v01.TransportMode; import org.matsim.api.core.v01.network.Network; import org.matsim.contrib.dvrp.router.DvrpGlobalRoutingNetworkProvider; @@ -30,15 +32,15 @@ import org.matsim.contrib.dvrp.run.DvrpConfigGroup; import org.matsim.contrib.dvrp.run.DvrpModes; import org.matsim.contrib.dvrp.trafficmonitoring.DvrpTravelTimeModule; -import org.matsim.contrib.parking.parkingsearch.evaluation.ParkingListener; import org.matsim.contrib.parking.parkingsearch.manager.FacilityBasedParkingManager; import org.matsim.contrib.parking.parkingsearch.manager.ParkingSearchManager; +import org.matsim.contrib.parking.parkingsearch.manager.ParkingStatsWriter; import org.matsim.contrib.parking.parkingsearch.manager.vehicleteleportationlogic.VehicleTeleportationLogic; import org.matsim.contrib.parking.parkingsearch.manager.vehicleteleportationlogic.VehicleTeleportationToNearbyParking; import org.matsim.contrib.parking.parkingsearch.routing.ParkingRouter; import org.matsim.contrib.parking.parkingsearch.routing.WithinDayParkingRouter; import org.matsim.core.controler.AbstractModule; -import org.matsim.core.controler.Controler; +import org.matsim.core.controler.Controller; import org.matsim.core.mobsim.qsim.PopulationModule; import org.matsim.core.mobsim.qsim.components.QSimComponentsConfig; import org.matsim.core.mobsim.qsim.components.StandardQSimComponentConfigurator; @@ -46,9 +48,6 @@ import org.matsim.core.router.speedy.SpeedyALTFactory; import org.matsim.core.router.util.TravelTime; -import com.google.inject.Key; -import com.google.inject.name.Names; - /** * @author jbischoff */ @@ -56,41 +55,42 @@ public class SetupParking { // TODO: create config group and make this all configurable? - static public void installParkingModules(Controler controler) { + static public void installParkingModules(Controller controller) { // No need to route car routes in Routing module in advance, as they are // calculated on the fly - if (!controler.getConfig().getModules().containsKey(DvrpConfigGroup.GROUP_NAME)) { - controler.getConfig().addModule(new DvrpConfigGroup()); + if (!controller.getConfig().getModules().containsKey(DvrpConfigGroup.GROUP_NAME)) { + controller.getConfig().addModule(new DvrpConfigGroup()); } - controler.addOverridingModule(new DvrpTravelTimeModule()); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new DvrpTravelTimeModule()); + controller.addOverridingModule(new AbstractModule() { @Override public void install() { bind(TravelTime.class).annotatedWith(DvrpModes.mode(TransportMode.car)) - .to(Key.get(TravelTime.class, Names.named(DvrpTravelTimeModule.DVRP_ESTIMATED))); + .to(Key.get(TravelTime.class, Names.named(DvrpTravelTimeModule.DVRP_ESTIMATED))); bind(TravelDisutilityFactory.class).annotatedWith(DvrpModes.mode(TransportMode.car)) - .toInstance(TimeAsTravelDisutility::new); + .toInstance(TimeAsTravelDisutility::new); bind(Network.class).annotatedWith(DvrpModes.mode(TransportMode.car)) - .to(Key.get(Network.class, Names.named(DvrpGlobalRoutingNetworkProvider.DVRP_ROUTING))); + .to(Key.get(Network.class, Names.named(DvrpGlobalRoutingNetworkProvider.DVRP_ROUTING))); install(new DvrpModeRoutingModule(TransportMode.car, new SpeedyALTFactory())); bind(Network.class).annotatedWith(Names.named(DvrpGlobalRoutingNetworkProvider.DVRP_ROUTING)) - .to(Network.class) - .asEagerSingleton(); + .to(Network.class) + .asEagerSingleton(); bind(ParkingSearchManager.class).to(FacilityBasedParkingManager.class).asEagerSingleton(); + bind(ParkingStatsWriter.class); this.install(new ParkingSearchQSimModule()); - addControlerListenerBinding().to(ParkingListener.class); + addControlerListenerBinding().to(ParkingSearchManager.class); bind(ParkingRouter.class).to(WithinDayParkingRouter.class); bind(VehicleTeleportationLogic.class).to(VehicleTeleportationToNearbyParking.class); } }); - controler.addOverridingModule(new AbstractModule() { + controller.addOverridingModule(new AbstractModule() { @Override public void install() { QSimComponentsConfig components = new QSimComponentsConfig(); - new StandardQSimComponentConfigurator(controler.getConfig()).configure(components); + new StandardQSimComponentConfigurator(controller.getConfig()).configure(components); components.removeNamedComponent(PopulationModule.COMPONENT_NAME); components.addNamedComponent(ParkingSearchPopulationModule.COMPONENT_NAME); diff --git a/contribs/parking/src/main/resources/parkingsearch/parkingFacilities.xml b/contribs/parking/src/main/resources/parkingsearch/parkingFacilities.xml index 95ecbfd1cc2..8f2228dcb5b 100644 --- a/contribs/parking/src/main/resources/parkingsearch/parkingFacilities.xml +++ b/contribs/parking/src/main/resources/parkingsearch/parkingFacilities.xml @@ -2,36 +2,36 @@ - + - - + + - - + + - + - - + + - - + + - + diff --git a/contribs/parking/src/main/resources/parkingsearch/population1.xml b/contribs/parking/src/main/resources/parkingsearch/population1.xml new file mode 100644 index 00000000000..4bace31f8e2 --- /dev/null +++ b/contribs/parking/src/main/resources/parkingsearch/population1.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/contribs/parking/src/main/resources/parkingsearch/population10.xml b/contribs/parking/src/main/resources/parkingsearch/population10.xml new file mode 100644 index 00000000000..059d8165658 --- /dev/null +++ b/contribs/parking/src/main/resources/parkingsearch/population10.xml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT.java deleted file mode 100644 index e3959961195..00000000000 --- a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT.java +++ /dev/null @@ -1,157 +0,0 @@ -/* *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2017 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.contrib.parking.parkingchoice.run; - -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.api.core.v01.population.Person; -import org.matsim.api.core.v01.population.Population; -import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; -import org.matsim.contrib.parking.parkingsearch.RunParkingSearchExample; -import org.matsim.contrib.parking.parkingsearch.sim.ParkingSearchConfigGroup; -import org.matsim.core.config.Config; -import org.matsim.core.config.ConfigUtils; -import org.matsim.core.events.EventsUtils; -import org.matsim.core.population.PopulationUtils; -import org.matsim.testcases.MatsimTestUtils; -import org.matsim.utils.eventsfilecomparison.ComparisonResult; - -/** - * @author jbischoff - */ -public class RunParkingSearchScenarioIT { - @RegisterExtension - private MatsimTestUtils utils = new MatsimTestUtils(); - - @Test - void testRunParkingBenesonStrategy() { - try { - String configFile = "./src/main/resources/parkingsearch/config.xml"; - Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); - config.controller().setLastIteration(0); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - - ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); - configGroup.setParkingSearchStrategy(ParkingSearchStrategy.Benenson); - - new RunParkingSearchExample().run(config, false); - - } catch (Exception e) { - e.printStackTrace(); - Assertions.fail("something went wrong"); - } - } - - @Test - void testRunParkingRandomStrategy() { - String configFile = "./src/main/resources/parkingsearch/config.xml"; - Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); - config.controller().setLastIteration(0); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - - ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); - configGroup.setParkingSearchStrategy(ParkingSearchStrategy.Random); - - try { - new RunParkingSearchExample().run(config, false); - } catch (Exception e) { - e.printStackTrace(); - Assertions.fail("something went wrong"); - } - } - - @Test - void testRunParkingDistanceMemoryStrategy() { - try { - String configFile = "./src/main/resources/parkingsearch/config.xml"; - Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); - config.controller().setLastIteration(0); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - - ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); - configGroup.setParkingSearchStrategy(ParkingSearchStrategy.DistanceMemory); - - new RunParkingSearchExample().run(config, false); - { - Population expected = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PopulationUtils.readPopulation(expected, utils.getInputDirectory() + "/output_plans.xml.gz"); - - Population actual = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PopulationUtils.readPopulation(actual, utils.getOutputDirectory() + "/output_plans.xml.gz"); - - for (Id personId : expected.getPersons().keySet()) { - double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore(); - double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore(); - Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); - } - - } - { - String expected = utils.getInputDirectory() + "/output_events.xml.gz"; - String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; - ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual); - Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result); - } - } catch (Exception e) { - e.printStackTrace(); - Assertions.fail("something went wrong"); - } - } - - @Test - void testRunParkingNearestParkingSpotStrategy() { - try { - String configFile = "./src/main/resources/parkingsearch/config.xml"; - Config config = ConfigUtils.loadConfig(configFile, new ParkingSearchConfigGroup()); - config.controller().setLastIteration(0); - config.controller().setOutputDirectory(utils.getOutputDirectory()); - - ParkingSearchConfigGroup configGroup = (ParkingSearchConfigGroup) config.getModules().get(ParkingSearchConfigGroup.GROUP_NAME); - configGroup.setParkingSearchStrategy(ParkingSearchStrategy.NearestParkingSpot); - - new RunParkingSearchExample().run(config, false); - { - Population expected = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PopulationUtils.readPopulation(expected, utils.getInputDirectory() + "/output_plans.xml.gz"); - - Population actual = PopulationUtils.createPopulation(ConfigUtils.createConfig()); - PopulationUtils.readPopulation(actual, utils.getOutputDirectory() + "/output_plans.xml.gz"); - - for (Id personId : expected.getPersons().keySet()) { - double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore(); - double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore(); - Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); - } - - } - { - String expected = utils.getInputDirectory() + "/output_events.xml.gz"; - String actual = utils.getOutputDirectory() + "/output_events.xml.gz"; - ComparisonResult result = EventsUtils.compareEventsFiles(expected, actual); - Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result); - } - } catch (Exception e) { - e.printStackTrace(); - Assertions.fail("something went wrong"); - } - } -} diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/AbstractParkingTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/AbstractParkingTest.java new file mode 100644 index 00000000000..fee02ad587f --- /dev/null +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/AbstractParkingTest.java @@ -0,0 +1,130 @@ +package org.matsim.contrib.parking.parkingsearch.facilityBasedParking; + +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.api.core.v01.Scenario; +import org.matsim.api.core.v01.population.Person; +import org.matsim.api.core.v01.population.Population; +import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; +import org.matsim.contrib.parking.parkingsearch.sim.ParkingSearchConfigGroup; +import org.matsim.contrib.parking.parkingsearch.sim.SetupParking; +import org.matsim.core.config.Config; +import org.matsim.core.config.ConfigUtils; +import org.matsim.core.controler.Controller; +import org.matsim.core.controler.ControllerUtils; +import org.matsim.core.events.EventsUtils; +import org.matsim.core.population.PopulationUtils; +import org.matsim.core.scenario.ScenarioUtils; +import org.matsim.testcases.MatsimTestUtils; +import org.matsim.utils.eventsfilecomparison.ComparisonResult; + +public abstract class AbstractParkingTest { + @RegisterExtension + MatsimTestUtils utils = new MatsimTestUtils(); + + abstract ParkingSearchStrategy getParkingSearchStrategy(); + + @Test + void testParking1() { + Config config = getConfig(getParkingConfig()); + config.plans().setInputFile("population1.xml"); + run(config); + validate(); + } + + @Test + void testParking10() { + Config config = getConfig(getParkingConfig()); + config.plans().setInputFile("population10.xml"); + run(config); + validate(); + } + + @Test + void testParking100() { + Config config = getConfig(getParkingConfig()); + run(config); + validate(); + } + + @Test + void testParking1_onlyFacilityParking() { + ParkingSearchConfigGroup parkingConfig = getParkingConfig(); + parkingConfig.setCanParkOnlyAtFacilities(true); + Config config = getConfig(parkingConfig); + config.plans().setInputFile("population1.xml"); + run(config); + validate(); + } + + /** + * Tests the behaviour of the parking search when only parking at facilities is allowed. + * Result: Agents are trying to park at facilities and are searching so long for a parking space until they found one. + */ + @Test + void testParking10_onlyFacilityParking() { + ParkingSearchConfigGroup parkingConfig = getParkingConfig(); + parkingConfig.setCanParkOnlyAtFacilities(true); + Config config = getConfig(parkingConfig); + config.plans().setInputFile("population10.xml"); + run(config); + validate(); + } + + private ParkingSearchConfigGroup getParkingConfig() { + ParkingSearchConfigGroup parkingSearchConfigGroup = new ParkingSearchConfigGroup(); + parkingSearchConfigGroup.setParkingSearchStrategy(getParkingSearchStrategy()); + return parkingSearchConfigGroup; + } + + private Config getConfig(ParkingSearchConfigGroup parkingSearchConfigGroup) { + Config config = ConfigUtils.loadConfig("parkingsearch/config.xml", parkingSearchConfigGroup); + config.controller().setOutputDirectory(utils.getOutputDirectory()); + config.controller().setLastIteration(0); + return config; + } + + private void run(Config config) { + Scenario scenario = ScenarioUtils.loadScenario(config); + + Controller controller = ControllerUtils.createController(scenario); + SetupParking.installParkingModules(controller); + controller.run(); + } + + private void validate() { + comparePopulation(); + compareEvents(); + compareCsv("0.parkingStats.csv"); + compareCsv("0.parkingStatsPerTimeSteps.csv"); + } + + private void compareCsv(String fileName) { + String parkingStatsOut = utils.getOutputDirectory() + "/ITERS/it.0/" + fileName; + String parkingStatsIn = utils.getInputDirectory() + "/" + fileName; + MatsimTestUtils.assertEqualFilesLineByLine(parkingStatsIn, parkingStatsOut); + } + + private void compareEvents() { + String expectedEventsFile = utils.getInputDirectory() + "/output_events.xml.gz"; + String actualEventsFile = utils.getOutputDirectory() + "/output_events.xml.gz"; + ComparisonResult result = EventsUtils.compareEventsFiles(expectedEventsFile, actualEventsFile); + Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, result); + } + + private void comparePopulation() { + Population expected = PopulationUtils.createPopulation(ConfigUtils.createConfig()); + PopulationUtils.readPopulation(expected, utils.getInputDirectory() + "/output_plans.xml.gz"); + + Population actual = PopulationUtils.createPopulation(ConfigUtils.createConfig()); + PopulationUtils.readPopulation(actual, utils.getOutputDirectory() + "/output_plans.xml.gz"); + + for (Id personId : expected.getPersons().keySet()) { + double scoreReference = expected.getPersons().get(personId).getSelectedPlan().getScore(); + double scoreCurrent = actual.getPersons().get(personId).getSelectedPlan().getScore(); + Assertions.assertEquals(scoreReference, scoreCurrent, MatsimTestUtils.EPSILON, "Scores of person=" + personId + " are different"); + } + } +} diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest.java new file mode 100644 index 00000000000..fe21aa68bbe --- /dev/null +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest.java @@ -0,0 +1,10 @@ +package org.matsim.contrib.parking.parkingsearch.facilityBasedParking; + +import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; + +public class BenensonParkingTest extends AbstractParkingTest { + @Override + ParkingSearchStrategy getParkingSearchStrategy() { + return ParkingSearchStrategy.Benenson; + } +} diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest.java new file mode 100644 index 00000000000..9822c5a68d5 --- /dev/null +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest.java @@ -0,0 +1,10 @@ +package org.matsim.contrib.parking.parkingsearch.facilityBasedParking; + +import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; + +public class DistanceMemoryParkingTest extends AbstractParkingTest { + @Override + ParkingSearchStrategy getParkingSearchStrategy() { + return ParkingSearchStrategy.DistanceMemory; + } +} diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest.java new file mode 100644 index 00000000000..0403332ec60 --- /dev/null +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest.java @@ -0,0 +1,12 @@ +package org.matsim.contrib.parking.parkingsearch.facilityBasedParking; + +import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; + +public class NearestParkingSpotTest extends AbstractParkingTest { + @Override + ParkingSearchStrategy getParkingSearchStrategy() { + return ParkingSearchStrategy.NearestParkingSpot; + } + + //TODO something is wrong with this strategy. Even for 100 vehicles, all of them are parking in the same parking spot. +} diff --git a/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest.java b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest.java new file mode 100644 index 00000000000..c473a821ea7 --- /dev/null +++ b/contribs/parking/src/test/java/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest.java @@ -0,0 +1,10 @@ +package org.matsim.contrib.parking.parkingsearch.facilityBasedParking; + +import org.matsim.contrib.parking.parkingsearch.ParkingSearchStrategy; + +public class RandomParkingTest extends AbstractParkingTest { + @Override + ParkingSearchStrategy getParkingSearchStrategy() { + return ParkingSearchStrategy.Random; + } +} diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_events.xml.gz deleted file mode 100644 index e80c449a03b..00000000000 Binary files a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_events.xml.gz and /dev/null differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_plans.xml.gz deleted file mode 100644 index e2a50e6fa9a..00000000000 Binary files a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingDistanceMemoryStrategy/output_plans.xml.gz and /dev/null differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_events.xml.gz new file mode 100644 index 00000000000..36d8ae41c21 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_plans.xml.gz new file mode 100644 index 00000000000..cf995fee841 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStats.csv new file mode 100644 index 00000000000..7bd305e83eb --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;10;5;5;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;10;5;5;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_events.xml.gz new file mode 100644 index 00000000000..fd76d129a1b Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_plans.xml.gz new file mode 100644 index 00000000000..b49179b7c90 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStats.csv new file mode 100644 index 00000000000..ee6192c5425 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;104;5;99;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;26;10;16;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;107;10;97;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;30;5;25;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..716c4f390f1 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;3 +09:15;0;0;1 +09:30;0;0;2 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_events.xml.gz new file mode 100644 index 00000000000..3300cf6fc43 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_plans.xml.gz new file mode 100644 index 00000000000..d18738479e9 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking100/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..dcdd85c0325 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;12;5;7;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;3;3;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;15;7;8;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;5;5;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..983cb03d56a Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..63644bd8eb6 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10OnlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..dcdd85c0325 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;12;5;7;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;3;3;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;15;7;8;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;5;5;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..983cb03d56a Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..63644bd8eb6 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..36d8ae41c21 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..cf995fee841 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1OnlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..36d8ae41c21 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..cf995fee841 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/BenensonParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_events.xml.gz new file mode 100644 index 00000000000..2bc7be4d53f Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_plans.xml.gz new file mode 100644 index 00000000000..26b51e95fff Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStats.csv new file mode 100644 index 00000000000..2ee1656326c --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;10;5;5;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;5;5;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;10;5;5;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;5;5;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_events.xml.gz new file mode 100644 index 00000000000..a216a012aef Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_plans.xml.gz new file mode 100644 index 00000000000..a8ff7a8b2bd Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStats.csv new file mode 100644 index 00000000000..804d206d189 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;100;5;95;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;90;10;80;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;100;10;90;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;95;5;90;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..12979cdbad0 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;7 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_events.xml.gz new file mode 100644 index 00000000000..1bb01ce6e46 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_plans.xml.gz new file mode 100644 index 00000000000..4c78de8075a Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking100/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..2ee1656326c --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;10;5;5;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;5;5;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;10;5;5;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;5;5;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..a216a012aef Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..a8ff7a8b2bd Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..2bc7be4d53f Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..26b51e95fff Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/DistanceMemoryParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStats.csv new file mode 100644 index 00000000000..7e2bf32fac8 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;0;0;0;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;0;0;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_events.xml.gz new file mode 100644 index 00000000000..8e1a8f4a86a Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_plans.xml.gz new file mode 100644 index 00000000000..c3d3666b97e Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStats.csv new file mode 100644 index 00000000000..7e2bf32fac8 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;0;0;0;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;0;0;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_events.xml.gz new file mode 100644 index 00000000000..cadcc82dcbc Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_plans.xml.gz new file mode 100644 index 00000000000..40f4eaec10e Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStats.csv new file mode 100644 index 00000000000..7e2bf32fac8 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;0;0;0;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;0;0;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingNearestParkingSpotStrategy/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/output_events.xml.gz similarity index 100% rename from contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingNearestParkingSpotStrategy/output_events.xml.gz rename to contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/output_events.xml.gz diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingNearestParkingSpotStrategy/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/output_plans.xml.gz similarity index 100% rename from contribs/parking/test/input/org/matsim/contrib/parking/parkingchoice/run/RunParkingSearchScenarioIT/testRunParkingNearestParkingSpotStrategy/output_plans.xml.gz rename to contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking100/output_plans.xml.gz diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..7e2bf32fac8 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;0;0;0;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;0;0;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..cadcc82dcbc Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..40f4eaec10e Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking10_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..7e2bf32fac8 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;0;0;0;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;0;0;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..8e1a8f4a86a Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..c3d3666b97e Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/NearestParkingSpotTest/testParking1_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_events.xml.gz new file mode 100644 index 00000000000..2bc7be4d53f Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_plans.xml.gz new file mode 100644 index 00000000000..26b51e95fff Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStats.csv new file mode 100644 index 00000000000..f3c91e1630b --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;10;5;5;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;10;5;5;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;1;1;1;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..aee46863f7a --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;0 +09:15;0;0;0 +09:30;0;0;0 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_events.xml.gz new file mode 100644 index 00000000000..fa9a7b934f2 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_plans.xml.gz new file mode 100644 index 00000000000..4c36398342c Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStats.csv new file mode 100644 index 00000000000..ddfea464dac --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;106;5;101;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;24;10;14;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;102;10;92;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;5;22;5;17;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..89a94f7925f --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1,62 @@ +time;rejectedParkingRequest;foundParking;unpark +09:00;0;0;2 +09:15;0;0;3 +09:30;0;0;2 +09:45;0;0;0 +10:00;0;0;0 +10:15;0;0;0 +10:30;0;0;0 +10:45;0;0;0 +11:00;0;0;0 +11:15;0;0;0 +11:30;0;0;0 +11:45;0;0;0 +12:00;0;0;0 +12:15;0;0;0 +12:30;0;0;0 +12:45;0;0;0 +13:00;0;0;0 +13:15;0;0;0 +13:30;0;0;0 +13:45;0;0;0 +14:00;0;0;0 +14:15;0;0;0 +14:30;0;0;0 +14:45;0;0;0 +15:00;0;0;0 +15:15;0;0;0 +15:30;0;0;0 +15:45;0;0;0 +16:00;0;0;0 +16:15;0;0;0 +16:30;0;0;0 +16:45;0;0;0 +17:00;0;0;0 +17:15;0;0;0 +17:30;0;0;0 +17:45;0;0;0 +18:00;0;0;0 +18:15;0;0;0 +18:30;0;0;0 +18:45;0;0;0 +19:00;0;0;0 +19:15;0;0;0 +19:30;0;0;0 +19:45;0;0;0 +20:00;0;0;0 +20:15;0;0;0 +20:30;0;0;0 +20:45;0;0;0 +21:00;0;0;0 +21:15;0;0;0 +21:30;0;0;0 +21:45;0;0;0 +22:00;0;0;0 +22:15;0;0;0 +22:30;0;0;0 +22:45;0;0;0 +23:00;0;0;0 +23:15;0;0;0 +23:30;0;0;0 +23:45;0;0;0 +24:00;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_events.xml.gz new file mode 100644 index 00000000000..1ba46f218f0 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_plans.xml.gz new file mode 100644 index 00000000000..f7d3b5d44ea Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking100/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..8704e2ee490 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;5;11;6;5;0;0;0 +149;300.0;-190.0;149_curbside;5.0;1;3;3;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;2;13;8;5;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;2;3;3;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..998560e4410 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..c9e8cf0c736 Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking10_onlyFacilityParking/output_plans.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv new file mode 100644 index 00000000000..11b81e47e1d --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStats.csv @@ -0,0 +1,5 @@ +linkId;X;Y;parkingFacility;capacity;EndOccupation;reservationsRequests;numberOfParkedVehicles;rejectedParkingRequest;numberOfWaitingActivities;numberOfStaysFromGetOffUntilGetIn;numberOfParkingBeforeGetIn +114;-300.0;-790.0;114_curbside;5.0;1;1;1;0;0;0;0 +149;300.0;-190.0;149_curbside;5.0;0;0;0;0;0;0;0 +349;300.0;-210.0;349_curbside;5.0;0;1;1;0;0;0;0 +314;-300.0;-810.0;314_curbside;5.0;0;0;0;0;0;0;0 diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv new file mode 100644 index 00000000000..fc35dee9a03 --- /dev/null +++ b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/0.parkingStatsPerTimeSteps.csv @@ -0,0 +1 @@ +time;rejectedParkingRequest;foundParking;unpark diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz new file mode 100644 index 00000000000..2bc7be4d53f Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_events.xml.gz differ diff --git a/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz new file mode 100644 index 00000000000..26b51e95fff Binary files /dev/null and b/contribs/parking/test/input/org/matsim/contrib/parking/parkingsearch/facilityBasedParking/RandomParkingTest/testParking1_onlyFacilityParking/output_plans.xml.gz differ 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(); + + } +} diff --git a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java index 287858329cb..4432063a364 100644 --- a/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java +++ b/matsim/src/test/java/org/matsim/testcases/MatsimTestUtils.java @@ -31,8 +31,8 @@ import org.matsim.core.gbl.MatsimRandom; import org.matsim.core.utils.io.IOUtils; import org.matsim.core.utils.misc.CRCChecksum; -import org.matsim.utils.eventsfilecomparison.EventsFileComparator; import org.matsim.utils.eventsfilecomparison.ComparisonResult; +import org.matsim.utils.eventsfilecomparison.EventsFileComparator; import java.io.BufferedReader; import java.io.File; @@ -41,6 +41,9 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.Objects; /** @@ -51,6 +54,11 @@ public final class MatsimTestUtils implements BeforeEachCallback, AfterEachCallback { private static final Logger log = LogManager.getLogger(MatsimTestUtils.class); + //used for copying files from output to input. Don't delete even if they are unused in production + public static final String FILE_NAME_PLANS = "output_plans.xml.gz"; + public static final String FILE_NAME_NETWORK = "output_network.xml.gz"; + public static final String FILE_NAME_EVENTS = "output_events.xml.gz"; + public enum TestMethodType { Normal, Parameterized } @@ -60,12 +68,16 @@ public enum TestMethodType { */ public static final double EPSILON = 1e-10; - /** The default output directory, where files of this test should be written to. - * Includes the trailing '/' to denote a directory. */ + /** + * The default output directory, where files of this test should be written to. + * Includes the trailing '/' to denote a directory. + */ private String outputDirectory = null; - /** The default input directory, where files of this test should be read from. - * Includes the trailing '/' to denote a directory. */ + /** + * The default input directory, where files of this test should be read from. + * Includes the trailing '/' to denote a directory. + */ private String inputDirectory = null; /** @@ -144,7 +156,7 @@ public URL packageInputResourcePath() { private URL getResourceNotNull(String pathString) { URL resource = this.testClass.getResource(pathString); if (resource == null) { - throw new UncheckedIOException(new IOException("Not found: "+pathString)); + throw new UncheckedIOException(new IOException("Not found: " + pathString)); } return resource; } @@ -171,7 +183,8 @@ public Config createConfig(URL context) { /** * Loads a configuration from file (or the default config if configfile is null) - * and sets the output directory to {classPath}/{methodName}/. For parameterized tests, the output directory is {classPath}/{methodName}/{parameters}/. + * and sets the output directory to {classPath}/{methodName}/. For parameterized tests, the output directory is {classPath}/{methodName}/{ + * parameters}/. * * @param configfile The path/filename of a configuration file, or null to load the default configuration. * @return The loaded configuration. @@ -181,7 +194,7 @@ public Config loadConfig(final String configfile, TestMethodType testMethodType, if (configfile != null) { config = ConfigUtils.loadConfig(configfile, customGroups); } else { - config = ConfigUtils.createConfig( customGroups ); + config = ConfigUtils.createConfig(customGroups); } return setOutputDirectory(config, testMethodType); } @@ -195,7 +208,7 @@ public Config loadConfig(final URL configfile, TestMethodType testMethodType, fi if (configfile != null) { config = ConfigUtils.loadConfig(configfile, customGroups); } else { - config = ConfigUtils.createConfig( customGroups ); + config = ConfigUtils.createConfig(customGroups); } return setOutputDirectory(config, testMethodType); } @@ -226,7 +239,7 @@ public String getParameterizedTestInputString() { } public Config createConfig(final ConfigGroup... customGroups) { - Config config = ConfigUtils.createConfig( customGroups ); + Config config = ConfigUtils.createConfig(customGroups); this.outputDirectory = getOutputDirectory(); config.controller().setOutputDirectory(this.outputDirectory); return config; @@ -254,7 +267,7 @@ public String getOutputDirectory() { public String getOutputDirectory(String subDir) { if (this.outputDirectory == null) { - this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName()+ "/" + subDir; + this.outputDirectory = "test/output/" + this.testClass.getCanonicalName().replace('.', '/') + "/" + getMethodName() + "/" + subDir; } createOutputDirectory(); return this.outputDirectory; @@ -271,18 +284,20 @@ public String getInputDirectory() { } return this.inputDirectory; } + /** - * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory delimiter. + * Returns the path to the input directory one level above the default input directory for this test including a trailing slash as directory + * delimiter. * * @return path to the input directory for this test */ public String getClassInputDirectory() { if (this.classInputDirectory == null) { - LogManager.getLogger(this.getClass()).info( "user.dir = " + System.getProperty("user.dir") ) ; + LogManager.getLogger(this.getClass()).info("user.dir = " + System.getProperty("user.dir")); this.classInputDirectory = "test/input/" + - this.testClass.getCanonicalName().replace('.', '/') + "/"; + this.testClass.getCanonicalName().replace('.', '/') + "/"; // this.classInputDirectory = System.getProperty("user.dir") + "/test/input/" + // this.testClass.getCanonicalName().replace('.', '/') + "/"; // (this used to be relative, i.e. ... = "test/input/" + ... . Started failing when @@ -292,8 +307,10 @@ public String getClassInputDirectory() { } return this.classInputDirectory; } + /** - * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory delimiter. + * Returns the path to the input directory two levels above the default input directory for this test including a trailing slash as directory + * delimiter. * * @return path to the input directory for this test */ @@ -321,7 +338,7 @@ public String getMethodName() { * This should be used for "fixtures" only that provide a scenario common to several * test cases. */ - public void initWithoutJUnitForFixture(Class fixture, Method method){ + public void initWithoutJUnitForFixture(Class fixture, Method method) { this.testClass = fixture; this.testMethodName = method.getName(); } @@ -333,27 +350,62 @@ public static void assertEqualFilesLineByLine(String inputFilename, String outpu String lineInput; String lineOutput; - while( ((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null) ){ - if ( !Objects.equals( lineInput.trim(), lineOutput.trim() ) ){ - log.info( "Reading line... " ); - log.info( lineInput ); - log.info( lineOutput ); - log.info( "" ); + while (((lineInput = readerV1Input.readLine()) != null) && ((lineOutput = readerV1Output.readLine()) != null)) { + if (!Objects.equals(lineInput.trim(), lineOutput.trim())) { + log.info("Reading line... "); + log.info(lineInput); + log.info(lineOutput); + log.info(""); } - Assertions.assertEquals(lineInput.trim(), lineOutput.trim(), "Lines have different content: " ); + Assertions.assertEquals(lineInput.trim(), lineOutput.trim(), "Lines have different content: "); } } catch (IOException e) { throw new UncheckedIOException(e); } } - public static void assertEqualEventsFiles( String filename1, String filename2 ) { - Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL ,EventsFileComparator.compare(filename1, filename2) ); + public static void assertEqualEventsFiles(String filename1, String filename2) { + Assertions.assertEquals(ComparisonResult.FILES_ARE_EQUAL, EventsFileComparator.compare(filename1, filename2)); + } + + public static void assertEqualFilesBasedOnCRC(String filename1, String filename2) { + long checksum1 = CRCChecksum.getCRCFromFile(filename1); + long checksum2 = CRCChecksum.getCRCFromFile(filename2); + Assertions.assertEquals(checksum1, checksum2, "different file checksums"); + } + + /** + * Creates the input directory for this test. + */ + public void createInputDirectory() { + try { + Files.createDirectories(Path.of(getInputDirectory())); + } catch (IOException e) { + e.printStackTrace(); + Assertions.fail(); + } + } + + /** + * Copies a file from the output directory to the input directory. This is normally only needed during development, if one would not do it + * manually. + */ + public void copyFileFromOutputToInput(String fileName) { + createInputDirectory(); + copyFileFromOutputToInput(fileName, fileName); } - public static void assertEqualFilesBasedOnCRC( String filename1, String filename2 ) { - long checksum1 = CRCChecksum.getCRCFromFile(filename1) ; - long checksum2 = CRCChecksum.getCRCFromFile(filename2) ; - Assertions.assertEquals( checksum1, checksum2, "different file checksums" ); - } + /** + * Copies a file from the output directory to the input directory. This is normally only needed during development, if one would not do it + * manually. + */ + public void copyFileFromOutputToInput(String outputFile, String inputFile) { + createInputDirectory(); + try { + Files.copy(Path.of(getOutputDirectory() + outputFile), Path.of(getInputDirectory() + inputFile), StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + e.printStackTrace(); + Assertions.fail(); + } + } }