From e2bc44d49fddf119309b587be052c643dea7aa62 Mon Sep 17 00:00:00 2001 From: u234825 Date: Tue, 7 Jan 2025 18:48:44 +0100 Subject: [PATCH 01/13] extending the railsim integration test (testMicroStationRerouting) to reveal a problem related to the departure and arrival event of trains after re-routing --- .../integration/RailsimIntegrationTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index 4bf88ef4c05..d9efcf842b4 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -35,6 +35,7 @@ import org.matsim.api.core.v01.population.Plan; import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.api.experimental.events.VehicleArrivesAtFacilityEvent; +import org.matsim.core.api.experimental.events.VehicleDepartsAtFacilityEvent; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.ScoringConfigGroup; @@ -47,6 +48,7 @@ import org.matsim.pt.transitSchedule.api.TransitLine; import org.matsim.pt.transitSchedule.api.TransitRoute; import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; +import org.matsim.pt.transitSchedule.api.TransitStopFacility; import org.matsim.testcases.MatsimTestUtils; import org.matsim.testcases.utils.EventsCollector; import org.matsim.vehicles.Vehicle; @@ -56,8 +58,10 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -317,6 +321,53 @@ void testMicroStationRerouting() { // These arrive closer together, because both waited assertTrainState(30974, 0, 0, 0, 400, filterTrainEvents(collector, "train3")); assertTrainState(30982, 0, 0, 0, 400, filterTrainEvents(collector, "train4")); + + // collect all arrivals and departures + Map, List>> train2arrivalStops = new HashMap<>(); + Map, List>> train2departureStops = new HashMap<>(); + + for (Event event : collector.getEvents()) { + if (event.getEventType().equals(VehicleArrivesAtFacilityEvent.EVENT_TYPE)) { + + VehicleArrivesAtFacilityEvent vehicleArrivesEvent = (VehicleArrivesAtFacilityEvent) event; + + if (train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()) == null) { + + List> stops = new ArrayList<>(); + stops.add(vehicleArrivesEvent.getFacilityId()); + train2arrivalStops.put(vehicleArrivesEvent.getVehicleId(), stops); + } else { + train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()).add(vehicleArrivesEvent.getFacilityId()); + } + } + + if (event.getEventType().equals(VehicleDepartsAtFacilityEvent.EVENT_TYPE)) { + + VehicleDepartsAtFacilityEvent vehicleDepartsEvent = (VehicleDepartsAtFacilityEvent) event; + + if (train2departureStops.get(vehicleDepartsEvent.getVehicleId()) == null) { + + List> stops = new ArrayList<>(); + stops.add(vehicleDepartsEvent.getFacilityId()); + train2departureStops.put(vehicleDepartsEvent.getVehicleId(), stops); + } else { + train2departureStops.get(vehicleDepartsEvent.getVehicleId()).add(vehicleDepartsEvent.getFacilityId()); + } + } + } + + // test if all trains have the correct number of arrivals and departures + for (Id vehicleId : train2arrivalStops.keySet()) { + Assertions.assertEquals(3, train2arrivalStops.get(vehicleId).size(), MatsimTestUtils.EPSILON, "Wrong number of arrival stops for train " + vehicleId); + } + for (Id vehicleId : train2departureStops.keySet()) { + Assertions.assertEquals(3, train2departureStops.get(vehicleId).size(), MatsimTestUtils.EPSILON, "Wrong number of departure stops for train " + vehicleId); + } + + // test if the trains have the correct arrival / departure stop facilities + Assertions.assertEquals("AB", train2arrivalStops.get(Id.createVehicleId("train3")).get(0).toString(), "Wrong stop facility. This is the start stop facility."); + Assertions.assertEquals("CD", train2arrivalStops.get(Id.createVehicleId("train3")).get(1).toString(), "Wrong stop facility. This is the rerouted stop Id. Train 3 is rerouted from CE to CD."); + Assertions.assertEquals("JK", train2arrivalStops.get(Id.createVehicleId("train3")).get(2).toString(), "Wrong stop facility. This is the final stop facility."); } @Test From a2ae5dfa8d04e0612ab4a0b3e59a9466063a8643 Mon Sep 17 00:00:00 2001 From: u234825 Date: Tue, 7 Jan 2025 19:30:15 +0100 Subject: [PATCH 02/13] adding a test which reveals another issue when re-routing trains. the simulation runs forever (loop in constructPath) --- .../integration/RailsimIntegrationTest.java | 53 +++ .../config.xml | 39 ++ .../trainNetwork.xml | 399 ++++++++++++++++++ .../transitSchedule.xml | 251 +++++++++++ .../transitVehicles.xml | 56 +++ 5 files changed, 798 insertions(+) create mode 100644 contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/config.xml create mode 100644 contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/trainNetwork.xml create mode 100644 contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitSchedule.xml create mode 100644 contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitVehicles.xml diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index d9efcf842b4..ac4cfeb2888 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -41,6 +41,9 @@ import org.matsim.core.config.groups.ScoringConfigGroup; import org.matsim.core.controler.AbstractModule; import org.matsim.core.controler.Controler; +import org.matsim.core.events.handler.EventHandler; +import org.matsim.core.gbl.MatsimRandom; +import org.matsim.core.mobsim.framework.listeners.MobsimListener; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.io.IOUtils; import org.matsim.examples.ExamplesUtils; @@ -62,6 +65,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -395,6 +399,11 @@ void testMicroStationReroutingConcurrent() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microStationRerouting"), filter); } + + @Test + void testMicroStationReroutingTwoDirections() { + modifyScheduleAndRunSimulation(new File(utils.getPackageInputDirectory(), "microStationReroutingTwoDirections"), 300, 1800); + } @Test void testScenarioKelheim() { @@ -493,6 +502,50 @@ public void install() { return collector; } + + private void modifyScheduleAndRunSimulation(File scenarioDir, int maxRndDelayStepSize, int maxMaxRndDelay) { + Random rnd = MatsimRandom.getRandom(); + rnd.setSeed(1242); + + for (double maxRndDelaySeconds = 0; maxRndDelaySeconds <= maxMaxRndDelay; maxRndDelaySeconds = maxRndDelaySeconds + maxRndDelayStepSize) { + Config config = ConfigUtils.loadConfig(new File(scenarioDir, "config.xml").toString()); + + config.controller().setOutputDirectory(utils.getOutputDirectory() + "maxRndDelay_" + maxRndDelaySeconds); + config.controller().setDumpDataAtEnd(true); + config.controller().setCreateGraphs(false); + config.controller().setLastIteration(0); + + Scenario scenario = ScenarioUtils.loadScenario(config); + + Controler controler = new Controler(scenario); + controler.addOverridingModule(new RailsimModule()); + controler.configureQSimComponents(components -> new RailsimQSimModule().configure(components)); + + // modify scenario + for (TransitLine line : scenario.getTransitSchedule().getTransitLines().values()) { + for (TransitRoute route : line.getRoutes().values()) { + List departuresToRemove = new ArrayList<>(); + List departuresToAdd = new ArrayList<>(); + for (Departure departure : route.getDepartures().values()) { + departuresToRemove.add(departure); + double departureTime = departure.getDepartureTime() + rnd.nextDouble() * maxRndDelaySeconds; + Departure modifiedDeparture = scenario.getTransitSchedule().getFactory().createDeparture(departure.getId(), departureTime); + modifiedDeparture.setVehicleId(departure.getVehicleId()); + departuresToAdd.add(modifiedDeparture); + } + + for (Departure departureToRemove : departuresToRemove) { + route.removeDeparture(departureToRemove); + } + for (Departure departureToAdd : departuresToAdd) { + route.addDeparture(departureToAdd); + } + } + } + + controler.run(); + } + } private double timeToAccelerate(double v0, double v, double a) { return (v - v0) / a; diff --git a/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/config.xml b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/config.xml new file mode 100644 index 00000000000..da3761b5c4e --- /dev/null +++ b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/config.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/trainNetwork.xml b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/trainNetwork.xml new file mode 100644 index 00000000000..d2bf5887476 --- /dev/null +++ b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/trainNetwork.xml @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 999 + + + + + 999 + + + + + + 999 + + + + + + 999 + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + true + + + + + 1 + 2b_3b + + + + + 1 + 2b_3b + + + + + 1 + + + + + 1 + 4b_5b + + + + + 1 + 4b_5b + + + + + 1 + true + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + true + + + + + + 1 + + + + + 1 + true + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + 1 + + + + + + 1 + 7b_8b + + + + + 1 + 7b_8b + + + + + 1 + 9b_10b + + + + + 1 + 9b_10b + + + + + + 1 + 3b_7b + + + + + 1 + 3b_7b + + + + + + 1 + 7b_9b + + + + + 1 + 7b_9b + + + + + + 1 + 8b_10b + + + + + 1 + 8b_10b + + + + + 1 + 4b_8b + + + + + 1 + 4b_8b + + + + + + 1 + + + + + 1 + + + + + \ No newline at end of file diff --git a/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitSchedule.xml b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitSchedule.xml new file mode 100644 index 00000000000..a1211eb2178 --- /dev/null +++ b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitSchedule.xml @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + rail + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rail + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rail + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rail + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitVehicles.xml b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitVehicles.xml new file mode 100644 index 00000000000..6e2ecb5904a --- /dev/null +++ b/contribs/railsim/test/input/ch/sbb/matsim/contrib/railsim/integration/microStationReroutingTwoDirections/transitVehicles.xml @@ -0,0 +1,56 @@ + + + + + + + 0.5 + 0.5 + + + + + + + + + + + + + + + 0.7 + 0.7 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From ec6cbefc35ffe9d814428ef641f6f4b015ec54e9 Mon Sep 17 00:00:00 2001 From: u234825 Date: Tue, 7 Jan 2025 19:37:26 +0100 Subject: [PATCH 03/13] stop the simulation from running forever --- .../integration/RailsimIntegrationTest.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index ac4cfeb2888..31f9571869b 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -57,6 +57,8 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.net.URL; import java.util.ArrayList; @@ -67,6 +69,12 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -402,7 +410,28 @@ void testMicroStationReroutingConcurrent() { @Test void testMicroStationReroutingTwoDirections() { - modifyScheduleAndRunSimulation(new File(utils.getPackageInputDirectory(), "microStationReroutingTwoDirections"), 300, 1800); +// modifyScheduleAndRunSimulation(new File(utils.getPackageInputDirectory(), "microStationReroutingTwoDirections"), 300, 1800); + + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future future = executor.submit(() -> { + modifyScheduleAndRunSimulation( + new File(utils.getPackageInputDirectory(), "microStationReroutingTwoDirections"), + 300, + 1800 + ); + }); + + try { + future.get(30, TimeUnit.SECONDS); + } catch (TimeoutException e) { + future.cancel(true); + fail("Simulation took too long and was aborted!"); + } catch (ExecutionException | InterruptedException e) { + // other exceptions + fail("An error occurred during the simulation: " + e.getMessage()); + } finally { + executor.shutdownNow(); + } } @Test From dba492dbd4955c153a709bb584183b6bff719817 Mon Sep 17 00:00:00 2001 From: rakow Date: Fri, 10 Jan 2025 12:24:18 +0100 Subject: [PATCH 04/13] prevent deadlock in rerouting --- .../contrib/railsim/qsimengine/router/TrainRouter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java index 889d80d84fb..9c4f139e4e9 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java @@ -87,7 +87,10 @@ public void setPosition(TrainPosition position) { @Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { // only works with fixed block - return resources.hasCapacity(time, link.getId(), RailResourceManager.ANY_TRACK, position) ? 0 : 1; + int weight = resources.hasCapacity(time, link.getId(), RailResourceManager.ANY_TRACK, position) ? 0 : 1; + + // Small offset in the weight prevents dead-locks in case there are loops within the station + return weight + 0.001; } @Override From 7ebde1c0dda3f197c0f4fd6d2b854bfb24bd42bc Mon Sep 17 00:00:00 2001 From: rakow Date: Fri, 10 Jan 2025 12:26:26 +0100 Subject: [PATCH 05/13] make weight even smaller --- .../matsim/contrib/railsim/qsimengine/router/TrainRouter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java index 9c4f139e4e9..2414bb1859a 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/router/TrainRouter.java @@ -90,7 +90,7 @@ public double getLinkTravelDisutility(Link link, double time, Person person, Veh int weight = resources.hasCapacity(time, link.getId(), RailResourceManager.ANY_TRACK, position) ? 0 : 1; // Small offset in the weight prevents dead-locks in case there are loops within the station - return weight + 0.001; + return weight + 0.00001; } @Override From 629bb591038052acdff34dc319d83af8c34f193d Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 22:19:52 +0100 Subject: [PATCH 06/13] rename it back to capacityDemand --- .../DemandReaderFromCSV.java | 12 ++-- .../DemandReaderFromCSVTest.java | 62 +++++++++---------- .../DefaultCommercialJobGenerator.java | 2 +- .../matsim/freight/carriers/CarrierJob.java | 2 +- .../carriers/CarrierPlanXmlParserV2.java | 2 +- .../carriers/CarrierPlanXmlParserV2_1.java | 2 +- .../carriers/CarrierPlanXmlWriterV2_1.java | 4 +- .../freight/carriers/CarrierService.java | 44 +++---------- .../freight/carriers/CarrierShipment.java | 6 +- .../freight/carriers/CarriersUtils.java | 2 +- .../analysis/CarrierPlanAnalysis.java | 8 +-- .../events/CarrierServiceStartEvent.java | 4 +- .../CarrierShipmentDeliveryEndEvent.java | 2 +- .../CarrierShipmentDeliveryStartEvent.java | 2 +- .../events/CarrierShipmentPickupEndEvent.java | 2 +- .../CarrierShipmentPickupStartEvent.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 8 +-- .../chessboard/FreightScenarioCreator.java | 2 +- .../multipleChains/MultipleChainsUtils.java | 2 +- .../CollectionCarrierScheduler.java | 2 +- .../DistributionCarrierScheduler.java | 2 +- .../MainRunCarrierScheduler.java | 2 +- .../freight/carriers/CarriersUtilsTest.java | 4 +- ...istanceConstraintFromVehiclesFileTest.java | 6 +- .../jsprit/DistanceConstraintTest.java | 6 +- .../carriers/jsprit/FixedCostsTest.java | 2 +- .../jsprit/MatsimTransformerTest.java | 14 ++--- .../utils/CarrierControllerUtilsIT.java | 2 +- .../utils/CarrierControllerUtilsTest.java | 18 +++--- .../CollectionTrackerTest.java | 2 +- .../CollectionLSPSchedulingTest.java | 4 +- .../CompleteLSPSchedulingTest.java | 16 ++--- .../FirstReloadLSPSchedulingTest.java | 6 +- .../MainRunLSPSchedulingTest.java | 10 +-- ...eShipmentsCollectionLSPSchedulingTest.java | 4 +- ...pleShipmentsCompleteLSPSchedulingTest.java | 16 ++--- ...ShipmentsFirstReloadLSPSchedulingTest.java | 6 +- ...ipleShipmentsMainRunLSPSchedulingTest.java | 10 +-- ...hipmentsSecondReloadLSPSchedulingTest.java | 12 ++-- .../SecondReloadLSPSchedulingTest.java | 12 ++-- ...iverTriggersCarrierReplanningListener.java | 2 +- 41 files changed, 152 insertions(+), 176 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 5eae9cb5757..63347fdcb66 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -655,7 +655,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setDemand(demandForThisLink).setServiceDuration(serviceTime) + .setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() @@ -696,7 +696,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { CarrierService.class); if (demandToDistribute > 0 && singleDemandForThisLink > 0) { CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setDemand(singleDemandForThisLink).setServiceDuration(serviceTime) + .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); thisCarrier.getServices().put(thisService.getId(), thisService); @@ -747,7 +747,7 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); if ((demandToDistribute > 0 && singleDemandForThisLink > 0) || demandToDistribute == 0) { CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setDemand(singleDemandForThisLink).setServiceDuration(serviceTime) + .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() @@ -1201,7 +1201,7 @@ private static void combineSimilarJobs(Scenario scenario) { double serviceTimePickup = 0; double serviceTimeDelivery = 0; for (CarrierShipment carrierShipment : shipmentsToConnect.values()) { - demandForThisLink = demandForThisLink + carrierShipment.getDemand(); + demandForThisLink = demandForThisLink + carrierShipment.getCapacityDemand(); serviceTimePickup = serviceTimePickup + carrierShipment.getPickupDuration(); serviceTimeDelivery = serviceTimeDelivery + carrierShipment.getDeliveryDuration(); shipmentsToRemove.put(carrierShipment.getId(), carrierShipment); @@ -1246,7 +1246,7 @@ private static void combineSimilarJobs(Scenario scenario) { int demandForThisLink = 0; double serviceTimeService = 0; for (CarrierService carrierService : servicesToConnect.values()) { - demandForThisLink = demandForThisLink + carrierService.getDemand(); + demandForThisLink = demandForThisLink + carrierService.getCapacityDemand(); serviceTimeService = serviceTimeService + carrierService.getServiceDuration(); servicesToRemove.put(carrierService.getId(), carrierService); } @@ -1254,7 +1254,7 @@ private static void combineSimilarJobs(Scenario scenario) { .newInstance(idNewService, baseService.getServiceLinkId()) .setServiceDuration(serviceTimeService) .setServiceStartTimeWindow(baseService.getServiceStartTimeWindow()) - .setDemand(demandForThisLink).build(); + .setCapacityDemand(demandForThisLink).build(); servicesToAdd.add(newService); } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 32972385d8a..1e497091ba8 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -101,9 +101,9 @@ void demandCreationWithSampleWithChangeNumberOfLocations() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - Assertions.assertEquals(5, shipment.getDemand()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + Assertions.assertEquals(5, shipment.getCapacityDemand()); Assertions.assertEquals(2000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(1250, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); @@ -168,9 +168,9 @@ void demandCreationWithSampleWithDemandOnLocation() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - Assertions.assertEquals(10, shipment.getDemand()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); @@ -235,9 +235,9 @@ void demandCreationWithSampleWithDemandOnLocationWithCombiningJobs() throws IOEx locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - Assertions.assertEquals(10, shipment.getDemand()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); @@ -305,9 +305,9 @@ void demandCreationNoSampling() throws IOException { locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier3.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - Assertions.assertEquals(10, shipment.getDemand()); + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); @@ -474,20 +474,20 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Map> locationsPerServiceElement = new HashMap<>(); int countDemand = 0; for (CarrierService service : testCarrier1.getServices().values()) { - countServicesWithCertainDemand.merge((Integer) service.getDemand(), 1, Integer::sum); - countDemand = countDemand + service.getDemand(); - if (service.getDemand() == 0) { + countServicesWithCertainDemand.merge((Integer) service.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + service.getCapacityDemand(); + if (service.getCapacityDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); - } else if (service.getDemand() == 1) { + } else if (service.getCapacityDemand() == 1) { Assertions.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else { - if (service.getDemand() == 2) { + if (service.getCapacityDemand() == 2) { Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) @@ -522,9 +522,9 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt Map> locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier2.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - if (shipment.getDemand() == 0) { + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + if (shipment.getCapacityDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); @@ -533,7 +533,7 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getDeliveryLinkId().toString()); - } else if (shipment.getDemand() == 2) { + } else if (shipment.getCapacityDemand() == 2) { Assertions.assertEquals(400, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(400, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); @@ -543,7 +543,7 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) .add(shipment.getDeliveryLinkId().toString()); } else { - if (shipment.getDemand() == 3) { + if (shipment.getCapacityDemand() == 3) { Assertions.assertEquals(600, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(600, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); @@ -583,15 +583,15 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Map> locationsPerServiceElement = new HashMap<>(); int countDemand = 0; for (CarrierService service : testCarrier1.getServices().values()) { - countServicesWithCertainDemand.merge((Integer) service.getDemand(), 1, Integer::sum); - countDemand = countDemand + service.getDemand(); - if (service.getDemand() == 0) { + countServicesWithCertainDemand.merge((Integer) service.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + service.getCapacityDemand(); + if (service.getCapacityDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else { - Assertions.assertEquals(service.getDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(service.getCapacityDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); @@ -621,9 +621,9 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ Map> locationsPerShipmentElement = new HashMap<>(); countDemand = 0; for (CarrierShipment shipment : testCarrier2.getShipments().values()) { - countShipmentsWithCertainDemand.merge((Integer) shipment.getDemand(), 1, Integer::sum); - countDemand = countDemand + shipment.getDemand(); - if (shipment.getDemand() == 0) { + countShipmentsWithCertainDemand.merge((Integer) shipment.getCapacityDemand(), 1, Integer::sum); + countDemand = countDemand + shipment.getCapacityDemand(); + if (shipment.getCapacityDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); @@ -633,8 +633,8 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) .add(shipment.getDeliveryLinkId().toString()); } else { - Assertions.assertEquals(shipment.getDemand() * 200, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(shipment.getDemand() * 200, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(shipment.getCapacityDemand() * 200, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); + Assertions.assertEquals(shipment.getCapacityDemand() * 200, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java index 2891b802294..3327f46292c 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java @@ -329,7 +329,7 @@ public void generateIterationServices(Carriers carriers, Population population) double latestStart = Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_END_IDX)); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(serviceId, PopulationUtils.decideOnLinkIdForActivity(activity,scenario)); - serviceBuilder.setDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX))); + serviceBuilder.setCapacityDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX))); serviceBuilder.setServiceDuration(Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_DURATION_IDX))); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(earliestStart,latestStart)); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java index 926c5ae379f..cf064f0fb98 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierJob.java @@ -19,5 +19,5 @@ */ public interface CarrierJob extends Attributable { Id getId(); - int getDemand(); + int getCapacityDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java index 7bbc83c9479..9645408a619 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java @@ -117,7 +117,7 @@ public void startTag(String name, Attributes atts, Stack context) { Id to = Id.create(toLocation, Link.class); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to); String capDemandString = atts.getValue("capacityDemand"); - if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString)); + if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString)); String startString = atts.getValue("earliestStart"); double start = parseTimeToDouble(startString); double end; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java index f439d323ddd..0f3a7180dff 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java @@ -115,7 +115,7 @@ public void startTag(String name, Attributes atts, Stack context) { Id to = Id.create(toLocation, Link.class); CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(id, to); String capDemandString = atts.getValue("capacityDemand"); - if (capDemandString != null) serviceBuilder.setDemand(getInt(capDemandString)); + if (capDemandString != null) serviceBuilder.setCapacityDemand(getInt(capDemandString)); String startString = atts.getValue("earliestStart"); double start = parseTimeToDouble(startString); double end; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 811153ead21..312f47a212d 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -161,7 +161,7 @@ private void writeShipment(CarrierShipment s, Id shipmentId, bo createTuple(ID, shipmentId.toString()), createTuple(FROM, s.getPickupLinkId().toString()), createTuple(TO, s.getDeliveryLinkId().toString()), - createTuple(SIZE, s.getDemand()), + createTuple(SIZE, s.getCapacityDemand()), createTuple(START_PICKUP, getTime(s.getPickupStartsTimeWindow().getStart())), createTuple(END_PICKUP, getTime(s.getPickupStartsTimeWindow().getEnd())), createTuple(START_DELIVERY, getTime(s.getDeliveryStartsTimeWindow().getStart())), @@ -191,7 +191,7 @@ private void writeService(CarrierService s, boolean closeElement, boolean lineBr this.writeStartTag(SERVICE, List.of( createTuple(ID, s.getId().toString()), createTuple(TO, s.getServiceLinkId().toString()), - createTuple(CAPACITY_DEMAND, s.getDemand()), + createTuple(CAPACITY_DEMAND, s.getCapacityDemand()), createTuple(EARLIEST_START, getTime(s.getServiceStartTimeWindow().getStart())), createTuple(LATEST_END, getTime(s.getServiceStartTimeWindow().getEnd())), createTuple(SERVICE_DURATION, getTime(s.getServiceDuration()))), closeElement, lineBreak diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 99be9a2f21f..bad47e13a95 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -31,7 +31,7 @@ public final class CarrierService implements CarrierJob { public static class Builder { private final Id id; - private int demand = 0; + private int capacityDemand = 0; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). @@ -82,20 +82,6 @@ public Builder setServiceDuration(double serviceDuration){ return this; } - /** - * Sets the demand (size; capacity needed) of the service. - * When not set, it is by default 0. - *

- * IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 - * - * @param demand the demand (size; capacity needed) of the service - * @return the builder - */ - public Builder setDemand(int demand) { - this.demand = demand; - return this; - } - /** * Sets the demand (size; capacity needed) of the service. @@ -103,21 +89,19 @@ public Builder setDemand(int demand) { *

* IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 * - * @deprecated please use {@link #setDemand(int)} instead - * - * @param value the demand (size; capacity needed) of the service + * @param capacityDemand the demand (size; capacity needed) of the service * @return the builder */ - @Deprecated(since = "dec'24") - public Builder setCapacityDemand(int value) { - return setDemand(value); + public Builder setCapacityDemand(int capacityDemand) { + this.capacityDemand = capacityDemand; + return this; } } private final Id id; - private final int demand; + private final int capacityDemand; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). @@ -133,7 +117,7 @@ private CarrierService(Builder builder){ serviceLinkId = builder.serviceLinkId; serviceDuration = builder.serviceDuration; serviceStartsTimeWindow = builder.serviceStartsTimeWindow; - demand = builder.demand; + capacityDemand = builder.capacityDemand; } @Override @@ -161,20 +145,12 @@ public TimeWindow getServiceStartTimeWindow(){ return serviceStartsTimeWindow; } - /** - * @deprecated please inline and use {@link #getDemand()} instead - */ - @Deprecated(since = "dec'24") - public int getCapacityDemand() { - return getDemand(); - } - /** * @return the demand (size; capacity needed) of the service. */ @Override - public int getDemand() { - return demand; + public int getCapacityDemand() { + return capacityDemand; } @@ -186,7 +162,7 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + demand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartsTimeWindow + "]"; + return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + capacityDemand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartsTimeWindow + "]"; } /* (non-Javadoc) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index a74177246d5..1ba23034184 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -260,7 +260,7 @@ public Id getDeliveryLinkId() { * @return the demand (size; capacity needed) of the shipment. */ @Override - public int getDemand() { + public int getCapacityDemand() { return demand; } @@ -280,11 +280,11 @@ public Attributes getAttributes() { //*** deprecated methods *** /** - * @deprecated please inline and use {@link #getDemand()} instead + * @deprecated please inline and use {@link #getCapacityDemand()} instead */ @Deprecated(since = "dec'24") public int getSize() { - return getDemand(); + return getCapacityDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index 2354e40a2d5..319c2753b01 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -431,7 +431,7 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create(carrierService.getId().toString(), CarrierShipment.class), depotServiceIsDeliveredFrom.get(carrierService.getId()), carrierService.getServiceLinkId(), - carrierService.getDemand()) + carrierService.getCapacityDemand()) .setDeliveryDuration(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we // have now time for that. Maybe change it later, kmt sep18 diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java index 7c73cb9b551..aec099c36a0 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/analysis/CarrierPlanAnalysis.java @@ -101,16 +101,16 @@ public void runAnalysisAndWriteStats(String analysisOutputDirectory) throws IOEx int numberOfHandledDemandSize; int notHandledJobs; if (numberOfPlanedShipments > 0) { - numberOfPlanedDemandSize = carrier.getShipments().values().stream().mapToInt(carrierShipment -> carrierShipment.getDemand()).sum(); + numberOfPlanedDemandSize = carrier.getShipments().values().stream().mapToInt(carrierShipment -> carrierShipment.getCapacityDemand()).sum(); numberOfHandledDemandSize = carrier.getSelectedPlan().getScheduledTours().stream().mapToInt( t -> t.getTour().getTourElements().stream().filter(te -> te instanceof Tour.Pickup).mapToInt( - te -> ((Tour.Pickup) te).getShipment().getDemand()).sum()).sum(); + te -> ((Tour.Pickup) te).getShipment().getCapacityDemand()).sum()).sum(); notHandledJobs = numberOfPlanedShipments - numberOfHandledPickups; } else { - numberOfPlanedDemandSize = carrier.getServices().values().stream().mapToInt(carrierService -> carrierService.getDemand()).sum(); + numberOfPlanedDemandSize = carrier.getServices().values().stream().mapToInt(carrierService -> carrierService.getCapacityDemand()).sum(); numberOfHandledDemandSize = carrier.getSelectedPlan().getScheduledTours().stream().mapToInt( t -> t.getTour().getTourElements().stream().filter(te -> te instanceof Tour.ServiceActivity).mapToInt( - te -> ((Tour.ServiceActivity) te).getService().getDemand()).sum()).sum(); + te -> ((Tour.ServiceActivity) te).getService().getCapacityDemand()).sum()).sum(); notHandledJobs = numberOfPlanedServices - nuOfServiceHandled; } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java index f0a2cc0fde6..cdfed51334c 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierServiceStartEvent.java @@ -47,7 +47,7 @@ public CarrierServiceStartEvent(double time, Id carrierId, CarrierServi super(time, carrierId, service.getServiceLinkId(), vehicleId); this.serviceId = service.getId(); this.serviceDuration = service.getServiceDuration(); - this.capacityDemand = service.getDemand(); + this.capacityDemand = service.getCapacityDemand(); } @Override @@ -85,7 +85,7 @@ public static CarrierServiceStartEvent convert(GenericEvent event) { Id locationLinkId = Id.createLinkId(attributes.get(ATTRIBUTE_LINK)); CarrierService service = CarrierService.Builder.newInstance(carrierServiceId, locationLinkId) .setServiceDuration(Double.parseDouble(attributes.get(CarrierEventAttributes.ATTRIBUTE_SERVICE_DURATION))) - .setDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND))) + .setCapacityDemand(Integer.parseInt(attributes.get(CarrierEventAttributes.ATTRIBUTE_CAPACITYDEMAND))) .build(); Id vehicleId = Id.create(attributes.get(ATTRIBUTE_VEHICLE), Vehicle.class); return new CarrierServiceStartEvent(time, carrierId, service, vehicleId); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java index 2687b550387..dad4d821be8 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryEndEvent.java @@ -47,7 +47,7 @@ public CarrierShipmentDeliveryEndEvent(double time, Id carrierId, Carri super(time, carrierId, shipment.getDeliveryLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryDuration(); - this.capacityDemand = shipment.getDemand(); + this.capacityDemand = shipment.getCapacityDemand(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java index ca4a2ec4767..ecbe02e3222 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentDeliveryStartEvent.java @@ -48,7 +48,7 @@ public CarrierShipmentDeliveryStartEvent(double time, Id carrierId, Car super(time, carrierId, shipment.getDeliveryLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.deliveryDuration = shipment.getDeliveryDuration(); - this.capacityDemand = shipment.getDemand(); + this.capacityDemand = shipment.getCapacityDemand(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java index 97da9f70817..a749c002290 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupEndEvent.java @@ -49,7 +49,7 @@ public CarrierShipmentPickupEndEvent(double time, Id carrierId, Carrier super(time, carrierId, shipment.getPickupLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupDuration(); - this.capacityDemand = shipment.getDemand(); + this.capacityDemand = shipment.getCapacityDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java index 7334a9fa8a6..aab4507b285 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/events/CarrierShipmentPickupStartEvent.java @@ -47,7 +47,7 @@ public CarrierShipmentPickupStartEvent(double time, Id carrierId, Carri super(time, carrierId, shipment.getPickupLinkId(), vehicleId); this.shipmentId = shipment.getId(); this.pickupDuration = shipment.getPickupDuration(); - this.capacityDemand = shipment.getDemand(); + this.capacityDemand = shipment.getCapacityDemand(); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 11776d0152b..ceb72f05b08 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -118,7 +118,7 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment) { .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierShipment.getPickupStartsTimeWindow().getStart(), carrierShipment.getPickupStartsTimeWindow().getEnd())) - .addSizeDimension(0, carrierShipment.getDemand()); + .addSizeDimension(0, carrierShipment.getCapacityDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); } @@ -149,7 +149,7 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord from .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierShipment.getPickupStartsTimeWindow().getStart(), carrierShipment.getPickupStartsTimeWindow().getEnd())) - .addSizeDimension(0, carrierShipment.getDemand()); + .addSizeDimension(0, carrierShipment.getCapacityDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); } @@ -165,7 +165,7 @@ static Service createJspritService(CarrierService carrierService, Coord location Location location = locationBuilder.build(); Builder serviceBuilder = Builder.newInstance(carrierService.getId().toString()); - serviceBuilder.addSizeDimension(0, carrierService.getDemand()); + serviceBuilder.addSizeDimension(0, carrierService.getCapacityDemand()); serviceBuilder.setLocation(location).setServiceTime(carrierService.getServiceDuration()) .setTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( carrierService.getServiceStartTimeWindow().getStart(), @@ -184,7 +184,7 @@ static Service createJspritService(CarrierService carrierService, Coord location static CarrierService createCarrierService(Service jspritService) { CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance( Id.create(jspritService.getId(), CarrierService.class), Id.create(jspritService.getLocation().getId(), Link.class)); - serviceBuilder.setDemand(jspritService.getSize().get(0)); + serviceBuilder.setCapacityDemand(jspritService.getSize().get(0)); serviceBuilder.setServiceDuration(jspritService.getServiceDuration()); serviceBuilder.setServiceStartTimeWindow( org.matsim.freight.carriers.TimeWindow.newInstance(jspritService.getTimeWindow().getStart(), jspritService.getTimeWindow().getEnd())); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java index 573e97f3a89..78a30e22b17 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java @@ -101,7 +101,7 @@ private static void createCustomers(Carrier carrier, Network network) { for(int i=0;i<20;i++){ CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create((i + 1),CarrierService.class), drawLocationLinkId(innerCityLinks, outerCityLinks)); - serviceBuilder.setDemand(1); + serviceBuilder.setCapacityDemand(1); serviceBuilder.setServiceDuration(5*60); serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(6*60*60, 15*60*60)); CarrierService carrierService = serviceBuilder.build(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java index 8670ad977ea..a7f33bfd794 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java @@ -59,7 +59,7 @@ public static Collection createLSPShipmentsFromCarrierShipments(Car LspShipmentUtils.LspShipmentBuilder builder = LspShipmentUtils.LspShipmentBuilder.newInstance( Id.create(shipment.getId().toString(), LspShipment.class)); - builder.setCapacityDemand(shipment.getDemand()); + builder.setCapacityDemand(shipment.getCapacityDemand()); builder.setFromLinkId(shipment.getPickupLinkId()); builder.setToLinkId(shipment.getDeliveryLinkId()); builder.setStartTimeWindow(shipment.getPickupStartsTimeWindow()); 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 f6473a6fcad..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 @@ -84,7 +84,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom()) .setServiceStartTimeWindow(TimeWindow.newInstance(lspShipment.getPickupTimeWindow().getStart(), lspShipment.getPickupTimeWindow().getEnd())) - .setDemand(lspShipment.getSize()) + .setCapacityDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan 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 f3814a036e6..cd988bce679 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 @@ -184,7 +184,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getTo()) //TODO TimeWindows are not set. This seems to be a problem. KMT'Aug'24 //If added here, we also need to decide what happens, if the vehicles StartTime (plus TT) is > TimeWindowEnd .... - .setDemand(lspShipment.getSize()) + .setCapacityDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java index abcc023fa20..99f49186e11 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -229,7 +229,7 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService.Builder builder = CarrierService.Builder.newInstance(serviceId, resource.getEndLinkId()); - builder.setDemand(lspShipment.getSize()); + builder.setCapacityDemand(lspShipment.getSize()); builder.setServiceDuration(lspShipment.getDeliveryServiceTime()); return builder.build(); } 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 839f2cceaef..260af466448 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 @@ -68,7 +68,7 @@ void testAddAndGetServiceToCarrier() { Carrier carrier = new CarrierImpl(Id.create("carrier", Carrier.class)); Id serviceId = Id.create("testVehicle", CarrierService.class); CarrierService service1 = CarrierService.Builder.newInstance(serviceId,Id.createLinkId("link0") ) - .setDemand(15).setServiceDuration(30).build(); + .setCapacityDemand(15).setServiceDuration(30).build(); //add Service CarriersUtils.addService(carrier, service1); @@ -105,7 +105,7 @@ void testAddAndGetShipmentToCarrier() { Assertions.assertEquals(shipmentId, carrierShipment1b.getId()); Assertions.assertEquals(service1.getId(), carrierShipment1b.getId()); Assertions.assertEquals(Id.createLinkId("link0"), carrierShipment1b.getPickupLinkId()); - Assertions.assertEquals(20, carrierShipment1b.getDemand(), EPSILON); + Assertions.assertEquals(20, carrierShipment1b.getCapacityDemand(), EPSILON); } @Test 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 e729e5360d6..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 @@ -421,14 +421,14 @@ private static Carrier addTwoServicesToCarrier(Carrier carrier) { CarrierService service1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 CarrierService service2 = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service2); return carrier; @@ -442,7 +442,7 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { CarrierService service3 = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service3); return carrier; 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 3747a98a882..b3d2cfbf0f2 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 @@ -614,14 +614,14 @@ private static Carrier addTwoServicesToCarrier(Carrier carrier) { CarrierService service1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 CarrierService service2 = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service2); return carrier; @@ -653,7 +653,7 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { CarrierService service3 = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) - .setDemand(40).build(); + .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service3); return carrier; 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 494c9f106e6..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 @@ -200,7 +200,7 @@ final void test_carrier3CostsAreCorrectly() { private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setDemand(size) + .setCapacityDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); 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 2882cec1336..ab344578513 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 @@ -122,7 +122,7 @@ void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { void whenTransforming_matsimService2jspritService_isMadeCorrectly() { CarrierService carrierService = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("locationId", Link.class)) - .setDemand(50).setServiceDuration(30.0) + .setCapacityDemand(50).setServiceDuration(30.0) .setServiceStartTimeWindow(TimeWindow.newInstance(10.0, 20.0)).build(); Service service = MatsimJspritFactory.createJspritService(carrierService, null); assertNotNull(service); @@ -148,7 +148,7 @@ void whenTransforming_jspritService2matsimService_isMadeCorrectly() { assertNotNull(service); assertEquals("locationId", service.getServiceLinkId().toString()); assertEquals(30.0, service.getServiceDuration(), 0.01); - assertEquals(50, service.getDemand()); + assertEquals(50, service.getCapacityDemand()); assertEquals(10.0, service.getServiceStartTimeWindow().getStart(), 0.01); CarrierService service2 = MatsimJspritFactory.createCarrierService(carrierService); @@ -201,7 +201,7 @@ void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { assertEquals(40.0, carrierShipment.getDeliveryDuration(), 0.01); assertEquals(50.0, carrierShipment.getDeliveryStartsTimeWindow().getStart(), 0.01); assertEquals(60.0, carrierShipment.getDeliveryStartsTimeWindow().getEnd(), 0.01); - assertEquals(50, carrierShipment.getDemand()); + assertEquals(50, carrierShipment.getCapacityDemand()); CarrierShipment carrierShipment2 = MatsimJspritFactory.createCarrierShipment(shipment); assertNotSame(carrierShipment, carrierShipment2); @@ -333,10 +333,10 @@ void whenTransforming_matsimPlan2vehicleRouteSolution_itIsMadeCorrectly() { private ScheduledTour getMatsimServiceTour() { CarrierService s1 = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("to1", Link.class)) - .setDemand(20).build(); + .setCapacityDemand(20).build(); CarrierService s2 = CarrierService.Builder .newInstance(Id.create("serviceId2", CarrierService.class), Id.create("to2", Link.class)) - .setDemand(10).build(); + .setCapacityDemand(10).build(); CarrierVehicle matsimVehicle = getMatsimVehicle("matsimVehicle", "loc", getMatsimVehicleType()); double startTime = 15.0; Tour.Builder sTourBuilder = Tour.Builder.newInstance(Id.create("testTour", Tour.class)); @@ -503,11 +503,11 @@ private Carrier createCarrierWithServices() { carrier.setCarrierCapabilities(ccBuilder.build()); CarrierService carrierService1 = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("i(7,4)R", Link.class)) - .setDemand(20).setServiceDuration(10.0).build(); + .setCapacityDemand(20).setServiceDuration(10.0).build(); CarriersUtils.addService(carrier, carrierService1); CarrierService carrierService2 = CarrierService.Builder .newInstance(Id.create("serviceId2", CarrierService.class), Id.create("i(3,9)", Link.class)) - .setDemand(10).setServiceDuration(20.0).build(); + .setCapacityDemand(10).setServiceDuration(20.0).build(); CarriersUtils.addService(carrier, carrierService2); return carrier; } 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 249da6bf44b..17aef0ebddd 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 @@ -294,7 +294,7 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setDemand(size) + .setCapacityDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(0.0, 36001.0)) .build(); 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 393f73088a3..25e5218e3ab 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 @@ -165,7 +165,7 @@ void numberOfInitialServicesIsCorrect() { int demandServices = 0; for (CarrierService carrierService : carrierWServices.getServices().values()) { - demandServices += carrierService.getDemand(); + demandServices += carrierService.getCapacityDemand(); } Assertions.assertEquals(4, demandServices); @@ -180,7 +180,7 @@ void numberOfInitialShipmentsIsCorrect() { Assertions.assertEquals(2, carrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipments.getShipments().values()) { - demandShipments += carrierShipment.getDemand(); + demandShipments += carrierShipment.getCapacityDemand(); } Assertions.assertEquals(3, demandShipments); } @@ -192,7 +192,7 @@ void numberOfShipmentsFromCopiedShipmentsIsCorrect() { Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWShipments.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { - demandShipments += carrierShipment.getDemand(); + demandShipments += carrierShipment.getCapacityDemand(); } Assertions.assertEquals(4, demandShipments); } @@ -204,7 +204,7 @@ void numberOfShipmentsFromConvertedServicesIsCorrect() { Assertions.assertEquals(2, carrierWShipmentsOnlyFromCarrierWServices.getShipments().size()); int demandShipments = 0; for (CarrierShipment carrierShipment : carrierWShipmentsOnlyFromCarrierWServices.getShipments().values()) { - demandShipments += carrierShipment.getDemand(); + demandShipments += carrierShipment.getCapacityDemand(); } Assertions.assertEquals(4, demandShipments); } @@ -246,7 +246,7 @@ void copyingOfShipmentsIsDoneCorrectly() { foundShipment1 = true; Assertions.assertEquals(Id.createLinkId("i(1,0)"), carrierShipment1.getPickupLinkId()); Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getDeliveryLinkId()); - Assertions.assertEquals(1, carrierShipment1.getDemand()); + Assertions.assertEquals(1, carrierShipment1.getCapacityDemand()); Assertions.assertEquals(30.0, carrierShipment1.getDeliveryDuration(), 0); Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); @@ -261,7 +261,7 @@ void copyingOfShipmentsIsDoneCorrectly() { foundShipment2 = true; Assertions.assertEquals(Id.createLinkId("i(3,0)"), carrierShipment2.getPickupLinkId()); Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getDeliveryLinkId()); - Assertions.assertEquals(2, carrierShipment2.getDemand()); + Assertions.assertEquals(2, carrierShipment2.getCapacityDemand()); Assertions.assertEquals(30.0, carrierShipment2.getDeliveryDuration(), 0); Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); @@ -284,7 +284,7 @@ void convertionOfServicesIsDoneCorrectly() { foundService1 = true; Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment1.getPickupLinkId()); Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getDeliveryLinkId()); - Assertions.assertEquals(2, carrierShipment1.getDemand()); + Assertions.assertEquals(2, carrierShipment1.getCapacityDemand()); Assertions.assertEquals(31.0, carrierShipment1.getDeliveryDuration(), 0); Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); @@ -298,7 +298,7 @@ void convertionOfServicesIsDoneCorrectly() { foundService2 = true; Assertions.assertEquals(Id.createLinkId("i(6,0)"), carrierShipment2.getPickupLinkId()); Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getDeliveryLinkId()); - Assertions.assertEquals(2, carrierShipment2.getDemand()); + Assertions.assertEquals(2, carrierShipment2.getCapacityDemand()); Assertions.assertEquals(31.0, carrierShipment2.getDeliveryDuration(), 0); Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); @@ -352,7 +352,7 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri private static CarrierService createMatsimService(String id, String to, int size) { return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) - .setDemand(size) + .setCapacityDemand(size) .setServiceDuration(31.0) .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); 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 b1d60e9665a..885f3605bef 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 @@ -237,7 +237,7 @@ public void testCollectionTracker() { if (element instanceof ServiceActivity activity) { scheduledCosts += activity.getService().getServiceDuration() * scheduledTour.getVehicle().getType().getCostInformation().getCostsPerSecond(); totalScheduledCosts += scheduledCosts; - totalScheduledWeight += activity.getService().getDemand(); + totalScheduledWeight += activity.getService().getCapacityDemand(); totalNumberOfScheduledShipments++; } } diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index ba6d1fd35e7..6b2d687682a 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -197,7 +197,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -212,7 +212,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index 11d49bd6c0b..3bd4a739ab3 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -434,7 +434,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -461,7 +461,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), toLinkId); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -485,7 +485,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -503,7 +503,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -522,7 +522,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -540,7 +540,7 @@ public void testCompletedLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -558,7 +558,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); @@ -576,7 +576,7 @@ public void testCompletedLSPScheduling() { DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 76191192a70..79c1f837d8c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -260,7 +260,7 @@ public void testFirstReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -284,7 +284,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -297,7 +297,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index ce0a83639a8..f02cceaf33e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -325,7 +325,7 @@ public void testMainRunLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -351,7 +351,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -369,7 +369,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -388,7 +388,7 @@ public void testMainRunLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -406,7 +406,7 @@ public void testMainRunLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index d3fe9b5214d..f4b4da0cc44 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -199,7 +199,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -212,7 +212,7 @@ public void testCollectionLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index 1a584b463b5..f4551bd70b9 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -437,7 +437,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -464,7 +464,7 @@ public void testCompletedLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), toLinkId); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -488,7 +488,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -506,7 +506,7 @@ public void testCompletedLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -525,7 +525,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -543,7 +543,7 @@ public void testCompletedLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -561,7 +561,7 @@ public void testCompletedLSPScheduling() { LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(lspTourStartEventHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); @@ -579,7 +579,7 @@ public void testCompletedLSPScheduling() { DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(distributionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index 4d41d635e10..b107d0f4acb 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -259,7 +259,7 @@ public void testFirstReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -283,7 +283,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -296,7 +296,7 @@ public void testFirstReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index b63c6d854d4..9810f9f0d18 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -325,7 +325,7 @@ public void testMainRunLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -351,7 +351,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(endHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -369,7 +369,7 @@ public void testMainRunLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(serviceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -388,7 +388,7 @@ public void testMainRunLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -406,7 +406,7 @@ public void testMainRunLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 03f374b15f0..44d2a92c239 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -369,7 +369,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -401,7 +401,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), toLinkId); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { @@ -431,7 +431,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -450,7 +450,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -470,7 +470,7 @@ public void testSecondReloadLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -489,7 +489,7 @@ public void testSecondReloadLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index 66a30fa10d4..7ee63e8b74c 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -369,7 +369,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), shipment.getFrom()); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -407,7 +407,7 @@ public void testSecondReloadLSPScheduling() { LspShipment shipment = entry.getValue().lspShipment; LogisticChainElement element = entry.getValue().logisticChainElement; assertSame(service.getServiceLinkId(), toLinkId); - assertEquals(service.getDemand(), shipment.getSize()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); boolean handledByTranshipmentHub = false; for (LogisticChainElement clientElement : @@ -438,7 +438,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(collectionEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -457,7 +457,7 @@ public void testSecondReloadLSPScheduling() { assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); - assertEquals(collectionServiceHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); @@ -477,7 +477,7 @@ public void testSecondReloadLSPScheduling() { LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunStartHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); @@ -496,7 +496,7 @@ public void testSecondReloadLSPScheduling() { LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(mainRunEndHandler.getCarrierService().getDemand(), shipment.getSize()); + assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java index 28820157125..9749c3b83fe 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java @@ -86,7 +86,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { // TODO This only looks at the FIRST time window. This may need revision once we handle multiple // time windows. .build(); - if (newShipment.getDemand() != 0) { + if (newShipment.getCapacityDemand() != 0) { receiverOrder.getCarrier().getShipments().put(newShipment.getId(), newShipment ); } } From 6b364b574049eb0f4500635a5b8a3a29d2a05abf Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 22:38:55 +0100 Subject: [PATCH 07/13] rename it back to capacityDemand; add a Builder for CarrierService that includes the capacity demand directly --- .../freight/carriers/CarrierService.java | 43 ++++++++++++++++--- .../freight/carriers/CarrierShipment.java | 20 ++++----- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index bad47e13a95..2582fe16a89 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -31,7 +31,7 @@ public final class CarrierService implements CarrierJob { public static class Builder { private final Id id; - private int capacityDemand = 0; + private int capacityDemand; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). @@ -40,14 +40,46 @@ public static class Builder { private TimeWindow serviceStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double serviceDuration = 0.0; - public static Builder newInstance(Id id, Id locationLinkId){ - return new Builder(id,locationLinkId); + + /** + * Returns a new service builder. + *

+ * The builder is init with the service's location, and with the service's demand. + * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. + *

+ * The capacity demand is set by default to 0 and needs to be changed later by calling {@link #setCapacityDemand(int)}. + * + * @deprecated since jan'25, use {@link #newInstance(Id, Id, int)} instead + * + * @param id the id of the shipment + * @param locationLinkId the location (link Id) where the service is performed + * @return the builder + */ + @Deprecated(since = "jan'25") + public static Builder newInstance(Id id, Id locationLinkId) { + return newInstance(id, locationLinkId, 0); + } + + /** + * Returns a new service builder. + *

+ * The builder is init with the service's location, and with the service's demand. + * The default-value for serviceTime is 0.0. The default-value for a timeWindow is [start=0.0, end=Double.maxValue()]. + * + * @param id the id of the shipment + * @param locationLinkId the location (link Id) where the service is performed + * @param capacityDemand the demand (size; capacity needed) of the service + * @return the builder + */ + public static Builder newInstance(Id id, Id locationLinkId, int capacityDemand){ + return new Builder(id,locationLinkId, capacityDemand ); } - private Builder(Id id, Id serviceLinkId) { + private Builder(Id id, Id serviceLinkId, int capacityDemand) { super(); this.id = id; this.serviceLinkId = serviceLinkId; + this.capacityDemand = capacityDemand; } public CarrierService build(){ @@ -82,16 +114,17 @@ public Builder setServiceDuration(double serviceDuration){ return this; } - /** * Sets the demand (size; capacity needed) of the service. * When not set, it is by default 0. *

* IMO we can put this into the Builder directly instead of a separate method? kturner dec'24 + * @deprecated please use the constructor including the capacity demand {@link #newInstance(Id, Id, int)} instead * * @param capacityDemand the demand (size; capacity needed) of the service * @return the builder */ + @Deprecated(since = "jan'25") public Builder setCapacityDemand(int capacityDemand) { this.capacityDemand = capacityDemand; return this; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 1ba23034184..b42637da366 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -46,7 +46,7 @@ public final class CarrierShipment implements CarrierJob { public static class Builder { private final Id id; - private final int demand; + private final int capacityDemand; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). @@ -71,19 +71,19 @@ public static class Builder { * @param id the id of the shipment * @param from the origin * @param to the destination - * @param demand demand of the shipment + * @param capacityDemand the demand (size; capacity needed) of the shipment * @return the builder */ - public static Builder newInstance(Id id, Id from, Id to, int demand){ - return new Builder(id, from, to, demand); + public static Builder newInstance(Id id, Id from, Id to, int capacityDemand){ + return new Builder(id, from, to, capacityDemand); } - private Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int demand) { + private Builder(Id id, Id pickupLinkId, Id deliveryLinkId, int capacityDemand) { super(); this.id = id; this.pickupLinkId = pickupLinkId; this.deliveryLinkId = deliveryLinkId; - this.demand = demand; + this.capacityDemand = capacityDemand; } /** @@ -181,7 +181,7 @@ public Builder setDeliveryServiceTime(double deliveryServiceTime){ } private final Id id; - private final int demand; + private final int capacityDemand; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). @@ -204,7 +204,7 @@ private CarrierShipment(Builder builder) { id = builder.id; pickupLinkId = builder.pickupLinkId; deliveryLinkId = builder.deliveryLinkId; - demand = builder.demand; + capacityDemand = builder.capacityDemand; pickupDuration = builder.pickupDuration; deliveryDuration = builder.deliveryDuration; pickupStartsTimeWindow = builder.pickupStartsTimeWindow; @@ -261,7 +261,7 @@ public Id getDeliveryLinkId() { */ @Override public int getCapacityDemand() { - return demand; + return capacityDemand; } public TimeWindow getPickupStartsTimeWindow() { @@ -357,7 +357,7 @@ public void setDeliveryServiceTime(double deliveryDuration) { @Override public String toString() { - return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + demand + "][pickupServiceTime=" + pickupDuration + "]" + + return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + capacityDemand + "][pickupServiceTime=" + pickupDuration + "]" + "[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartsTimeWindow +"][deliveryTimeWindow="+ deliveryStartsTimeWindow +"]"; } From a0e5ff2132af6ab2a4f3569a8fb2bd03b6b55792 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 22:53:56 +0100 Subject: [PATCH 08/13] rename serviceStartTimeWindow to serviceStartingTimeWindow; keep old setter as deprecated to avoid code breaking --- .../DemandReaderFromCSV.java | 24 +++++++++---------- .../DefaultCommercialJobGenerator.java | 4 ++-- .../carriers/CarrierPlanXmlParserV2.java | 2 +- .../carriers/CarrierPlanXmlParserV2_1.java | 2 +- .../freight/carriers/CarrierService.java | 21 ++++++++++++++-- .../carriers/jsprit/MatsimJspritFactory.java | 4 ++-- .../chessboard/FreightScenarioCreator.java | 4 ++-- .../CollectionCarrierScheduler.java | 4 ++-- ...istanceConstraintFromVehiclesFileTest.java | 15 +++++++----- .../jsprit/DistanceConstraintTest.java | 15 +++++++----- .../carriers/jsprit/FixedCostsTest.java | 6 ++--- .../carriers/jsprit/IntegrationIT.java | 5 ++-- .../jsprit/MatsimTransformerTest.java | 6 ++--- .../utils/CarrierControllerUtilsIT.java | 6 ++--- .../utils/CarrierControllerUtilsTest.java | 6 ++--- .../DefaultUnhandledServicesSolution.java | 10 ++++---- ...rateSmallScaleCommercialTrafficDemand.java | 5 ++-- 17 files changed, 81 insertions(+), 58 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 63347fdcb66..b72bac3cf9c 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -654,9 +654,9 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { Id idNewService = Id.create( createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); - CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime) - .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) + CarrierService.Builder builder = CarrierService.Builder.newInstance(idNewService, link.getId()) + .setCapacityDemand(demandForThisLink).setServiceDuration(serviceTime); + CarrierService thisService = builder.setServiceStartingTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class)).getServices() @@ -695,9 +695,9 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); if (demandToDistribute > 0 && singleDemandForThisLink > 0) { - CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) - .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) + CarrierService.Builder builder = CarrierService.Builder.newInstance(idNewService, link.getId()) + .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime); + CarrierService thisService = builder.setServiceStartingTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); thisCarrier.getServices().put(thisService.getId(), thisService); } @@ -746,9 +746,9 @@ else if (samplingOption.equals("changeNumberOfLocationsWithDemand")) { Id idNewService = Id.create( createJobId(scenario, newDemandInformationElement, link.getId(), null), CarrierService.class); if ((demandToDistribute > 0 && singleDemandForThisLink > 0) || demandToDistribute == 0) { - CarrierService thisService = CarrierService.Builder.newInstance(idNewService, link.getId()) - .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime) - .setServiceStartTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) + CarrierService.Builder builder = CarrierService.Builder.newInstance(idNewService, link.getId()) + .setCapacityDemand(singleDemandForThisLink).setServiceDuration(serviceTime); + CarrierService thisService = builder.setServiceStartingTimeWindow(newDemandInformationElement.getFirstJobElementTimeWindow()) .build(); CarriersUtils.getCarriers(scenario).getCarriers() .get(Id.create(newDemandInformationElement.getCarrierName(), Carrier.class)).getServices() @@ -1250,10 +1250,10 @@ private static void combineSimilarJobs(Scenario scenario) { serviceTimeService = serviceTimeService + carrierService.getServiceDuration(); servicesToRemove.put(carrierService.getId(), carrierService); } - CarrierService newService = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(idNewService, baseService.getServiceLinkId()) - .setServiceDuration(serviceTimeService) - .setServiceStartTimeWindow(baseService.getServiceStartTimeWindow()) + .setServiceDuration(serviceTimeService); + CarrierService newService = builder.setServiceStartingTimeWindow(baseService.getServiceStartTimeWindow()) .setCapacityDemand(demandForThisLink).build(); servicesToAdd.add(newService); } diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java index 3327f46292c..3c80d3b1e0a 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/DefaultCommercialJobGenerator.java @@ -331,9 +331,9 @@ public void generateIterationServices(Carriers carriers, Population population) CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(serviceId, PopulationUtils.decideOnLinkIdForActivity(activity,scenario)); serviceBuilder.setCapacityDemand(Integer.parseInt(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_AMOUNT_IDX))); serviceBuilder.setServiceDuration(Double.parseDouble(commercialJobProperties.get(COMMERCIALJOB_ATTRIBUTE_DURATION_IDX))); - serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(earliestStart,latestStart)); + serviceBuilder.setServiceStartingTimeWindow(TimeWindow.newInstance(earliestStart,latestStart)); - Id carrierId = JointDemandUtils.getCurrentlySelectedCarrierForJob(activity, jobIdx); + Id carrierId = JointDemandUtils.getCurrentlySelectedCarrierForJob(activity, jobIdx); if (carriers.getCarriers().containsKey(carrierId)) { Carrier carrier = carriers.getCarriers().get(carrierId); CarrierService service = serviceBuilder.build(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java index 9645408a619..892ca375861 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java @@ -123,7 +123,7 @@ public void startTag(String name, Attributes atts, Stack context) { double end; String endString = atts.getValue("latestEnd"); end = parseTimeToDouble(endString); - serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(start, end)); + serviceBuilder.setServiceStartingTimeWindow(TimeWindow.newInstance(start, end)); String serviceTimeString = atts.getValue("serviceDuration"); if (serviceTimeString != null) serviceBuilder.setServiceDuration(parseTimeToDouble(serviceTimeString)); currentService = serviceBuilder.build(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java index 0f3a7180dff..ab989b4c31a 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java @@ -121,7 +121,7 @@ public void startTag(String name, Attributes atts, Stack context) { double end; String endString = atts.getValue("latestEnd"); end = parseTimeToDouble(endString); - serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(start, end)); + serviceBuilder.setServiceStartingTimeWindow(TimeWindow.newInstance(start, end)); String serviceTimeString = atts.getValue("serviceDuration"); if (serviceTimeString != null) serviceBuilder.setServiceDuration(parseTimeToDouble(serviceTimeString)); currentService = serviceBuilder.build(); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 2582fe16a89..7e2d84d9d89 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -88,7 +88,7 @@ public CarrierService build(){ /** - * Sets a time-window for the beginning of the service + * Sets a time-window for the beginning of the service * When not set, it is by default [0.0., Integer.MAX_VALUE]. *

* Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that @@ -97,11 +97,28 @@ public CarrierService build(){ * @param startTimeWindow time-window for the beginning of the service activity * @return the builder */ - public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ + public Builder setServiceStartingTimeWindow(TimeWindow startTimeWindow){ this.serviceStartsTimeWindow = startTimeWindow; return this; } + /** + * Sets a time-window for the beginning of the service + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that + * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @deprecated since jan'25, use {@link #setServiceStartingTimeWindow(TimeWindow)} instead + * + * @param startTimeWindow time-window for the beginning of the service activity + * @return the builder + */ + @Deprecated(since = "jan'25") + public Builder setServiceStartTimeWindow(TimeWindow startTimeWindow){ + return setServiceStartingTimeWindow(startTimeWindow); + } + /** * Sets the duration for the pickup activity. * When not set, it is by default 0.0. diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index ceb72f05b08..97a94d8b6ad 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -58,6 +58,7 @@ import org.matsim.api.core.v01.network.Network; import org.matsim.core.utils.io.IOUtils; import org.matsim.freight.carriers.*; +import org.matsim.freight.carriers.TimeWindow; import org.matsim.vehicles.VehicleType; import org.matsim.vehicles.VehicleUtils; @@ -186,8 +187,7 @@ static CarrierService createCarrierService(Service jspritService) { Id.create(jspritService.getId(), CarrierService.class), Id.create(jspritService.getLocation().getId(), Link.class)); serviceBuilder.setCapacityDemand(jspritService.getSize().get(0)); serviceBuilder.setServiceDuration(jspritService.getServiceDuration()); - serviceBuilder.setServiceStartTimeWindow( - org.matsim.freight.carriers.TimeWindow.newInstance(jspritService.getTimeWindow().getStart(), jspritService.getTimeWindow().getEnd())); + serviceBuilder.setServiceStartingTimeWindow(TimeWindow.newInstance(jspritService.getTimeWindow().getStart(), jspritService.getTimeWindow().getEnd())); CarrierService carrierService = serviceBuilder.build(); CarriersUtils.setSkills(carrierService, jspritService.getRequiredSkills().values()); return carrierService; diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java index 78a30e22b17..eec4fe29a39 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/usecases/chessboard/FreightScenarioCreator.java @@ -103,8 +103,8 @@ private static void createCustomers(Carrier carrier, Network network) { CarrierService.Builder serviceBuilder = CarrierService.Builder.newInstance(Id.create((i + 1),CarrierService.class), drawLocationLinkId(innerCityLinks, outerCityLinks)); serviceBuilder.setCapacityDemand(1); serviceBuilder.setServiceDuration(5*60); - serviceBuilder.setServiceStartTimeWindow(TimeWindow.newInstance(6*60*60, 15*60*60)); - CarrierService carrierService = serviceBuilder.build(); + serviceBuilder.setServiceStartingTimeWindow(TimeWindow.newInstance(6*60*60, 15*60*60)); + CarrierService carrierService = serviceBuilder.build(); CarriersUtils.addService(carrier, carrierService); } } 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 d91bf1c94f5..1cc1d47f9ba 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 @@ -82,8 +82,8 @@ public void scheduleResource() { private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = Id.create(lspShipment.getId().toString(), CarrierService.class); - CarrierService carrierService = CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom()) - .setServiceStartTimeWindow(TimeWindow.newInstance(lspShipment.getPickupTimeWindow().getStart(), lspShipment.getPickupTimeWindow().getEnd())) + CarrierService.Builder builder = CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom()); + CarrierService carrierService = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(lspShipment.getPickupTimeWindow().getStart(), lspShipment.getPickupTimeWindow().getEnd())) .setCapacityDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); 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 43557b37a2a..cce3e70853b 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 @@ -418,16 +418,18 @@ private void prepareConfig(Config config) { private static Carrier addTwoServicesToCarrier(Carrier carrier) { // Service 1 - CarrierService service1 = CarrierService.Builder + CarrierService.Builder builder1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service1 = builder1.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 - CarrierService service2 = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service2 = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service2); @@ -439,9 +441,10 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { addTwoServicesToCarrier(carrier); // Service 3 - CarrierService service3 = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service3 = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service3); 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 b3d2cfbf0f2..394e388e82d 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 @@ -611,16 +611,18 @@ static void prepareConfig(Config config) { private static Carrier addTwoServicesToCarrier(Carrier carrier) { // Service 1 - CarrierService service1 = CarrierService.Builder + CarrierService.Builder builder1 = CarrierService.Builder .newInstance(Id.create("Service1", CarrierService.class), Id.createLinkId("j(3,8)")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service1 = builder1.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service1); // Service 2 - CarrierService service2 = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(Id.create("Service2", CarrierService.class), Id.createLinkId("j(0,3)R")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service2 = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service2); @@ -650,9 +652,10 @@ private static Carrier addThreeServicesToCarrier(Carrier carrier) { addTwoServicesToCarrier(carrier); // Service 3 - CarrierService service3 = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(Id.create("Service3", CarrierService.class), Id.createLinkId("j(9,2)")) - .setServiceDuration(20).setServiceStartTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) + .setServiceDuration(20); + CarrierService service3 = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 10 * 3600)) .setCapacityDemand(40).build(); CarriersUtils.addService(carrier, service3); 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 cf5060bf772..c66458b26d2 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 @@ -199,10 +199,10 @@ final void test_carrier3CostsAreCorrectly() { } private static CarrierService createMatsimService(String id, String to, int size) { - return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) + CarrierService.Builder builder = CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) .setCapacityDemand(size) - .setServiceDuration(31.0) - .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) + .setServiceDuration(31.0); + return builder.setServiceStartingTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); } 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 6c61511a480..8ee297c4900 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 @@ -88,9 +88,10 @@ void testJsprit() throws ExecutionException, InterruptedException { Assertions.assertEquals(2, carrier.getPlans().size(), "The number of plans is not as expected"); // Test method if all jobs are handled Assertions.assertTrue(CarriersUtils.allJobsHandledBySelectedPlan(carrier), "Not all jobs are handled"); - CarrierService newService = CarrierService.Builder.newInstance(Id.create( + CarrierService.Builder builder = CarrierService.Builder.newInstance(Id.create( "service" + carrier.getServices().size(), CarrierService.class), Id.createLinkId("100603")) - .setServiceDuration(10.).setServiceStartTimeWindow(TimeWindow.newInstance(0,86000)).build(); + .setServiceDuration(10.); + CarrierService newService = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(0, 86000)).build(); carrier.getServices().put(newService.getId(), newService); Assertions.assertFalse(CarriersUtils.allJobsHandledBySelectedPlan(carrier), "All jobs are handled although a new service was added"); } 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 ab344578513..a194df63983 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 @@ -120,10 +120,10 @@ void whenTransforming_matsimVehicle2jspritVehicle_itIsMadeCorrectly() { @Test void whenTransforming_matsimService2jspritService_isMadeCorrectly() { - CarrierService carrierService = CarrierService.Builder + CarrierService.Builder builder = CarrierService.Builder .newInstance(Id.create("serviceId", CarrierService.class), Id.create("locationId", Link.class)) - .setCapacityDemand(50).setServiceDuration(30.0) - .setServiceStartTimeWindow(TimeWindow.newInstance(10.0, 20.0)).build(); + .setCapacityDemand(50).setServiceDuration(30.0); + CarrierService carrierService = builder.setServiceStartingTimeWindow(TimeWindow.newInstance(10.0, 20.0)).build(); Service service = MatsimJspritFactory.createJspritService(carrierService, null); assertNotNull(service); assertEquals("locationId", service.getLocation().getId()); 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 17aef0ebddd..4518470191a 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 @@ -293,10 +293,10 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri } private static CarrierService createMatsimService(String id, String to, int size) { - return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) + CarrierService.Builder builder = CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) .setCapacityDemand(size) - .setServiceDuration(31.0) - .setServiceStartTimeWindow(TimeWindow.newInstance(0.0, 36001.0)) + .setServiceDuration(31.0); + return builder.setServiceStartingTimeWindow(TimeWindow.newInstance(0.0, 36001.0)) .build(); } } 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 25e5218e3ab..9cf70e22727 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 @@ -351,10 +351,10 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri } private static CarrierService createMatsimService(String id, String to, int size) { - return CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) + CarrierService.Builder builder = CarrierService.Builder.newInstance(Id.create(id, CarrierService.class), Id.create(to, Link.class)) .setCapacityDemand(size) - .setServiceDuration(31.0) - .setServiceStartTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) + .setServiceDuration(31.0); + return builder.setServiceStartingTimeWindow(TimeWindow.newInstance(3601.0, 36001.0)) .build(); } diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java index 109ac1f1288..29aa63e994b 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java @@ -4,10 +4,7 @@ import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Scenario; import org.matsim.core.gbl.MatsimRandom; -import org.matsim.freight.carriers.Carrier; -import org.matsim.freight.carriers.CarrierService; -import org.matsim.freight.carriers.CarrierVehicle; -import org.matsim.freight.carriers.CarriersUtils; +import org.matsim.freight.carriers.*; import java.util.*; import java.util.concurrent.ExecutionException; @@ -40,8 +37,9 @@ public List createListOfCarrierWithUnhandledJobs(Scenario scenario){ private void redrawAllServiceDurations(Carrier carrier, GenerateSmallScaleCommercialTrafficDemand.CarrierAttributes carrierAttributes, int additionalTravelBufferPerIterationInMinutes) { for (CarrierService service : carrier.getServices().values()) { double newServiceDuration = generator.getServiceTimePerStop(carrier, carrierAttributes, additionalTravelBufferPerIterationInMinutes); - CarrierService redrawnService = CarrierService.Builder.newInstance(service.getId(), service.getServiceLinkId()) - .setServiceDuration(newServiceDuration).setServiceStartTimeWindow(service.getServiceStartTimeWindow()).build(); + CarrierService.Builder builder = CarrierService.Builder.newInstance(service.getId(), service.getServiceLinkId()) + .setServiceDuration(newServiceDuration); + CarrierService redrawnService = builder.setServiceStartingTimeWindow(service.getServiceStartTimeWindow()).build(); carrier.getServices().put(redrawnService.getId(), redrawnService); } } 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 9faf05c8e55..d8818b887d4 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 @@ -800,8 +800,9 @@ private void createService(Carrier newCarrier, ArrayList noPossibleLinks Id idNewService = Id.create(newCarrier.getId().toString() + "_" + linkId + "_" + rnd.nextInt(10000), CarrierService.class); - CarrierService thisService = CarrierService.Builder.newInstance(idNewService, linkId) - .setServiceDuration(serviceTimePerStop).setServiceStartTimeWindow(serviceTimeWindow).build(); + CarrierService.Builder builder = CarrierService.Builder.newInstance(idNewService, linkId) + .setServiceDuration(serviceTimePerStop); + CarrierService thisService = builder.setServiceStartingTimeWindow(serviceTimeWindow).build(); newCarrier.getServices().put(thisService.getId(), thisService); } From 9b20a1489abacc3d9c46492733c2c43d90fab11c Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 22:56:20 +0100 Subject: [PATCH 09/13] rename serviceStartTimeWindow to serviceStartingTimeWindow; keep old setter as deprecated to avoid code breaking --- .../DemandReaderFromCSV.java | 4 +-- .../DemandReaderFromCSVTest.java | 10 +++---- .../jointDemand/ScoreCommercialJobs.java | 6 ++--- .../carriers/CarrierPlanXmlWriterV2_1.java | 4 +-- .../freight/carriers/CarrierService.java | 26 ++++++++++++------- .../freight/carriers/CarriersUtils.java | 4 +-- .../org/matsim/freight/carriers/Tour.java | 2 +- .../carriers/jsprit/MatsimJspritFactory.java | 4 +-- .../jsprit/MatsimTransformerTest.java | 2 +- .../CollectionLSPSchedulingTest.java | 8 +++--- .../CompleteLSPSchedulingTest.java | 24 ++++++++--------- .../FirstReloadLSPSchedulingTest.java | 8 +++--- .../MainRunLSPSchedulingTest.java | 16 ++++++------ ...eShipmentsCollectionLSPSchedulingTest.java | 8 +++--- ...pleShipmentsCompleteLSPSchedulingTest.java | 24 ++++++++--------- ...ShipmentsFirstReloadLSPSchedulingTest.java | 8 +++--- ...ipleShipmentsMainRunLSPSchedulingTest.java | 16 ++++++------ ...hipmentsSecondReloadLSPSchedulingTest.java | 16 ++++++------ .../SecondReloadLSPSchedulingTest.java | 16 ++++++------ .../DefaultUnhandledServicesSolution.java | 2 +- .../FreightAnalysisServiceTracking.java | 2 +- 21 files changed, 109 insertions(+), 101 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index b72bac3cf9c..ca6498d9ca1 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -1238,7 +1238,7 @@ private static void combineSimilarJobs(Scenario scenario) { CarrierService thisService = thisCarrier.getServices().get(thisServiceId); if (baseService.getId() != thisService.getId() && baseService.getServiceLinkId() == thisService.getServiceLinkId() && baseService - .getServiceStartTimeWindow() == thisService.getServiceStartTimeWindow()) + .getServiceStaringTimeWindow() == thisService.getServiceStaringTimeWindow()) servicesToConnect.put(thisServiceId, thisService); } } @@ -1253,7 +1253,7 @@ private static void combineSimilarJobs(Scenario scenario) { CarrierService.Builder builder = CarrierService.Builder .newInstance(idNewService, baseService.getServiceLinkId()) .setServiceDuration(serviceTimeService); - CarrierService newService = builder.setServiceStartingTimeWindow(baseService.getServiceStartTimeWindow()) + CarrierService newService = builder.setServiceStartingTimeWindow(baseService.getServiceStaringTimeWindow()) .setCapacityDemand(demandForThisLink).build(); servicesToAdd.add(newService); } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 1e497091ba8..16b5c1ef9ed 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -478,18 +478,18 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt countDemand = countDemand + service.getCapacityDemand(); if (service.getCapacityDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStaringTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else if (service.getCapacityDemand() == 1) { Assertions.assertEquals(100, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStaringTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else { if (service.getCapacityDemand() == 2) { Assertions.assertEquals(200, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStaringTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else @@ -587,12 +587,12 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ countDemand = countDemand + service.getCapacityDemand(); if (service.getCapacityDemand() == 0) { Assertions.assertEquals(180, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(3000, 13000), service.getServiceStaringTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement1", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } else { Assertions.assertEquals(service.getCapacityDemand() * 100, service.getServiceDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStartTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(5000, 20000), service.getServiceStaringTimeWindow()); locationsPerServiceElement.computeIfAbsent("serviceElement2", (k) -> new HashSet<>()) .add(service.getServiceLinkId().toString()); } diff --git a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ScoreCommercialJobs.java b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ScoreCommercialJobs.java index c3a6a068701..f9859468f93 100644 --- a/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ScoreCommercialJobs.java +++ b/contribs/commercialTrafficApplications/src/main/java/org/matsim/contrib/commercialTrafficApplications/jointDemand/ScoreCommercialJobs.java @@ -112,9 +112,9 @@ private void handleFreightActivityStart(ActivityStartEvent event) { } private double calcDifference(CarrierService service, double time) { - if (time < service.getServiceStartTimeWindow().getStart()) return (service.getServiceStartTimeWindow().getStart() - time); - else if (time >= service.getServiceStartTimeWindow().getStart() && time <= service.getServiceStartTimeWindow().getEnd()) return 0; - else return (time - service.getServiceStartTimeWindow().getEnd()); + if (time < service.getServiceStaringTimeWindow().getStart()) return (service.getServiceStaringTimeWindow().getStart() - time); + else if (time >= service.getServiceStaringTimeWindow().getStart() && time <= service.getServiceStaringTimeWindow().getEnd()) return 0; + else return (time - service.getServiceStaringTimeWindow().getEnd()); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 312f47a212d..082e71972a4 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -192,8 +192,8 @@ private void writeService(CarrierService s, boolean closeElement, boolean lineBr createTuple(ID, s.getId().toString()), createTuple(TO, s.getServiceLinkId().toString()), createTuple(CAPACITY_DEMAND, s.getCapacityDemand()), - createTuple(EARLIEST_START, getTime(s.getServiceStartTimeWindow().getStart())), - createTuple(LATEST_END, getTime(s.getServiceStartTimeWindow().getEnd())), + createTuple(EARLIEST_START, getTime(s.getServiceStaringTimeWindow().getStart())), + createTuple(LATEST_END, getTime(s.getServiceStaringTimeWindow().getEnd())), createTuple(SERVICE_DURATION, getTime(s.getServiceDuration()))), closeElement, lineBreak ); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 7e2d84d9d89..4cb3ade8972 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -37,7 +37,7 @@ public static class Builder { //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id serviceLinkId; - private TimeWindow serviceStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private TimeWindow serviceStartingTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double serviceDuration = 0.0; @@ -92,13 +92,13 @@ public CarrierService build(){ * When not set, it is by default [0.0., Integer.MAX_VALUE]. *

* Note that the time-window restricts the start-time of the service (i.e. serviceActivity). If one works with hard time-windows (which means that - * time-windows must be met) than the service is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * time-windows must be met) than the service is allowed to start between startingTimeWindow.getStart() and startingTimeWindow.getEnd(). * - * @param startTimeWindow time-window for the beginning of the service activity + * @param startingTimeWindow time-window for the beginning of the service activity * @return the builder */ - public Builder setServiceStartingTimeWindow(TimeWindow startTimeWindow){ - this.serviceStartsTimeWindow = startTimeWindow; + public Builder setServiceStartingTimeWindow(TimeWindow startingTimeWindow){ + this.serviceStartingTimeWindow = startingTimeWindow; return this; } @@ -157,7 +157,7 @@ public Builder setCapacityDemand(int capacityDemand) { //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id serviceLinkId; - private final TimeWindow serviceStartsTimeWindow; + private final TimeWindow serviceStartingTimeWindow; private final double serviceDuration; private final Attributes attributes = new AttributesImpl(); @@ -166,7 +166,7 @@ private CarrierService(Builder builder){ id = builder.id; serviceLinkId = builder.serviceLinkId; serviceDuration = builder.serviceDuration; - serviceStartsTimeWindow = builder.serviceStartsTimeWindow; + serviceStartingTimeWindow = builder.serviceStartingTimeWindow; capacityDemand = builder.capacityDemand; } @@ -191,8 +191,16 @@ public double getServiceDuration() { return serviceDuration; } + public TimeWindow getServiceStaringTimeWindow(){ + return serviceStartingTimeWindow; + } + + /** + * @deprecated please use {@link #getServiceStaringTimeWindow()} instead + */ + @Deprecated(since = "jan'25") public TimeWindow getServiceStartTimeWindow(){ - return serviceStartsTimeWindow; + return getServiceStaringTimeWindow(); } /** @@ -212,7 +220,7 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + capacityDemand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartsTimeWindow + "]"; + return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + capacityDemand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartingTimeWindow + "]"; } /* (non-Javadoc) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index 319c2753b01..e9bba751535 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -435,9 +435,9 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri .setDeliveryDuration(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we // have now time for that. Maybe change it later, kmt sep18 - .setDeliveryStartsTimeWindow(carrierService.getServiceStartTimeWindow()) + .setDeliveryStartsTimeWindow(carrierService.getServiceStaringTimeWindow()) // Limited to end of delivery timeWindow (pickup later than the latest delivery is not useful). - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStartTimeWindow().getEnd())) + .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStaringTimeWindow().getEnd())) .build(); addShipment(carrierWS, carrierShipment); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java index fec5bc60655..17225c33b7e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java @@ -389,7 +389,7 @@ public double getDuration() { @Override public TimeWindow getTimeWindow() { - return service.getServiceStartTimeWindow(); + return service.getServiceStaringTimeWindow(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index 97a94d8b6ad..efc47e09daa 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -169,8 +169,8 @@ static Service createJspritService(CarrierService carrierService, Coord location serviceBuilder.addSizeDimension(0, carrierService.getCapacityDemand()); serviceBuilder.setLocation(location).setServiceTime(carrierService.getServiceDuration()) .setTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( - carrierService.getServiceStartTimeWindow().getStart(), - carrierService.getServiceStartTimeWindow().getEnd())); + carrierService.getServiceStaringTimeWindow().getStart(), + carrierService.getServiceStaringTimeWindow().getEnd())); for (String skill : CarriersUtils.getSkills(carrierService)) { serviceBuilder.addRequiredSkill(skill); } 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 a194df63983..5ab577a22fd 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 @@ -149,7 +149,7 @@ void whenTransforming_jspritService2matsimService_isMadeCorrectly() { assertEquals("locationId", service.getServiceLinkId().toString()); assertEquals(30.0, service.getServiceDuration(), 0.01); assertEquals(50, service.getCapacityDemand()); - assertEquals(10.0, service.getServiceStartTimeWindow().getStart(), 0.01); + assertEquals(10.0, service.getServiceStaringTimeWindow().getStart(), 0.01); CarrierService service2 = MatsimJspritFactory.createCarrierService(carrierService); assertNotSame(service, service2); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 6b2d687682a..3e2a27775d9 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -199,8 +199,8 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -214,8 +214,8 @@ public void testCollectionLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index 3bd4a739ab3..e6b5428c2dd 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -487,8 +487,8 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -505,8 +505,8 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -523,8 +523,8 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -541,8 +541,8 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -559,8 +559,8 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(9).getLogisticChainElement()); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(10).getLogisticChainElement()); @@ -577,8 +577,8 @@ public void testCompletedLSPScheduling() { assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(9).getLogisticChainElement()); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(10).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 79c1f837d8c..712dd3d7d18 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -286,8 +286,8 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -299,8 +299,8 @@ public void testFirstReloadLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index f02cceaf33e..25fed36527b 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -353,8 +353,8 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -371,8 +371,8 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -389,8 +389,8 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -407,8 +407,8 @@ public void testMainRunLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index f4b4da0cc44..674faadfbba 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -201,8 +201,8 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -214,8 +214,8 @@ public void testCollectionLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), collectionLSP.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index f4551bd70b9..45f4601950d 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -490,8 +490,8 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -508,8 +508,8 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -526,8 +526,8 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -544,8 +544,8 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -562,8 +562,8 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(lspTourStartEventHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, lspTourStartEventHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, lspTourStartEventHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(9).getLogisticChainElement()); assertSame(lspTourStartEventHandler.getLogisticChainElement(), planElements.get(10).getLogisticChainElement()); @@ -580,8 +580,8 @@ public void testCompletedLSPScheduling() { assertSame(distributionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(distributionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, distributionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, distributionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(8).getLogisticChainElement()); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(9).getLogisticChainElement()); assertSame(distributionServiceHandler.getLogisticChainElement(), planElements.get(10).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index b107d0f4acb..042a4ba6b86 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -285,8 +285,8 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(endHandler.getLspShipment(), shipment); @@ -298,8 +298,8 @@ public void testFirstReloadLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index 9810f9f0d18..e3293655b22 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -353,8 +353,8 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(endHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(endHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -371,8 +371,8 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(serviceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(serviceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -389,8 +389,8 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -407,8 +407,8 @@ public void testMainRunLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 44d2a92c239..794e6c2d063 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -433,8 +433,8 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -452,8 +452,8 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -471,8 +471,8 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -490,8 +490,8 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); diff --git a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index 7ee63e8b74c..ca5b0b6f90e 100644 --- a/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/contribs/freight/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -440,8 +440,8 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(collectionEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); @@ -459,8 +459,8 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getCarrierService().getServiceLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); - assertEquals(collectionServiceHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), shipment.getPickupTimeWindow().getStart(), 0.0); + assertEquals(collectionServiceHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), shipment.getPickupTimeWindow().getEnd(), 0.0); assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); @@ -478,8 +478,8 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunStartHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunStartHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); @@ -497,8 +497,8 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunEndHandler.getCarrierService().getServiceLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); - assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getStart(), 0.0); - assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStartTimeWindow().getEnd(), 0.0); + assertEquals(0, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getStart(), 0.0); + assertEquals(Integer.MAX_VALUE, mainRunEndHandler.getCarrierService().getServiceStaringTimeWindow().getEnd(), 0.0); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(4).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(5).getLogisticChainElement()); assertSame(mainRunEndHandler.getLogisticChainElement(), planElements.get(6).getLogisticChainElement()); diff --git a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java index 29aa63e994b..abc241a35b9 100644 --- a/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java +++ b/contribs/small-scale-traffic-generation/src/main/java/org/matsim/smallScaleCommercialTrafficGeneration/DefaultUnhandledServicesSolution.java @@ -39,7 +39,7 @@ private void redrawAllServiceDurations(Carrier carrier, GenerateSmallScaleCommer double newServiceDuration = generator.getServiceTimePerStop(carrier, carrierAttributes, additionalTravelBufferPerIterationInMinutes); CarrierService.Builder builder = CarrierService.Builder.newInstance(service.getId(), service.getServiceLinkId()) .setServiceDuration(newServiceDuration); - CarrierService redrawnService = builder.setServiceStartingTimeWindow(service.getServiceStartTimeWindow()).build(); + CarrierService redrawnService = builder.setServiceStartingTimeWindow(service.getServiceStaringTimeWindow()).build(); carrier.getServices().put(redrawnService.getId(), redrawnService); } } diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java index b0e668fdc2f..2f22abe9ddc 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisServiceTracking.java @@ -61,7 +61,7 @@ public void trackServiceActivityStart(ActivityStartEvent activityStartEvent) { if (service.driverId == null) { // if there is no driver, but there is a service which is to be performed at the moment at this place, we guess this could be the event for it. // (Does not work well obviously as soon as there are multiple services at a location that have generous time windows, like e.g. at stores). - if (service.service.getServiceStartTimeWindow().getStart() <= activityStartEvent.getTime() && activityStartEvent.getTime() <= service.service.getServiceStartTimeWindow().getEnd()) { + if (service.service.getServiceStaringTimeWindow().getStart() <= activityStartEvent.getTime() && activityStartEvent.getTime() <= service.service.getServiceStaringTimeWindow().getEnd()) { service.driverIdGuess = activityStartEvent.getPersonId(); service.arrivalTimeGuess = activityStartEvent.getTime(); } From ec4539782e3bb29e4b88fbf7edc7d592dfa0b35f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 23:00:46 +0100 Subject: [PATCH 10/13] rename ...StartTimeWindow to ...StartingTimeWindow; keep old setter as deprecated to avoid code breaking --- .../DemandReaderFromCSV.java | 12 +-- .../DemandReaderFromCSVTest.java | 36 +++---- .../freight/carriers/CarrierPlanReaderV1.java | 6 +- .../carriers/CarrierPlanXmlParserV2.java | 4 +- .../carriers/CarrierPlanXmlParserV2_1.java | 4 +- .../carriers/CarrierPlanXmlWriterV2_1.java | 8 +- .../freight/carriers/CarrierShipment.java | 96 ++++++++++++++----- .../freight/carriers/CarriersUtils.java | 4 +- .../org/matsim/freight/carriers/Tour.java | 4 +- .../carriers/jsprit/MatsimJspritFactory.java | 20 ++-- .../multipleChains/MultipleChainsUtils.java | 4 +- .../jsprit/DistanceConstraintTest.java | 4 +- .../jsprit/MatsimTransformerTest.java | 16 ++-- .../freight/carriers/jsprit/SkillsIT.java | 16 ++-- .../utils/CarrierControllerUtilsIT.java | 4 +- .../utils/CarrierControllerUtilsTest.java | 36 +++---- ...iverTriggersCarrierReplanningListener.java | 2 +- .../ReceiverChessboardScenario.java | 2 +- .../FreightAnalysisShipmentTracking.java | 8 +- 19 files changed, 168 insertions(+), 118 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index ca6498d9ca1..fa01b29fc30 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -1051,8 +1051,8 @@ private static void createSingleShipment(Scenario scenario, DemandInformationEle CarrierShipment thisShipment = CarrierShipment.Builder .newInstance(idNewShipment, linkPickup.getId(), linkDelivery.getId(), singleDemandForThisLink) - .setPickupDuration(serviceTimePickup).setPickupStartsTimeWindow(timeWindowPickup) - .setDeliveryDuration(serviceTimeDelivery).setDeliveryStartsTimeWindow(timeWindowDelivery) + .setPickupDuration(serviceTimePickup).setPickupStartingTimeWindow(timeWindowPickup) + .setDeliveryDuration(serviceTimeDelivery).setDeliveryStartingTimeWindow(timeWindowDelivery) .build(); thisCarrier.getShipments().put(thisShipment.getId(), thisShipment); if (demandForThisLink == 0) @@ -1190,8 +1190,8 @@ private static void combineSimilarJobs(Scenario scenario) { if (baseShipment.getId() != thisShipment.getId() && baseShipment.getPickupLinkId() == thisShipment.getPickupLinkId() && baseShipment.getDeliveryLinkId() == thisShipment.getDeliveryLinkId()) { - if (baseShipment.getPickupStartsTimeWindow() == thisShipment.getPickupStartsTimeWindow()) { - if (baseShipment.getDeliveryStartsTimeWindow() == thisShipment.getDeliveryStartsTimeWindow()) shipmentsToConnect.put(thisShipmentId, thisShipment); + if (baseShipment.getPickupStartingTimeWindow() == thisShipment.getPickupStartingTimeWindow()) { + if (baseShipment.getDeliveryStartingTimeWindow() == thisShipment.getDeliveryStartingTimeWindow()) shipmentsToConnect.put(thisShipmentId, thisShipment); } } } @@ -1209,9 +1209,9 @@ private static void combineSimilarJobs(Scenario scenario) { CarrierShipment newShipment = CarrierShipment.Builder .newInstance(idNewShipment, baseShipment.getPickupLinkId(), baseShipment.getDeliveryLinkId(), demandForThisLink) .setPickupDuration(serviceTimePickup) - .setPickupStartsTimeWindow(baseShipment.getPickupStartsTimeWindow()) + .setPickupStartingTimeWindow(baseShipment.getPickupStartingTimeWindow()) .setDeliveryDuration(serviceTimeDelivery) - .setDeliveryStartsTimeWindow(baseShipment.getDeliveryStartsTimeWindow()).build(); + .setDeliveryStartingTimeWindow(baseShipment.getDeliveryStartingTimeWindow()).build(); shipmentsToAdd.add(newShipment); } } diff --git a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java index 16b5c1ef9ed..794cf772c9e 100644 --- a/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java +++ b/contribs/application/src/test/java/org/matsim/freightDemandGeneration/DemandReaderFromCSVTest.java @@ -106,8 +106,8 @@ void demandCreationWithSampleWithChangeNumberOfLocations() throws IOException { Assertions.assertEquals(5, shipment.getCapacityDemand()); Assertions.assertEquals(2000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(1250, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -173,8 +173,8 @@ void demandCreationWithSampleWithDemandOnLocation() throws IOException { Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -240,8 +240,8 @@ void demandCreationWithSampleWithDemandOnLocationWithCombiningJobs() throws IOEx Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -310,8 +310,8 @@ void demandCreationNoSampling() throws IOException { Assertions.assertEquals(10, shipment.getCapacityDemand()); Assertions.assertEquals(4000, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(2500, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(8000, 50000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 60000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -527,8 +527,8 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt if (shipment.getCapacityDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -536,8 +536,8 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt } else if (shipment.getCapacityDemand() == 2) { Assertions.assertEquals(400, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(400, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) @@ -546,8 +546,8 @@ private static void checkCarrier1and2(Scenario scenario, Network network, ShpOpt if (shipment.getCapacityDemand() == 3) { Assertions.assertEquals(600, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(600, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) @@ -626,8 +626,8 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ if (shipment.getCapacityDemand() == 0) { Assertions.assertEquals(300, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(350, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(10000, 45000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement1_delivery", (k) -> new HashSet<>()) @@ -635,8 +635,8 @@ private static void checkCarrier1and2WithCombiningJobs(Scenario scenario, Networ } else { Assertions.assertEquals(shipment.getCapacityDemand() * 200, shipment.getPickupDuration(), MatsimTestUtils.EPSILON); Assertions.assertEquals(shipment.getCapacityDemand() * 200, shipment.getDeliveryDuration(), MatsimTestUtils.EPSILON); - Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartsTimeWindow()); - Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartsTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(11000, 44000), shipment.getPickupStartingTimeWindow()); + Assertions.assertEquals(TimeWindow.newInstance(20000, 40000), shipment.getDeliveryStartingTimeWindow()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_pickup", (k) -> new HashSet<>()) .add(shipment.getPickupLinkId().toString()); locationsPerShipmentElement.computeIfAbsent("ShipmentElement2_delivery", (k) -> new HashSet<>()) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java index c22b5928899..278e428ea33 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanReaderV1.java @@ -116,11 +116,11 @@ public void startTag(String name, Attributes attributes, Stack context) CarrierShipment.Builder shipmentBuilder = CarrierShipment.Builder.newInstance( Id.create( id, CarrierShipment.class ), Id.create( from, Link.class ), Id.create( to, Link.class ), size ); if( startPickup == null ){ - shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryStartsTimeWindow( + shipmentBuilder.setPickupStartingTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ).setDeliveryStartingTimeWindow( TimeWindow.newInstance( 0.0, Integer.MAX_VALUE ) ); } else{ - shipmentBuilder.setPickupStartsTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ). - setDeliveryStartsTimeWindow( + shipmentBuilder.setPickupStartingTimeWindow( TimeWindow.newInstance( getDouble( startPickup ), getDouble( endPickup ) ) ). + setDeliveryStartingTimeWindow( TimeWindow.newInstance( getDouble( startDelivery ), diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java index 892ca375861..b08846ed47e 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2.java @@ -157,9 +157,9 @@ public void startTag(String name, Attributes atts, Stack context) { String deliveryServiceTime = atts.getValue("deliveryServiceTime"); if (startPickup != null && endPickup != null) - shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); + shipmentBuilder.setPickupStartingTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); if (startDelivery != null && endDelivery != null) - shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); + shipmentBuilder.setDeliveryStartingTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); if (pickupServiceTime != null) shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime)); if (deliveryServiceTime != null) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java index ab989b4c31a..68a9d0a6a99 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlParserV2_1.java @@ -155,9 +155,9 @@ public void startTag(String name, Attributes atts, Stack context) { String deliveryServiceTime = atts.getValue("deliveryServiceTime"); if (startPickup != null && endPickup != null) - shipmentBuilder.setPickupStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); + shipmentBuilder.setPickupStartingTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startPickup), parseTimeToDouble(endPickup))); if (startDelivery != null && endDelivery != null) - shipmentBuilder.setDeliveryStartsTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); + shipmentBuilder.setDeliveryStartingTimeWindow(TimeWindow.newInstance(parseTimeToDouble(startDelivery), parseTimeToDouble(endDelivery))); if (pickupServiceTime != null) shipmentBuilder.setPickupDuration(parseTimeToDouble(pickupServiceTime)); if (deliveryServiceTime != null) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java index 082e71972a4..be1ce74c560 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierPlanXmlWriterV2_1.java @@ -162,10 +162,10 @@ private void writeShipment(CarrierShipment s, Id shipmentId, bo createTuple(FROM, s.getPickupLinkId().toString()), createTuple(TO, s.getDeliveryLinkId().toString()), createTuple(SIZE, s.getCapacityDemand()), - createTuple(START_PICKUP, getTime(s.getPickupStartsTimeWindow().getStart())), - createTuple(END_PICKUP, getTime(s.getPickupStartsTimeWindow().getEnd())), - createTuple(START_DELIVERY, getTime(s.getDeliveryStartsTimeWindow().getStart())), - createTuple(END_DELIVERY, getTime(s.getDeliveryStartsTimeWindow().getEnd())), + createTuple(START_PICKUP, getTime(s.getPickupStartingTimeWindow().getStart())), + createTuple(END_PICKUP, getTime(s.getPickupStartingTimeWindow().getEnd())), + createTuple(START_DELIVERY, getTime(s.getDeliveryStartingTimeWindow().getStart())), + createTuple(END_DELIVERY, getTime(s.getDeliveryStartingTimeWindow().getEnd())), createTuple(PICKUP_SERVICE_TIME, getTime(s.getPickupDuration())), createTuple(DELIVERY_SERVICE_TIME, getTime(s.getDeliveryDuration()))), closeElement, lineBreak ); diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index b42637da366..879db720c22 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -52,14 +52,14 @@ public static class Builder { //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id pickupLinkId; - private TimeWindow pickupStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private TimeWindow pickupStartingTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double pickupDuration = 0.0; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id deliveryLinkId; - private TimeWindow deliveryStartsTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); + private TimeWindow deliveryStartingTimeWindow = TimeWindow.newInstance(0.0, Integer.MAX_VALUE); private double deliveryDuration = 0.0; /** @@ -93,14 +93,31 @@ private Builder(Id id, Id pickupLinkId, Id delivery * Note that the time-window restricts the start-time of the shipment's pickup . If one works with hard time-windows (which means that * time-windows must be met) than the pickup is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). * - * @param pickupStartsTimeWindow time-window for the beginning of the pickup activity + * @param pickupStartingTimeWindow time-window for the beginning of the pickup activity * @return the builder */ - public Builder setPickupStartsTimeWindow(TimeWindow pickupStartsTimeWindow){ - this.pickupStartsTimeWindow = pickupStartsTimeWindow; + public Builder setPickupStartingTimeWindow(TimeWindow pickupStartingTimeWindow){ + this.pickupStartingTimeWindow = pickupStartingTimeWindow; return this; } + /** + * Sets a time-window for the beginning of the pickup + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's pickup . If one works with hard time-windows (which means that + * time-windows must be met) than the pickup is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @deprecated since jan'25, use {@link #setPickupStartingTimeWindow(TimeWindow)} instead + * + * @param pickupStartingTimeWindow time-window for the beginning of the pickup activity + * @return the builder + */ + @Deprecated(since = "jan'25") + public Builder setPickupStartsTimeWindow(TimeWindow pickupStartingTimeWindow){ + return setPickupStartingTimeWindow(pickupStartingTimeWindow); + } + /** * Sets the duration for the pickup activity. * When not set, it is by default 0.0. @@ -120,14 +137,31 @@ public Builder setPickupDuration(double pickupDuration){ * Note that the time-window restricts the start-time of the shipment's delivery . If one works with hard time-windows (which means that * time-windows must be met) than the delivery is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). * - * @param deliveryStartsTimeWindow time-window for the beginning of the delivery activity + * @param deliveryStartingTimeWindow time-window for the beginning of the delivery activity * @return the builder */ - public Builder setDeliveryStartsTimeWindow(TimeWindow deliveryStartsTimeWindow){ - this.deliveryStartsTimeWindow = deliveryStartsTimeWindow; + public Builder setDeliveryStartingTimeWindow(TimeWindow deliveryStartingTimeWindow){ + this.deliveryStartingTimeWindow = deliveryStartingTimeWindow; return this; } + /** + * Sets a time-window for the beginning of the delivery + * When not set, it is by default [0.0., Integer.MAX_VALUE]. + *

+ * Note that the time-window restricts the start-time of the shipment's delivery . If one works with hard time-windows (which means that + * time-windows must be met) than the delivery is allowed to start between startTimeWindow.getStart() and startTimeWindow.getEnd(). + * + * @deprecated since jan'25, use {@link #setDeliveryStartingTimeWindow(TimeWindow)} instead + * + * @param deliveryStartingTimeWindow time-window for the beginning of the delivery activity + * @return the builder + */ + @Deprecated(since = "jan'25") + public Builder setDeliveryStartsTimeWindow(TimeWindow deliveryStartingTimeWindow){ + return setDeliveryStartingTimeWindow(deliveryStartingTimeWindow); + } + /** * Sets the duration for the delivery activity. * When not set, it is by default 0.0. @@ -148,11 +182,11 @@ public CarrierShipment build(){ /** - * @deprecated please inline and use {@link #setPickupStartsTimeWindow(TimeWindow)} instead + * @deprecated please inline and use {@link #setPickupStartingTimeWindow(TimeWindow)} instead */ @Deprecated(since = "dec'24") public Builder setPickupTimeWindow(TimeWindow pickupTW){ - return setPickupStartsTimeWindow(pickupTW); + return setPickupStartingTimeWindow(pickupTW); } /** @@ -164,11 +198,11 @@ public Builder setPickupServiceTime(double pickupServiceTime){ } /** - * @deprecated please inline and use {@link #setDeliveryStartsTimeWindow(TimeWindow)} instead + * @deprecated please inline and use {@link #setDeliveryStartingTimeWindow(TimeWindow)} instead */ @Deprecated(since = "dec'24") public Builder setDeliveryTimeWindow(TimeWindow deliveryTW){ - return setDeliveryStartsTimeWindow(deliveryTW); + return setDeliveryStartingTimeWindow(deliveryTW); } /** @@ -187,14 +221,14 @@ public Builder setDeliveryServiceTime(double deliveryServiceTime){ //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id pickupLinkId; - private final TimeWindow pickupStartsTimeWindow; + private final TimeWindow pickupStartingTimeWindow; private double pickupDuration; //IMO we could build a general class (CarrierActivity ???), containing the location, StartTimeWindow and Duration. //This could be used for both, CarrierService and CarrierShipment (Pickup and Delivery). //kturner dec'24 private final Id deliveryLinkId; - private final TimeWindow deliveryStartsTimeWindow; + private final TimeWindow deliveryStartingTimeWindow; private double deliveryDuration; private final Attributes attributes = new AttributesImpl(); @@ -207,8 +241,8 @@ private CarrierShipment(Builder builder) { capacityDemand = builder.capacityDemand; pickupDuration = builder.pickupDuration; deliveryDuration = builder.deliveryDuration; - pickupStartsTimeWindow = builder.pickupStartsTimeWindow; - deliveryStartsTimeWindow = builder.deliveryStartsTimeWindow; + pickupStartingTimeWindow = builder.pickupStartingTimeWindow; + deliveryStartingTimeWindow = builder.deliveryStartingTimeWindow; } //* getters and setters @@ -264,12 +298,28 @@ public int getCapacityDemand() { return capacityDemand; } + public TimeWindow getPickupStartingTimeWindow() { + return pickupStartingTimeWindow; + } + + /** + * @deprecated since jan'25, use {@link #getPickupStartingTimeWindow()} instead + */ + @Deprecated(since = "jan'25") public TimeWindow getPickupStartsTimeWindow() { - return pickupStartsTimeWindow; + return getPickupStartingTimeWindow(); } + public TimeWindow getDeliveryStartingTimeWindow() { + return deliveryStartingTimeWindow; + } + + /** + * @deprecated since jan'25, use {@link #getDeliveryStartingTimeWindow()} instead + */ + @Deprecated(since = "jan'25") public TimeWindow getDeliveryStartsTimeWindow() { - return deliveryStartsTimeWindow; + return getDeliveryStartingTimeWindow(); } @Override @@ -297,11 +347,11 @@ public Id getFrom() { } /** - * @deprecated please inline and use {@link #getPickupStartsTimeWindow()} instead + * @deprecated please inline and use {@link #getPickupStartingTimeWindow()} instead */ @Deprecated(since = "dec'24") public TimeWindow getPickupTimeWindow() { - return getPickupStartsTimeWindow(); + return getPickupStartingTimeWindow(); } /** @@ -330,11 +380,11 @@ public Id getTo() { } /** - * @deprecated please inline and use {@link #getDeliveryStartsTimeWindow()} instead + * @deprecated please inline and use {@link #getDeliveryStartingTimeWindow()} instead */ @Deprecated(since = "dec'24") public TimeWindow getDeliveryTimeWindow() { - return getDeliveryStartsTimeWindow(); + return getDeliveryStartingTimeWindow(); } /** @@ -358,7 +408,7 @@ public void setDeliveryServiceTime(double deliveryDuration) { @Override public String toString() { return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + capacityDemand + "][pickupServiceTime=" + pickupDuration + "]" + - "[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartsTimeWindow +"][deliveryTimeWindow="+ deliveryStartsTimeWindow +"]"; + "[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartingTimeWindow +"][deliveryTimeWindow="+ deliveryStartingTimeWindow +"]"; } /* (non-Javadoc) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java index e9bba751535..c4d981f7073 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarriersUtils.java @@ -435,9 +435,9 @@ private static void createShipmentsFromServices(Carrier carrierWS, Carrier carri .setDeliveryDuration(carrierService.getServiceDuration()) // .setPickupServiceTime(pickupServiceTime) //Not set yet, because in service we // have now time for that. Maybe change it later, kmt sep18 - .setDeliveryStartsTimeWindow(carrierService.getServiceStaringTimeWindow()) + .setDeliveryStartingTimeWindow(carrierService.getServiceStaringTimeWindow()) // Limited to end of delivery timeWindow (pickup later than the latest delivery is not useful). - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStaringTimeWindow().getEnd())) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, carrierService.getServiceStaringTimeWindow().getEnd())) .build(); addShipment(carrierWS, carrierShipment); } diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java index 17225c33b7e..6898ac6bcb1 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/Tour.java @@ -539,7 +539,7 @@ public String getActivityType() { @Override public TimeWindow getTimeWindow() { - return shipment.getPickupStartsTimeWindow(); + return shipment.getPickupStartingTimeWindow(); } @Override @@ -592,7 +592,7 @@ public Delivery(CarrierShipment shipment) { @Override public TimeWindow getTimeWindow() { - return shipment.getDeliveryStartsTimeWindow(); + return shipment.getDeliveryStartingTimeWindow(); } @Override diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java index efc47e09daa..39a353c5300 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/jsprit/MatsimJspritFactory.java @@ -90,10 +90,10 @@ static CarrierShipment createCarrierShipment(Shipment jspritShipment) { Id.createLinkId(jspritShipment.getPickupLocation().getId()), Id.createLinkId(jspritShipment.getDeliveryLocation().getId()), jspritShipment.getSize().get(0)) .setDeliveryDuration(jspritShipment.getDeliveryServiceTime()) - .setDeliveryStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(), + .setDeliveryStartingTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getDeliveryTimeWindow().getStart(), jspritShipment.getDeliveryTimeWindow().getEnd())) .setPickupDuration(jspritShipment.getPickupServiceTime()) - .setPickupStartsTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(), + .setPickupStartingTimeWindow(org.matsim.freight.carriers.TimeWindow.newInstance(jspritShipment.getPickupTimeWindow().getStart(), jspritShipment.getPickupTimeWindow().getEnd())) .build(); CarriersUtils.setSkills(carrierShipment, jspritShipment.getRequiredSkills().values()); @@ -112,13 +112,13 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment) { .setDeliveryLocation(Location.newInstance(carrierShipment.getDeliveryLinkId().toString())) .setDeliveryServiceTime(carrierShipment.getDeliveryDuration()) .setDeliveryTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow - .newInstance(carrierShipment.getDeliveryStartsTimeWindow().getStart(), - carrierShipment.getDeliveryStartsTimeWindow().getEnd())) + .newInstance(carrierShipment.getDeliveryStartingTimeWindow().getStart(), + carrierShipment.getDeliveryStartingTimeWindow().getEnd())) .setPickupServiceTime(carrierShipment.getPickupDuration()) .setPickupLocation(Location.newInstance(carrierShipment.getPickupLinkId().toString())) .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( - carrierShipment.getPickupStartsTimeWindow().getStart(), - carrierShipment.getPickupStartsTimeWindow().getEnd())) + carrierShipment.getPickupStartingTimeWindow().getStart(), + carrierShipment.getPickupStartingTimeWindow().getEnd())) .addSizeDimension(0, carrierShipment.getCapacityDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); @@ -144,12 +144,12 @@ static Shipment createJspritShipment(CarrierShipment carrierShipment, Coord from Shipment.Builder shipmentBuilder = Shipment.Builder.newInstance(carrierShipment.getId().toString()) .setDeliveryLocation(toLocation).setDeliveryServiceTime(carrierShipment.getDeliveryDuration()) .setDeliveryTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow - .newInstance(carrierShipment.getDeliveryStartsTimeWindow().getStart(), - carrierShipment.getDeliveryStartsTimeWindow().getEnd())) + .newInstance(carrierShipment.getDeliveryStartingTimeWindow().getStart(), + carrierShipment.getDeliveryStartingTimeWindow().getEnd())) .setPickupServiceTime(carrierShipment.getPickupDuration()).setPickupLocation(fromLocation) .setPickupTimeWindow(com.graphhopper.jsprit.core.problem.solution.route.activity.TimeWindow.newInstance( - carrierShipment.getPickupStartsTimeWindow().getStart(), - carrierShipment.getPickupStartsTimeWindow().getEnd())) + carrierShipment.getPickupStartingTimeWindow().getStart(), + carrierShipment.getPickupStartingTimeWindow().getEnd())) .addSizeDimension(0, carrierShipment.getCapacityDemand()); for (String skill : CarriersUtils.getSkills(carrierShipment)) { shipmentBuilder.addRequiredSkill(skill); diff --git a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java index a7f33bfd794..3c316efb667 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java +++ b/contribs/freight/src/main/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsUtils.java @@ -62,8 +62,8 @@ public static Collection createLSPShipmentsFromCarrierShipments(Car builder.setCapacityDemand(shipment.getCapacityDemand()); builder.setFromLinkId(shipment.getPickupLinkId()); builder.setToLinkId(shipment.getDeliveryLinkId()); - builder.setStartTimeWindow(shipment.getPickupStartsTimeWindow()); - builder.setEndTimeWindow(shipment.getDeliveryStartsTimeWindow()); + builder.setStartTimeWindow(shipment.getPickupStartingTimeWindow()); + builder.setEndTimeWindow(shipment.getDeliveryStartingTimeWindow()); builder.setPickupServiceTime(shipment.getPickupDuration()); builder.setDeliveryServiceTime(shipment.getDeliveryDuration()); shipmentList.add(builder.build()); 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 394e388e82d..53e22766987 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 @@ -633,14 +633,14 @@ private static Carrier addTwoShipmentsToCarrier(Carrier carrier) { // Shipment 1 CarrierShipment shipment1 = CarrierShipment.Builder .newInstance(Id.create("Shipment1", CarrierShipment.class), Id.createLinkId("i(1,8)"), Id.createLinkId("j(3,8)"), 40) - .setDeliveryDuration(20).setDeliveryStartsTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) + .setDeliveryDuration(20).setDeliveryStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) .build(); CarriersUtils.addShipment(carrier, shipment1); // Shipment 2 CarrierShipment shipment2 = CarrierShipment.Builder .newInstance(Id.create("Shipment2", CarrierShipment.class),Id.createLinkId("i(1,8)"), Id.createLinkId("j(0,3)R"), 40) - .setDeliveryDuration(20).setDeliveryStartsTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) + .setDeliveryDuration(20).setDeliveryStartingTimeWindow(TimeWindow.newInstance(8 * 3600, 12 * 3600)) .build(); CarriersUtils.addShipment(carrier, shipment2); 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 5ab577a22fd..125b0615180 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 @@ -161,8 +161,8 @@ void whenTransforming_matsimShipment2jspritShipment_isMadeCorrectly() { CarrierShipment carrierShipment = CarrierShipment.Builder .newInstance(Id.create("ShipmentId", CarrierShipment.class), Id.createLinkId("PickupLocationId"), Id.createLinkId("DeliveryLocationId"), 50) - .setPickupDuration(30.0).setPickupStartsTimeWindow(TimeWindow.newInstance(10.0, 20.0)) - .setDeliveryDuration(40.0).setDeliveryStartsTimeWindow(TimeWindow.newInstance(50.0, 60.0)).build(); + .setPickupDuration(30.0).setPickupStartingTimeWindow(TimeWindow.newInstance(10.0, 20.0)) + .setDeliveryDuration(40.0).setDeliveryStartingTimeWindow(TimeWindow.newInstance(50.0, 60.0)).build(); Shipment shipment = MatsimJspritFactory.createJspritShipment(carrierShipment); assertNotNull(shipment); assertEquals("PickupLocationId", shipment.getPickupLocation().getId()); @@ -195,12 +195,12 @@ void whenTransforming_jspritShipment2matsimShipment_isMadeCorrectly() { assertNotNull(carrierShipment); assertEquals("PickupLocationId", carrierShipment.getPickupLinkId().toString()); assertEquals(30.0, carrierShipment.getPickupDuration(), 0.01); - assertEquals(10.0, carrierShipment.getPickupStartsTimeWindow().getStart(), 0.01); - assertEquals(20.0, carrierShipment.getPickupStartsTimeWindow().getEnd(), 0.01); + assertEquals(10.0, carrierShipment.getPickupStartingTimeWindow().getStart(), 0.01); + assertEquals(20.0, carrierShipment.getPickupStartingTimeWindow().getEnd(), 0.01); assertEquals("DeliveryLocationId", carrierShipment.getDeliveryLinkId().toString()); assertEquals(40.0, carrierShipment.getDeliveryDuration(), 0.01); - assertEquals(50.0, carrierShipment.getDeliveryStartsTimeWindow().getStart(), 0.01); - assertEquals(60.0, carrierShipment.getDeliveryStartsTimeWindow().getEnd(), 0.01); + assertEquals(50.0, carrierShipment.getDeliveryStartingTimeWindow().getStart(), 0.01); + assertEquals(60.0, carrierShipment.getDeliveryStartingTimeWindow().getEnd(), 0.01); assertEquals(50, carrierShipment.getCapacityDemand()); CarrierShipment carrierShipment2 = MatsimJspritFactory.createCarrierShipment(shipment); @@ -391,8 +391,8 @@ private CarrierShipment getMatsimShipment(String id, String from, String to, int return CarrierShipment.Builder .newInstance(Id.create(id, CarrierShipment.class), Id.create(from, Link.class), Id.create(to, Link.class), size) - .setDeliveryDuration(30.0).setDeliveryStartsTimeWindow(TimeWindow.newInstance(10.0, 20.0)) - .setPickupDuration(15.0).setPickupStartsTimeWindow(TimeWindow.newInstance(1.0, 5.0)).build(); + .setDeliveryDuration(30.0).setDeliveryStartingTimeWindow(TimeWindow.newInstance(10.0, 20.0)) + .setPickupDuration(15.0).setPickupStartingTimeWindow(TimeWindow.newInstance(1.0, 5.0)).build(); } @Test 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 379fb15486c..a3445c990d9 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 @@ -161,9 +161,9 @@ private void addShipmentsRequiringDifferentSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setPickupDuration(Time.parseTime("00:05:00")) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentOne, "skill 1"); @@ -174,9 +174,9 @@ private void addShipmentsRequiringDifferentSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setPickupDuration(Time.parseTime("00:05:00")) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentTwo, "skill 2"); @@ -190,9 +190,9 @@ private void addShipmentsRequiringSameSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setPickupDuration(Time.parseTime("00:05:00")) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentOne, "skill 1"); @@ -203,9 +203,9 @@ private void addShipmentsRequiringSameSkills(Scenario scenario) { carrierLocation, Id.createLinkId("i(10,10)R"), 1) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setPickupDuration(Time.parseTime("00:05:00")) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(0.0, Time.parseTime("24:00:00"))) .setDeliveryDuration(Time.parseTime("00:05:00")) .build(); CarriersUtils.addSkill(shipmentTwo, "skill 1"); 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 4518470191a..76c2cf57a69 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 @@ -286,9 +286,9 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri return CarrierShipment.Builder.newInstance(shipmentId, fromLinkId, toLinkId, size) .setDeliveryDuration(30.0) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(0.0, 36000.0)) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(0.0, 36000.0)) .setPickupDuration(5.0) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) .build(); } 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 9cf70e22727..e380a033f8f 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 @@ -248,11 +248,11 @@ void copyingOfShipmentsIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(7,6)R"), carrierShipment1.getDeliveryLinkId()); Assertions.assertEquals(1, carrierShipment1.getCapacityDemand()); Assertions.assertEquals(30.0, carrierShipment1.getDeliveryDuration(), 0); - Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(3600.0, carrierShipment1.getDeliveryStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment1.getDeliveryStartingTimeWindow().getEnd(), 0); Assertions.assertEquals(5.0, carrierShipment1.getPickupDuration(), 0); - Assertions.assertEquals(0.0, carrierShipment1.getPickupStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(7200.0, carrierShipment1.getPickupStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment1.getPickupStartingTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWShipments, Id.create("shipment2", CarrierShipment.class)); assert carrierShipment2 != null; @@ -263,11 +263,11 @@ void copyingOfShipmentsIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(3,7)"), carrierShipment2.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment2.getCapacityDemand()); Assertions.assertEquals(30.0, carrierShipment2.getDeliveryDuration(), 0); - Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(3600.0, carrierShipment2.getDeliveryStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36000.0, carrierShipment2.getDeliveryStartingTimeWindow().getEnd(), 0); Assertions.assertEquals(5.0, carrierShipment2.getPickupDuration(), 0); - Assertions.assertEquals(0.0, carrierShipment2.getPickupStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(7200.0, carrierShipment2.getPickupStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(7200.0, carrierShipment2.getPickupStartingTimeWindow().getEnd(), 0); } Assertions.assertTrue(foundShipment1, "Not found Shipment1 after copying"); Assertions.assertTrue(foundShipment2, "Not found Shipment2 after copying"); @@ -286,11 +286,11 @@ void convertionOfServicesIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(3,9)"), carrierShipment1.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment1.getCapacityDemand()); Assertions.assertEquals(31.0, carrierShipment1.getDeliveryDuration(), 0); - Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(3601.0, carrierShipment1.getDeliveryStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getDeliveryStartingTimeWindow().getEnd(), 0); Assertions.assertEquals(0.0, carrierShipment1.getPickupDuration(), 0); - Assertions.assertEquals(0.0, carrierShipment1.getPickupStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment1.getPickupStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment1.getPickupStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment1.getPickupStartingTimeWindow().getEnd(), 0); } CarrierShipment carrierShipment2 = CarriersUtils.getShipment(carrierWShipmentsOnlyFromCarrierWServices, Id.create("Service2", CarrierShipment.class)); assert carrierShipment2 != null; @@ -300,11 +300,11 @@ void convertionOfServicesIsDoneCorrectly() { Assertions.assertEquals(Id.createLinkId("i(4,9)"), carrierShipment2.getDeliveryLinkId()); Assertions.assertEquals(2, carrierShipment2.getCapacityDemand()); Assertions.assertEquals(31.0, carrierShipment2.getDeliveryDuration(), 0); - Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(3601.0, carrierShipment2.getDeliveryStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getDeliveryStartingTimeWindow().getEnd(), 0); Assertions.assertEquals(0.0, carrierShipment2.getPickupDuration(), 0); - Assertions.assertEquals(0.0, carrierShipment2.getPickupStartsTimeWindow().getStart(), 0); - Assertions.assertEquals(36001.0, carrierShipment2.getPickupStartsTimeWindow().getEnd(), 0); + Assertions.assertEquals(0.0, carrierShipment2.getPickupStartingTimeWindow().getStart(), 0); + Assertions.assertEquals(36001.0, carrierShipment2.getPickupStartingTimeWindow().getEnd(), 0); } Assertions.assertTrue(foundService1, "Not found converted Service1 after converting"); Assertions.assertTrue(foundService2, "Not found converted Service2 after converting"); @@ -344,9 +344,9 @@ private static CarrierShipment createMatsimShipment(String id, String from, Stri return CarrierShipment.Builder.newInstance(shipmentId, fromLinkId, toLinkId, size) .setDeliveryDuration(30.0) - .setDeliveryStartsTimeWindow(TimeWindow.newInstance(3600.0, 36000.0)) + .setDeliveryStartingTimeWindow(TimeWindow.newInstance(3600.0, 36000.0)) .setPickupDuration(5.0) - .setPickupStartsTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) + .setPickupStartingTimeWindow(TimeWindow.newInstance(0.0, 7200.0)) .build(); } diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java index 9749c3b83fe..46e4e8efcbe 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/ReceiverTriggersCarrierReplanningListener.java @@ -82,7 +82,7 @@ public void notifyIterationStarts(IterationStartsEvent event) { (int) (Math.round(order.getDailyOrderQuantity()*order.getProduct().getProductType().getRequiredCapacity())) ); CarrierShipment newShipment = builder .setDeliveryDuration( order.getServiceDuration() ) - .setDeliveryStartsTimeWindow( receiverPlan.getTimeWindows().get( 0 ) ) + .setDeliveryStartingTimeWindow( receiverPlan.getTimeWindows().get( 0 ) ) // TODO This only looks at the FIRST time window. This may need revision once we handle multiple // time windows. .build(); diff --git a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java index 34b74c242d4..941af3c43a5 100644 --- a/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java +++ b/contribs/freightreceiver/src/main/java/org/matsim/freight/receiver/run/chessboard/ReceiverChessboardScenario.java @@ -229,7 +229,7 @@ public static void convertReceiverOrdersToInitialCarrierShipments(Carriers carri } CarrierShipment shipment = shpBuilder.setDeliveryDuration(order.getServiceDuration()) - .setDeliveryStartsTimeWindow(receiverPlan.getTimeWindows().get(0)) + .setDeliveryStartingTimeWindow(receiverPlan.getTimeWindows().get(0)) .build(); carriers.getCarriers().get(receiverOrder.getCarrierId()).getShipments().put(shipment.getId(), shipment); } diff --git a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java index 5673a46b530..d4493affd48 100644 --- a/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java +++ b/contribs/vsp/src/main/java/org/matsim/freight/carriers/analysis/FreightAnalysisShipmentTracking.java @@ -57,8 +57,8 @@ public void trackDeliveryActivity(ActivityStartEvent activityStartEvent) { for (ShipmentTracker shipment: shipments.values()){ if (shipment.to==activityStartEvent.getLinkId() ){ if(shipment.driverId == null){ - if(shipment.shipment.getDeliveryStartsTimeWindow().getStart() <= activityStartEvent.getTime()) { - if (activityStartEvent.getTime()<= shipment.shipment.getDeliveryStartsTimeWindow().getEnd()) { + if(shipment.shipment.getDeliveryStartingTimeWindow().getStart() <= activityStartEvent.getTime()) { + if (activityStartEvent.getTime()<= shipment.shipment.getDeliveryStartingTimeWindow().getEnd()) { if (shipment.possibleDrivers.contains(activityStartEvent.getPersonId().toString())) { shipment.driverIdGuess = activityStartEvent.getPersonId(); shipment.deliveryTimeGuess=activityStartEvent.getTime(); @@ -77,8 +77,8 @@ public void trackPickupActivity(ActivityStartEvent activityStartEvent) { for (ShipmentTracker shipmentTracker: shipments.values()){ if (shipmentTracker.from==activityStartEvent.getLinkId()){ if (shipmentTracker.driverId==null){ - if(shipmentTracker.shipment.getPickupStartsTimeWindow().getStart() <= activityStartEvent.getTime()) { - if (activityStartEvent.getTime()<= shipmentTracker.shipment.getPickupStartsTimeWindow().getEnd()) { + if(shipmentTracker.shipment.getPickupStartingTimeWindow().getStart() <= activityStartEvent.getTime()) { + if (activityStartEvent.getTime()<= shipmentTracker.shipment.getPickupStartingTimeWindow().getEnd()) { shipmentTracker.possibleDrivers.add(activityStartEvent.getPersonId().toString()); } } From 8e83d0901082ae41b7123a6d1177101ea273f82f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 13 Jan 2025 23:06:19 +0100 Subject: [PATCH 11/13] adapt toString() output accordingly --- .../main/java/org/matsim/freight/carriers/CarrierService.java | 2 +- .../java/org/matsim/freight/carriers/CarrierShipment.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java index 4cb3ade8972..c8491ab5fdd 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierService.java @@ -220,7 +220,7 @@ public Attributes getAttributes() { @Override public String toString() { - return "[id=" + id + "][locationId=" + serviceLinkId + "][capacityDemand=" + capacityDemand + "][serviceDuration=" + serviceDuration + "][startTimeWindow=" + serviceStartingTimeWindow + "]"; + return "[id=" + id + "][serviceLinkId=" + serviceLinkId + "][capacityDemand=" + capacityDemand + "][serviceDuration=" + serviceDuration + "][serviceStartingTimeWindow=" + serviceStartingTimeWindow + "]"; } /* (non-Javadoc) diff --git a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java index 879db720c22..4f2752b9b4f 100644 --- a/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java +++ b/contribs/freight/src/main/java/org/matsim/freight/carriers/CarrierShipment.java @@ -407,8 +407,8 @@ public void setDeliveryServiceTime(double deliveryDuration) { @Override public String toString() { - return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][from=" + pickupLinkId.toString() + "][to=" + deliveryLinkId.toString() + "][size=" + capacityDemand + "][pickupServiceTime=" + pickupDuration + "]" + - "[deliveryServiceTime="+ deliveryDuration +"][pickupTimeWindow="+ pickupStartingTimeWindow +"][deliveryTimeWindow="+ deliveryStartingTimeWindow +"]"; + return "[id= "+ id.toString() + "][hash=" + this.hashCode() + "][pickupLinkId=" + pickupLinkId.toString() + "][deliveryLinkId=" + deliveryLinkId.toString() + "][capacityDemand=" + capacityDemand + "][pickupDuration=" + pickupDuration + "]" + + "[deliveryDuration="+ deliveryDuration +"][pickupStartingTimeWindow="+ pickupStartingTimeWindow +"][deliveryStartingTimeWindow="+ deliveryStartingTimeWindow +"]"; } /* (non-Javadoc) From 03398892e64cc9fdd4ff72e8e469f30cefb13215 Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 14 Jan 2025 11:28:56 +0100 Subject: [PATCH 12/13] handle multiple detours on the same schedule correctly --- .../railsim/qsimengine/RailsimEngine.java | 4 +- .../qsimengine/RailsimTransitDriverAgent.java | 27 +++++++++++--- .../integration/RailsimIntegrationTest.java | 37 ++++++++++--------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngine.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngine.java index c31d0943003..973ee06ebec 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngine.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimEngine.java @@ -557,7 +557,9 @@ private double handleTransitStop(double time, TrainState state) { // Time needs to be rounded to current sim step double stopTime = state.pt.handleTransitStop(state.nextStop, Math.ceil(time)); - state.nextStop = state.pt.getNextTransitStop(); + // If stop time > 0, train has not yet departed + if (stopTime <= 0) + state.nextStop = state.pt.getNextTransitStop(); return stopTime; } diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimTransitDriverAgent.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimTransitDriverAgent.java index 8768ce90029..e63c301a05c 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimTransitDriverAgent.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/qsimengine/RailsimTransitDriverAgent.java @@ -43,7 +43,8 @@ public final class RailsimTransitDriverAgent extends TransitDriverAgentImpl { /** * Contains the original stop if it was overwritten by a detour. */ - private TransitStopFacility overwrittenStop; + private TransitStopFacility originalStop; + private TransitStopFacility detourStop; private final Map, List> stopAreas; @@ -59,7 +60,8 @@ public RailsimTransitDriverAgent(Map, List original, List detour) { - TransitStopFacility nextStop = getNextTransitStop(); + // The current next stop which may already be a detour + TransitStopFacility nextStop = detourStop != null ? detourStop : getNextTransitStop(); // Adjust the link index so that it fits to the new size // the original route inside this agent is not updated because it is currently not necessary @@ -87,7 +89,13 @@ public TransitStopFacility addDetour(List original, List det for (RailLink d : detour) { if (stop.getLinkId().equals(d.getLinkId())) { - this.overwrittenStop = nextStop; + + // Always contains the stop from original schedule + if (originalStop == null) { + this.originalStop = nextStop; + } + + this.detourStop = stop; return stop; } } @@ -106,10 +114,17 @@ public double handleTransitStop(TransitStopFacility stop, double now) { // This function will call the API with the original stop as if no reroute has happened // use the original stop exactly one time - if (overwrittenStop != null) { - stop = overwrittenStop; + if (originalStop != null) { + stop = originalStop; double t = super.handleTransitStop(stop, now); - overwrittenStop = null; + + // Vehicle has not yet departed and must wait, stops are not updated yet + if (t > 0) { + return t; + } + + originalStop = null; + detourStop = null; return t; } diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index 31f9571869b..be22a0c1d5a 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -332,8 +332,8 @@ void testMicroStationRerouting() { assertTrainState(30914, 0, 0, 0, 400, filterTrainEvents(collector, "train2")); // These arrive closer together, because both waited assertTrainState(30974, 0, 0, 0, 400, filterTrainEvents(collector, "train3")); - assertTrainState(30982, 0, 0, 0, 400, filterTrainEvents(collector, "train4")); - + assertTrainState(31034, 0, 0, 0, 400, filterTrainEvents(collector, "train4")); + // collect all arrivals and departures Map, List>> train2arrivalStops = new HashMap<>(); Map, List>> train2departureStops = new HashMap<>(); @@ -342,9 +342,9 @@ void testMicroStationRerouting() { if (event.getEventType().equals(VehicleArrivesAtFacilityEvent.EVENT_TYPE)) { VehicleArrivesAtFacilityEvent vehicleArrivesEvent = (VehicleArrivesAtFacilityEvent) event; - + if (train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()) == null) { - + List> stops = new ArrayList<>(); stops.add(vehicleArrivesEvent.getFacilityId()); train2arrivalStops.put(vehicleArrivesEvent.getVehicleId(), stops); @@ -352,13 +352,13 @@ void testMicroStationRerouting() { train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()).add(vehicleArrivesEvent.getFacilityId()); } } - + if (event.getEventType().equals(VehicleDepartsAtFacilityEvent.EVENT_TYPE)) { VehicleDepartsAtFacilityEvent vehicleDepartsEvent = (VehicleDepartsAtFacilityEvent) event; - + if (train2departureStops.get(vehicleDepartsEvent.getVehicleId()) == null) { - + List> stops = new ArrayList<>(); stops.add(vehicleDepartsEvent.getFacilityId()); train2departureStops.put(vehicleDepartsEvent.getVehicleId(), stops); @@ -367,7 +367,7 @@ void testMicroStationRerouting() { } } } - + // test if all trains have the correct number of arrivals and departures for (Id vehicleId : train2arrivalStops.keySet()) { Assertions.assertEquals(3, train2arrivalStops.get(vehicleId).size(), MatsimTestUtils.EPSILON, "Wrong number of arrival stops for train " + vehicleId); @@ -375,10 +375,13 @@ void testMicroStationRerouting() { for (Id vehicleId : train2departureStops.keySet()) { Assertions.assertEquals(3, train2departureStops.get(vehicleId).size(), MatsimTestUtils.EPSILON, "Wrong number of departure stops for train " + vehicleId); } - + // test if the trains have the correct arrival / departure stop facilities Assertions.assertEquals("AB", train2arrivalStops.get(Id.createVehicleId("train3")).get(0).toString(), "Wrong stop facility. This is the start stop facility."); - Assertions.assertEquals("CD", train2arrivalStops.get(Id.createVehicleId("train3")).get(1).toString(), "Wrong stop facility. This is the rerouted stop Id. Train 3 is rerouted from CE to CD."); + + // The original events don't contain the re-routing. They appear to other agents as if the train drove the original schedule. + Assertions.assertEquals("CE", train2arrivalStops.get(Id.createVehicleId("train3")).get(1).toString(), "Wrong stop facility. This is the rerouted stop Id. Train 3 is rerouted from CE to CD."); + Assertions.assertEquals("JK", train2arrivalStops.get(Id.createVehicleId("train3")).get(2).toString(), "Wrong stop facility. This is the final stop facility."); } @@ -407,7 +410,7 @@ void testMicroStationReroutingConcurrent() { EventsCollector collector = runSimulation(new File(utils.getPackageInputDirectory(), "microStationRerouting"), filter); } - + @Test void testMicroStationReroutingTwoDirections() { // modifyScheduleAndRunSimulation(new File(utils.getPackageInputDirectory(), "microStationReroutingTwoDirections"), 300, 1800); @@ -420,7 +423,7 @@ void testMicroStationReroutingTwoDirections() { 1800 ); }); - + try { future.get(30, TimeUnit.SECONDS); } catch (TimeoutException e) { @@ -531,14 +534,14 @@ public void install() { return collector; } - + private void modifyScheduleAndRunSimulation(File scenarioDir, int maxRndDelayStepSize, int maxMaxRndDelay) { Random rnd = MatsimRandom.getRandom(); rnd.setSeed(1242); for (double maxRndDelaySeconds = 0; maxRndDelaySeconds <= maxMaxRndDelay; maxRndDelaySeconds = maxRndDelaySeconds + maxRndDelayStepSize) { Config config = ConfigUtils.loadConfig(new File(scenarioDir, "config.xml").toString()); - + config.controller().setOutputDirectory(utils.getOutputDirectory() + "maxRndDelay_" + maxRndDelaySeconds); config.controller().setDumpDataAtEnd(true); config.controller().setCreateGraphs(false); @@ -549,7 +552,7 @@ private void modifyScheduleAndRunSimulation(File scenarioDir, int maxRndDelaySte Controler controler = new Controler(scenario); controler.addOverridingModule(new RailsimModule()); controler.configureQSimComponents(components -> new RailsimQSimModule().configure(components)); - + // modify scenario for (TransitLine line : scenario.getTransitSchedule().getTransitLines().values()) { for (TransitRoute route : line.getRoutes().values()) { @@ -562,7 +565,7 @@ private void modifyScheduleAndRunSimulation(File scenarioDir, int maxRndDelaySte modifiedDeparture.setVehicleId(departure.getVehicleId()); departuresToAdd.add(modifiedDeparture); } - + for (Departure departureToRemove : departuresToRemove) { route.removeDeparture(departureToRemove); } @@ -571,7 +574,7 @@ private void modifyScheduleAndRunSimulation(File scenarioDir, int maxRndDelaySte } } } - + controler.run(); } } From 7b38e6066a21d03f4d3657ba8d45da349b1f006f Mon Sep 17 00:00:00 2001 From: rakow Date: Tue, 14 Jan 2025 12:05:19 +0100 Subject: [PATCH 13/13] handle multiple detours on the same schedule correctly --- .../railsim/events/RailsimDetourEvent.java | 3 ++ .../integration/RailsimIntegrationTest.java | 39 +++++++------------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/events/RailsimDetourEvent.java b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/events/RailsimDetourEvent.java index 70b2fddd1c1..cb0c04ad5b0 100644 --- a/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/events/RailsimDetourEvent.java +++ b/contribs/railsim/src/main/java/ch/sbb/matsim/contrib/railsim/events/RailsimDetourEvent.java @@ -64,6 +64,9 @@ public Id getVehicleId() { return vehicleId; } + public Id getNewStop() { + return newStop; + } @Override public Map getAttributes() { diff --git a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java index be22a0c1d5a..4c0d774396a 100644 --- a/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java +++ b/contribs/railsim/src/test/java/ch/sbb/matsim/contrib/railsim/integration/RailsimIntegrationTest.java @@ -20,6 +20,7 @@ package ch.sbb.matsim.contrib.railsim.integration; import ch.sbb.matsim.contrib.railsim.RailsimModule; +import ch.sbb.matsim.contrib.railsim.events.RailsimDetourEvent; import ch.sbb.matsim.contrib.railsim.events.RailsimTrainStateEvent; import ch.sbb.matsim.contrib.railsim.qsimengine.RailsimQSimModule; import org.junit.jupiter.api.Assertions; @@ -337,34 +338,21 @@ void testMicroStationRerouting() { // collect all arrivals and departures Map, List>> train2arrivalStops = new HashMap<>(); Map, List>> train2departureStops = new HashMap<>(); + Map, List> train2detours = new HashMap<>(); for (Event event : collector.getEvents()) { - if (event.getEventType().equals(VehicleArrivesAtFacilityEvent.EVENT_TYPE)) { - - VehicleArrivesAtFacilityEvent vehicleArrivesEvent = (VehicleArrivesAtFacilityEvent) event; - - if (train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()) == null) { - - List> stops = new ArrayList<>(); - stops.add(vehicleArrivesEvent.getFacilityId()); - train2arrivalStops.put(vehicleArrivesEvent.getVehicleId(), stops); - } else { - train2arrivalStops.get(vehicleArrivesEvent.getVehicleId()).add(vehicleArrivesEvent.getFacilityId()); - } + if (event instanceof VehicleArrivesAtFacilityEvent vehicleArrivesEvent) { + train2arrivalStops.computeIfAbsent(vehicleArrivesEvent.getVehicleId(), k -> new ArrayList<>()) + .add(vehicleArrivesEvent.getFacilityId()); } - if (event.getEventType().equals(VehicleDepartsAtFacilityEvent.EVENT_TYPE)) { - - VehicleDepartsAtFacilityEvent vehicleDepartsEvent = (VehicleDepartsAtFacilityEvent) event; - - if (train2departureStops.get(vehicleDepartsEvent.getVehicleId()) == null) { + if (event instanceof VehicleDepartsAtFacilityEvent vehicleDepartsEvent) { + train2departureStops.computeIfAbsent(vehicleDepartsEvent.getVehicleId(), k -> new ArrayList<>()) + .add(vehicleDepartsEvent.getFacilityId()); + } - List> stops = new ArrayList<>(); - stops.add(vehicleDepartsEvent.getFacilityId()); - train2departureStops.put(vehicleDepartsEvent.getVehicleId(), stops); - } else { - train2departureStops.get(vehicleDepartsEvent.getVehicleId()).add(vehicleDepartsEvent.getFacilityId()); - } + if (event instanceof RailsimDetourEvent detour) { + train2detours.computeIfAbsent(detour.getVehicleId(), k -> new ArrayList<>()).add(detour); } } @@ -380,7 +368,10 @@ void testMicroStationRerouting() { Assertions.assertEquals("AB", train2arrivalStops.get(Id.createVehicleId("train3")).get(0).toString(), "Wrong stop facility. This is the start stop facility."); // The original events don't contain the re-routing. They appear to other agents as if the train drove the original schedule. - Assertions.assertEquals("CE", train2arrivalStops.get(Id.createVehicleId("train3")).get(1).toString(), "Wrong stop facility. This is the rerouted stop Id. Train 3 is rerouted from CE to CD."); + Assertions.assertEquals("CE", train2arrivalStops.get(Id.createVehicleId("train3")).get(1).toString(), "Wrong stop facility. This is the original id"); + // Detour facility + Assertions.assertEquals("CD", train2detours.get(Id.createVehicleId("train3")).get(0).getNewStop().toString()); + Assertions.assertEquals("JK", train2arrivalStops.get(Id.createVehicleId("train3")).get(2).toString(), "Wrong stop facility. This is the final stop facility."); }