diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java index 55980a54..2bd364fb 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/LSPTourStartEventHandler.java @@ -64,13 +64,13 @@ public class LSPTourStartEventHandler // Todo: I have made it (temporarily) public because of junit tests :( -- need to find another way // to do the junit testing. kmt jun'23 + private final Tour tour; private final CarrierService carrierService; private final LogisticChainElement logisticChainElement; private final LSPCarrierResource resource; - private final Tour tour; private LSPShipment lspShipment; - LSPTourStartEventHandler( + public LSPTourStartEventHandler( LSPShipment lspShipment, CarrierService carrierService, LogisticChainElement logisticChainElement, @@ -95,18 +95,26 @@ public void handleEvent(CarrierTourStartEvent event) { if (tourElement instanceof ServiceActivity serviceActivity) { if (serviceActivity.getService().getId() == carrierService.getId() && event.getCarrierId() == resource.getCarrier().getId()) { - if (resource instanceof DistributionCarrierResource) { + if (resource instanceof DistributionCarrierResource) { //DistributionTourStarts logLoad( event.getCarrierId(), event.getLinkId(), event.getTime() - getCumulatedLoadingTime(tour), event.getTime()); logTransport( - event.getCarrierId(), event.getLinkId(), tour.getEndLinkId(), event.getTime()); - } // else if (resource instanceof MainRunCarrierResource) { - //.... -// } - + event.getCarrierId(), + event.getLinkId(), tour.getEndLinkId(), + event.getTime()); + } else if (resource instanceof MainRunCarrierResource) { //MainRunTourStarts + logLoad(event.getCarrierId(), + event.getLinkId(), + event.getTime() - getCumulatedLoadingTime(tour), + event.getTime()); + logTransport(event.getCarrierId(), + event.getLinkId(), + tour.getEndLinkId(), + event.getTime()); + } } } } diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java index d4206554..973cf57c 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -385,8 +385,8 @@ private void addMainTourRunStartEventHandler( Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getShipments().contains(tuple)) { - MainRunTourStartEventHandler handler = - new MainRunTourStartEventHandler( + LSPTourStartEventHandler handler = + new LSPTourStartEventHandler( tuple.getShipment(), carrierService, element, resource, tour); tuple.getShipment().addSimulationTracker(handler); break; diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunTourStartEventHandler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunTourStartEventHandler.java deleted file mode 100644 index 51f8f491..00000000 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunTourStartEventHandler.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - *********************************************************************** * - * project: org.matsim.* - * * - * *********************************************************************** * - * * - * copyright : (C) 2024 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 org.matsim.api.core.v01.Id; -import org.matsim.api.core.v01.network.Link; -import org.matsim.freight.carriers.Carrier; -import org.matsim.freight.carriers.CarrierService; -import org.matsim.freight.carriers.Tour; -import org.matsim.freight.carriers.Tour.ServiceActivity; -import org.matsim.freight.carriers.Tour.TourElement; -import org.matsim.freight.carriers.events.CarrierTourStartEvent; -import org.matsim.freight.carriers.events.eventhandler.CarrierTourStartEventHandler; -import org.matsim.freight.logistics.LSPCarrierResource; -import org.matsim.freight.logistics.LSPResource; -import org.matsim.freight.logistics.LSPSimulationTracker; -import org.matsim.freight.logistics.LogisticChainElement; -import org.matsim.freight.logistics.shipment.LSPShipment; -import org.matsim.freight.logistics.shipment.ShipmentLeg; -import org.matsim.freight.logistics.shipment.ShipmentPlanElement; -import org.matsim.freight.logistics.shipment.ShipmentUtils; - -public class MainRunTourStartEventHandler - implements CarrierTourStartEventHandler, LSPSimulationTracker { - // Todo: I have made it (temporarily) public because of junit tests :( -- need to find another way - // to do the junit testing. kmt jun'23 - - private final Tour tour; - private final CarrierService carrierService; - private final LogisticChainElement logisticChainElement; - private final LSPCarrierResource resource; - private LSPShipment lspShipment; - - public MainRunTourStartEventHandler( - LSPShipment lspShipment, - CarrierService carrierService, - LogisticChainElement logisticChainElement, - LSPCarrierResource resource, - Tour tour) { - this.lspShipment = lspShipment; - this.carrierService = carrierService; - this.logisticChainElement = logisticChainElement; - this.resource = resource; - this.tour = tour; - } - - @Override - public void reset(int iteration) { - // TODO Auto-generated method stub - } - - @Override - public void handleEvent(CarrierTourStartEvent event) { - if (event.getTourId().equals(tour.getId())) { - for (TourElement tourElement : tour.getTourElements()) { - if (tourElement instanceof ServiceActivity serviceActivity) { - if (serviceActivity.getService().getId() == carrierService.getId() - && event.getCarrierId() == resource.getCarrier().getId()) { - logLoad(event.getCarrierId(), event.getLinkId(), - event.getTime() - getCumulatedLoadingTime(tour), event.getTime()); - logTransport(event.getCarrierId(), event.getLinkId(), tour.getEndLinkId(), - event.getTime()); - } - } - } - } - } - - private void logLoad(Id carrierId, Id linkId, - double startTime, double endTime) { - ShipmentUtils.LoggedShipmentLoadBuilder builder = - ShipmentUtils.LoggedShipmentLoadBuilder.newInstance(); - builder.setCarrierId(carrierId); - builder.setLinkId(linkId); - builder.setLogisticsChainElement(logisticChainElement); - builder.setResourceId(resource.getId()); - builder.setStartTime(startTime); - builder.setEndTime(endTime); - ShipmentPlanElement loggedShipmentLoad = builder.build(); - String idString = - loggedShipmentLoad.getResourceId() - + "" - + loggedShipmentLoad.getLogisticChainElement().getId() - + loggedShipmentLoad.getElementType(); - Id loadId = Id.create(idString, ShipmentPlanElement.class); - lspShipment.getShipmentLog().addPlanElement(loadId, loggedShipmentLoad); - } - - private void logTransport(Id carrierId, Id fromLinkId, - Id toLinkId, double startTime) { - ShipmentUtils.LoggedShipmentTransportBuilder builder = - ShipmentUtils.LoggedShipmentTransportBuilder.newInstance(); - builder.setCarrierId(carrierId); - builder.setFromLinkId(fromLinkId); - builder.setToLinkId(toLinkId); - builder.setLogisticChainElement(logisticChainElement); - builder.setResourceId(resource.getId()); - builder.setStartTime(startTime); - ShipmentLeg transport = builder.build(); - String idString = - transport.getResourceId() - + "" - + transport.getLogisticChainElement().getId() - + transport.getElementType(); - Id transportId = Id.create(idString, ShipmentPlanElement.class); - lspShipment.getShipmentLog().addPlanElement(transportId, transport); - } - - private double getCumulatedLoadingTime(Tour tour) { - double cumulatedLoadingTime = 0; - for (TourElement tourElement : tour.getTourElements()) { - if (tourElement instanceof ServiceActivity serviceActivity) { - cumulatedLoadingTime = cumulatedLoadingTime + serviceActivity.getDuration(); - } - } - return cumulatedLoadingTime; - } - - public CarrierService getCarrierService() { - return carrierService; - } - - public LSPShipment getLspShipment() { - return lspShipment; - } - - public LogisticChainElement getLogisticChainElement() { - return logisticChainElement; - } - - public Id getResourceId() { - return resource.getId(); - } - - @Override - public void setEmbeddingContainer(LSPShipment pointer) { - this.lspShipment = pointer; - } -} diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java index 37e07b42..c2e80dbb 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -502,6 +502,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -518,8 +519,9 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -535,6 +537,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -552,6 +555,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); + //DistributionRunStart assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); @@ -569,6 +573,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), planElements.get(10).getResourceId()); assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); + //DistributionServiceStart assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java index c3de4016..c0ebf127 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -366,6 +366,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -382,8 +383,9 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunTourStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -399,6 +401,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunTourEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java index 00e1b0d7..a2a2f21c 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -505,6 +505,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -521,8 +522,9 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunTourStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -538,6 +540,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunTourEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); @@ -555,6 +558,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); + //DistributionTourStart assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); @@ -572,6 +576,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), planElements.get(10).getResourceId()); assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); + //DistributionServiceStart assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java index efea24ac..5dab232d 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -366,6 +366,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -382,8 +383,9 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunTourStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -399,6 +401,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java index 36cae547..14508001 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -418,6 +418,7 @@ public void testSecondReloadLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); + //CollectionTourEnd assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.get(0); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -434,6 +435,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionEndHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -450,8 +452,9 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -467,6 +470,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java index 3ad22bbc..e380d8e6 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -418,6 +418,7 @@ public void testSecondReloadLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); + //CollectionTourEnd assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.get(0); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -434,6 +435,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionEndHandler.getResourceId(), resources.get(0).getId()); + //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); @@ -450,8 +452,9 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), resources.get(0).getId()); - assertTrue(eventHandlers.get(2) instanceof MainRunTourStartEventHandler); - MainRunTourStartEventHandler mainRunStartHandler = (MainRunTourStartEventHandler) eventHandlers.get(2); + //MainRunStart + assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertEquals(mainRunStartHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -467,6 +470,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), planElements.get(6).getResourceId()); assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); + //MainRunEnd assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId);