From 2057918e3f3c199ed12d20354669e0f4cbc47e2f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Fri, 16 Aug 2024 15:27:48 +0200 Subject: [PATCH] remove LSPCarrierPair and the list storing it. This is not needed in leads only to more complex code. --- .../CollectionCarrierScheduler.java | 122 ++++++------- .../DistributionCarrierScheduler.java | 169 +++++++++--------- 2 files changed, 147 insertions(+), 144 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java index c3448994..8e19d993 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -1,27 +1,30 @@ /* - *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2022 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** + *********************************************************************** * + * project: org.matsim.* + * * + * *********************************************************************** * + * * + * copyright : (C) 2022 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package org.matsim.freight.logistics.resourceImplementations; -import java.util.ArrayList; +import java.util.Objects; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.freight.carriers.Carrier; @@ -45,9 +48,10 @@ */ /*package-private*/ class CollectionCarrierScheduler extends LSPResourceScheduler { + Logger log = LogManager.getLogger(CollectionCarrierScheduler.class); + private Carrier carrier; private CollectionCarrierResource resource; - private ArrayList pairs; private final Scenario scenario; /** @@ -57,13 +61,11 @@ * @param scenario the road pricing scheme */ CollectionCarrierScheduler(Scenario scenario) { - this.pairs = new ArrayList<>(); this.scenario = scenario; } @Override public void initializeValues(LSPResource resource) { - this.pairs = new ArrayList<>(); if (resource.getClass() == CollectionCarrierResource.class) { this.resource = (CollectionCarrierResource) resource; this.carrier = this.resource.getCarrier(); @@ -89,7 +91,11 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { .setCapacityDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); - pairs.add(new LSPCarrierPair(lspShipment, carrierService)); + //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan + if (! Objects.equals(lspShipment.getId().toString(), carrierService.getId().toString())) { + log.error("Id of LspShipment: {} and CarrierService: {} do not match", lspShipment.getId().toString(), carrierService.getId().toString(), + new IllegalStateException("Id of LspShipment and CarrierService do not match")); + } return carrierService; } @@ -100,15 +106,12 @@ protected void updateShipments() { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof ServiceActivity serviceActivity) { - for (LSPCarrierPair pair : pairs) { - if (pair.lspShipment == lspShipment - && pair.carrierService.getId() == serviceActivity.getService().getId()) { - addShipmentLoadElement(lspShipment, tour, serviceActivity); - addShipmentTransportElement(lspShipment, tour, serviceActivity); - addShipmentUnloadElement(lspShipment, tour); - addCollectionTourEndEventHandler(pair.carrierService, lspShipment, resource, tour); - addCollectionServiceEventHandler(pair.carrierService, lspShipment, resource); - } + if (Objects.equals(lspShipment.getId().toString(), serviceActivity.getService().getId().toString())) { + addShipmentLoadElement(lspShipment, tour, serviceActivity); + addShipmentTransportElement(lspShipment, tour, serviceActivity); + addShipmentUnloadElement(lspShipment, tour); + addCollectionTourEndEventHandler(serviceActivity.getService(), lspShipment, resource, tour); + addCollectionServiceEventHandler(serviceActivity.getService(), lspShipment, resource); } } } @@ -117,10 +120,10 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipment lspShipment, Tour tour, ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = - LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { @@ -132,23 +135,23 @@ private void addShipmentLoadElement( int serviceIndex = tour.getTourElements().indexOf(serviceActivity); Leg legBeforeService = (Leg) tour.getTourElements().get(serviceIndex - 1); double startTimeOfLoading = - legBeforeService.getExpectedDepartureTime() + legBeforeService.getExpectedTransportTime(); + legBeforeService.getExpectedDepartureTime() + legBeforeService.getExpectedTransportTime(); builder.setStartTime(startTimeOfLoading); builder.setEndTime(startTimeOfLoading + lspShipment.getDeliveryServiceTime()); LspShipmentPlanElement load = builder.build(); String idString = - load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); + load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) - .addPlanElement(id, load); + .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = - LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { @@ -170,23 +173,23 @@ private void addShipmentTransportElement( builder.setCarrierService(serviceActivity.getService()); LspShipmentPlanElement transport = builder.build(); String idString = - transport.getResourceId() - + "" - + transport.getLogisticChainElement().getId() - + transport.getElementType(); + transport.getResourceId() + + "" + + transport.getLogisticChainElement().getId() + + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) - .addPlanElement(id, transport); + .addPlanElement(id, transport); } private void addCollectionServiceEventHandler( - CarrierService carrierService, LspShipment lspShipment, LSPCarrierResource resource) { + CarrierService carrierService, LspShipment lspShipment, LSPCarrierResource resource) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { CollectionServiceEndEventHandler endHandler = - new CollectionServiceEndEventHandler( - carrierService, lspShipment, element, resource); + new CollectionServiceEndEventHandler( + carrierService, lspShipment, element, resource); lspShipment.addSimulationTracker(endHandler); break; } @@ -194,15 +197,15 @@ private void addCollectionServiceEventHandler( } private void addCollectionTourEndEventHandler( - CarrierService carrierService, - LspShipment lspShipment, - LSPCarrierResource resource, - Tour tour) { + CarrierService carrierService, + LspShipment lspShipment, + LSPCarrierResource resource, + Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourEndEventHandler handler = - new LSPTourEndEventHandler( - lspShipment, carrierService, element, resource, tour); + new LSPTourEndEventHandler( + lspShipment, carrierService, element, resource, tour); lspShipment.addSimulationTracker(handler); break; } @@ -212,7 +215,7 @@ private void addCollectionTourEndEventHandler( private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = - LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { @@ -226,13 +229,13 @@ private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour) { LspShipmentPlanElement unload = builder.build(); String idString = - unload.getResourceId() - + "" - + unload.getLogisticChainElement().getId() - + unload.getElementType(); + unload.getResourceId() + + "" + + unload.getLogisticChainElement().getId() + + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) - .addPlanElement(id, unload); + .addPlanElement(id, unload); } private double getUnloadEndTime(Tour tour) { @@ -245,5 +248,4 @@ private double getUnloadEndTime(Tour tour) { return unloadEndTime; } - private record LSPCarrierPair(LspShipment lspShipment, CarrierService carrierService) {} } diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java index 2dc40979..5a3de136 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -1,30 +1,30 @@ /* - *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2022 by the members listed in the COPYING, * - * LICENSE and WARRANTY file. * - * email : info at matsim dot org * - * * - * *********************************************************************** * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * See also COPYING, LICENSE and WARRANTY file * - * * - * *********************************************************************** + *********************************************************************** * + * project: org.matsim.* + * * + * *********************************************************************** * + * * + * copyright : (C) 2022 by the members listed in the COPYING, * + * LICENSE and WARRANTY file. * + * email : info at matsim dot org * + * * + * *********************************************************************** * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * See also COPYING, LICENSE and WARRANTY file * + * * + * *********************************************************************** */ package org.matsim.freight.logistics.resourceImplementations; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; +import java.util.*; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.locationtech.jts.util.Assert; import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; @@ -50,9 +50,10 @@ */ /*package-private*/ class DistributionCarrierScheduler extends LSPResourceScheduler { + Logger log = LogManager.getLogger(DistributionCarrierScheduler.class); + private Carrier carrier; private DistributionCarrierResource resource; - private ArrayList pairs; private int carrierCnt = 1; private final Scenario scenario; @@ -64,13 +65,11 @@ * @param scenario the scenario */ DistributionCarrierScheduler(Scenario scenario) { - this.pairs = new ArrayList<>(); this.scenario = scenario; } @Override protected void initializeValues(LSPResource resource) { - this.pairs = new ArrayList<>(); if (resource.getClass() == DistributionCarrierResource.class) { this.resource = (DistributionCarrierResource) resource; this.carrier = this.resource.getCarrier(); @@ -94,14 +93,14 @@ protected void scheduleResource() { // das erste/nächste(?) und schaut ob es da rein passt... Aber was ist, wenn es mehrere // gibt??? VehicleType vehicleType = - ResourceImplementationUtils.getVehicleTypeCollection(carrier).iterator().next(); + ResourceImplementationUtils.getVehicleTypeCollection(carrier).iterator().next(); if ((load + lspShipment.getSize()) - > vehicleType.getCapacity().getOther().intValue()) { + > vehicleType.getCapacity().getOther().intValue()) { load = 0; Carrier auxiliaryCarrier = - CarrierSchedulerUtils.solveVrpWithJsprit( - createAuxiliaryCarrier(shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime), - scenario); + CarrierSchedulerUtils.solveVrpWithJsprit( + createAuxiliaryCarrier(shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime), + scenario); scheduledPlans.add(auxiliaryCarrier.getSelectedPlan()); carrier.getServices().putAll(auxiliaryCarrier.getServices()); cumulatedLoadingTime = 0; @@ -115,10 +114,10 @@ protected void scheduleResource() { if (!shipmentsInCurrentTour.isEmpty()) { Carrier auxiliaryCarrier = - CarrierSchedulerUtils.solveVrpWithJsprit( - createAuxiliaryCarrier( - shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime), - scenario); + CarrierSchedulerUtils.solveVrpWithJsprit( + createAuxiliaryCarrier( + shipmentsInCurrentTour, availabilityTimeOfLastShipment + cumulatedLoadingTime), + scenario); scheduledPlans.add(auxiliaryCarrier.getSelectedPlan()); carrier.getServices().putAll(auxiliaryCarrier.getServices()); shipmentsInCurrentTour.clear(); @@ -157,13 +156,13 @@ private Collection unifyTourIds(Collection carrierPl for (CarrierPlan carrierPlan : carrierPlans) { for (ScheduledTour scheduledTour : carrierPlan.getScheduledTours()) { var newTour = - scheduledTour - .getTour() - .duplicateWithNewId(Id.create("dist_" + tourIdIndex, Tour.class)); + scheduledTour + .getTour() + .duplicateWithNewId(Id.create("dist_" + tourIdIndex, Tour.class)); tourIdIndex++; var newScheduledTour = - ScheduledTour.newInstance( - newTour, scheduledTour.getVehicle(), scheduledTour.getDeparture()); + ScheduledTour.newInstance( + newTour, scheduledTour.getVehicle(), scheduledTour.getDeparture()); scheduledToursUnified.add(newScheduledTour); } } @@ -176,7 +175,11 @@ private CarrierService convertToCarrierService(LspShipment lspShipment) { .setCapacityDemand(lspShipment.getSize()) .setServiceDuration(lspShipment.getDeliveryServiceTime()) .build(); - pairs.add(new LSPCarrierPair(lspShipment, carrierService)); + //ensure that the ids of the lspShipment and the carrierService are the same. This is needed for updating the LSPShipmentPlan + if (! Objects.equals(lspShipment.getId().toString(), carrierService.getId().toString())) { + log.error("Id of LspShipment: {} and CarrierService: {} do not match", lspShipment.getId().toString(), carrierService.getId().toString(), + new IllegalStateException("Id of LspShipment and CarrierService do not match")); + } return carrierService; } @@ -187,15 +190,12 @@ protected void updateShipments() { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof ServiceActivity serviceActivity) { - for (LSPCarrierPair pair : pairs) { - if (pair.lspShipment == lspShipment - && pair.carrierService.getId() == serviceActivity.getService().getId()) { - addShipmentLoadElement(lspShipment, tour); - addShipmentTransportElement(lspShipment, tour, serviceActivity); - addShipmentUnloadElement(lspShipment, tour, serviceActivity); - addDistributionTourStartEventHandler(pair.carrierService, lspShipment, resource, tour); - addDistributionServiceEventHandler(pair.carrierService, lspShipment, resource); - } + if (Objects.equals(lspShipment.getId().toString(), serviceActivity.getService().getId().toString())) { + addShipmentLoadElement(lspShipment, tour); + addShipmentTransportElement(lspShipment, tour, serviceActivity); + addShipmentUnloadElement(lspShipment, tour, serviceActivity); + addDistributionTourStartEventHandler(serviceActivity.getService(), lspShipment, resource, tour); + addDistributionServiceEventHandler(serviceActivity.getService(), lspShipment, resource); } } } @@ -205,7 +205,7 @@ protected void updateShipments() { private void addShipmentLoadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = - LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { @@ -228,17 +228,17 @@ private void addShipmentLoadElement(LspShipment lspShipment, Tour tour) { LspShipmentPlanElement load = builder.build(); String idString = - load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); + load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) - .addPlanElement(id, load); + .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = - LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { @@ -253,13 +253,13 @@ private void addShipmentTransportElement( final Leg legBeforeService = (Leg) tour.getTourElements().get(serviceIndex - 1); final double startTimeOfTransport = legAfterStart.getExpectedDepartureTime(); final double endTimeOfTransport = - legBeforeService.getExpectedTransportTime() + legBeforeService.getExpectedDepartureTime(); + legBeforeService.getExpectedTransportTime() + legBeforeService.getExpectedDepartureTime(); Assert.isTrue( - endTimeOfTransport >= startTimeOfTransport, - "latest End must be later than earliest start. start: " - + startTimeOfTransport - + " ; end: " - + endTimeOfTransport); + endTimeOfTransport >= startTimeOfTransport, + "latest End must be later than earliest start. start: " + + startTimeOfTransport + + " ; end: " + + endTimeOfTransport); builder.setStartTime(startTimeOfTransport); builder.setEndTime(endTimeOfTransport); @@ -269,20 +269,20 @@ private void addShipmentTransportElement( builder.setCarrierService(serviceActivity.getService()); LspShipmentPlanElement transport = builder.build(); String idString = - transport.getResourceId() - + "" - + transport.getLogisticChainElement().getId() - + transport.getElementType(); + transport.getResourceId() + + "" + + transport.getLogisticChainElement().getId() + + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) - .addPlanElement(id, transport); + .addPlanElement(id, transport); } private void addShipmentUnloadElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = - LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); + LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { @@ -297,20 +297,20 @@ private void addShipmentUnloadElement( final double startTime = serviceAct.getExpectedArrival(); final double endTime = startTime + serviceAct.getDuration(); Assert.isTrue( - endTime >= startTime, - "latest End must be later than earliest start. start: " + startTime + " ; end: " + endTime); + endTime >= startTime, + "latest End must be later than earliest start. start: " + startTime + " ; end: " + endTime); builder.setStartTime(startTime); builder.setEndTime(endTime); LspShipmentPlanElement unload = builder.build(); String idString = - unload.getResourceId() - + String.valueOf(unload.getLogisticChainElement().getId()) - + unload.getElementType(); + unload.getResourceId() + + String.valueOf(unload.getLogisticChainElement().getId()) + + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) - .addPlanElement(id, unload); + .addPlanElement(id, unload); } private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrentTour, double startTime) { @@ -318,12 +318,12 @@ private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrent carrierCnt++; Carrier auxiliaryCarrier = CarriersUtils.createCarrier(carrierId); CarrierVehicle carrierVehicle = - carrier.getCarrierCapabilities().getCarrierVehicles().values().iterator().next(); + carrier.getCarrierCapabilities().getCarrierVehicles().values().iterator().next(); final VehicleType vehicleType = carrierVehicle.getType(); CarrierVehicle.Builder vBuilder = - CarrierVehicle.Builder.newInstance( - carrierVehicle.getId(), carrierVehicle.getLinkId(), vehicleType); + CarrierVehicle.Builder.newInstance( + carrierVehicle.getId(), carrierVehicle.getLinkId(), vehicleType); vBuilder.setEarliestStart(startTime); vBuilder.setLatestEnd(24 * 60 * 60); CarrierVehicle cv = vBuilder.build(); @@ -338,12 +338,14 @@ private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrent } private void addDistributionServiceEventHandler( - CarrierService carrierService, LspShipment lspShipment, LSPCarrierResource resource) { + CarrierService carrierService, + LspShipment lspShipment, + LSPCarrierResource resource) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { DistributionServiceStartEventHandler handler = - new DistributionServiceStartEventHandler(carrierService, lspShipment, element, resource); + new DistributionServiceStartEventHandler(carrierService, lspShipment, element, resource); lspShipment.addSimulationTracker(handler); break; } @@ -351,20 +353,19 @@ private void addDistributionServiceEventHandler( } private void addDistributionTourStartEventHandler( - CarrierService carrierService, - LspShipment lspShipment, - LSPCarrierResource resource, - Tour tour) { + CarrierService carrierService, + LspShipment lspShipment, + LSPCarrierResource resource, + Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourStartEventHandler handler = - new LSPTourStartEventHandler(lspShipment, carrierService, element, resource, tour); + new LSPTourStartEventHandler(lspShipment, carrierService, element, resource, tour); lspShipment.addSimulationTracker(handler); break; } } } - private record LSPCarrierPair(LspShipment lspShipment, CarrierService carrierService) {} }