From 5fc4cec2bd170860f35b3b2d5d73dacea34e68d4 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 12:10:24 +0200 Subject: [PATCH 01/21] store time in Attribute of LspShipment. --- .../logistics/LspShipmentWithTime.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java index 60eacfd1..f39f2116 100644 --- a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java +++ b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java @@ -30,11 +30,12 @@ public class LspShipmentWithTime { // jun'22 private final LspShipment lspShipment; - private final double time; +// private final double time; public LspShipmentWithTime(double time, LspShipment lspShipment) { this.lspShipment = lspShipment; - this.time = time; + setTimeOfLspShipment(this.lspShipment, time); +// this.time = time; } public LspShipment getLspShipment() { @@ -42,6 +43,31 @@ public LspShipment getLspShipment() { } public double getTime() { - return time; + return getTimeOfLspShipment(this.lspShipment); +// return time; + } + + /** + * Stores a time as Attribute in the LspShipment. + * This is needed for some kind of tracking the shipment. + *

+ * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. + * KMT Jul'24 + * @param lspShipment the LspShipment to store the time in + * @param time the time to store + */ + private void setTimeOfLspShipment(LspShipment lspShipment, double time){ + lspShipment.getAttributes().putAttribute("time", time); + } + + /** + * Returns the time stored in the LspShipment. + *

+ * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. KMT Jul'24 + * @param lspShipment the LspShipment to get the time from + * @return the time as double + */ + private double getTimeOfLspShipment(LspShipment lspShipment) { + return (double) lspShipment.getAttributes().getAttribute("time"); } } From 60b514003c519322c3c666d4f30c644ed9427179 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 12:14:31 +0200 Subject: [PATCH 02/21] move methods to Utils class --- .../logistics/LspShipmentWithTime.java | 31 +++---------------- .../logistics/shipment/LspShipmentUtils.java | 24 ++++++++++++++ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java index f39f2116..ab649710 100644 --- a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java +++ b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java @@ -21,6 +21,7 @@ package org.matsim.freight.logistics; import org.matsim.freight.logistics.shipment.LspShipment; +import org.matsim.freight.logistics.shipment.LspShipmentUtils; public class LspShipmentWithTime { // yyyyyy find better solution for this. It is not so good to define an interface, and then @@ -30,12 +31,11 @@ public class LspShipmentWithTime { // jun'22 private final LspShipment lspShipment; -// private final double time; + public LspShipmentWithTime(double time, LspShipment lspShipment) { this.lspShipment = lspShipment; - setTimeOfLspShipment(this.lspShipment, time); -// this.time = time; + LspShipmentUtils.setTimeOfLspShipment(this.lspShipment, time); } public LspShipment getLspShipment() { @@ -43,31 +43,8 @@ public LspShipment getLspShipment() { } public double getTime() { - return getTimeOfLspShipment(this.lspShipment); + return LspShipmentUtils.getTimeOfLspShipment(this.lspShipment); // return time; } - /** - * Stores a time as Attribute in the LspShipment. - * This is needed for some kind of tracking the shipment. - *

- * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. - * KMT Jul'24 - * @param lspShipment the LspShipment to store the time in - * @param time the time to store - */ - private void setTimeOfLspShipment(LspShipment lspShipment, double time){ - lspShipment.getAttributes().putAttribute("time", time); - } - - /** - * Returns the time stored in the LspShipment. - *

- * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. KMT Jul'24 - * @param lspShipment the LspShipment to get the time from - * @return the time as double - */ - private double getTimeOfLspShipment(LspShipment lspShipment) { - return (double) lspShipment.getAttributes().getAttribute("time"); - } } diff --git a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentUtils.java b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentUtils.java index 4ce345f7..01efd96b 100644 --- a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentUtils.java +++ b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentUtils.java @@ -60,6 +60,30 @@ public static LspShipmentPlan getOrCreateShipmentPlan(LSPPlan lspPlan, Id + * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. + * KMT Jul'24 + * @param lspShipment the LspShipment to store the time in + * @param time the time to store + */ + public static void setTimeOfLspShipment(LspShipment lspShipment, double time){ + lspShipment.getAttributes().putAttribute("time", time); + } + + /** + * Returns the time stored in the LspShipment. + *

+ * This will replace the LSPShipmentWithTime class and thus reduce the complexity of the code. KMT Jul'24 + * @param lspShipment the LspShipment to get the time from + * @return the time as double + */ + public static double getTimeOfLspShipment(LspShipment lspShipment) { + return (double) lspShipment.getAttributes().getAttribute("time"); + } + public static final class LspShipmentBuilder { final Id id; final List lspShipmentRequirements; From 4ff74c8c1516d5594ca436d162ea634d4cc5709e Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 12:46:28 +0200 Subject: [PATCH 03/21] WIP get rid of LspShipmentWithTime --- .../logistics/LSPResourceScheduler.java | 18 ++--- .../logistics/LspShipmentWithTime.java | 2 +- .../freight/logistics/WaitingShipments.java | 4 +- .../logistics/WaitingShipmentsImpl.java | 19 ++--- .../CollectionCarrierScheduler.java | 44 ++++++------ .../DistributionCarrierScheduler.java | 57 ++++++++------- .../MainRunCarrierScheduler.java | 69 +++++++++---------- .../TransshipmentHubScheduler.java | 18 ++--- .../logistics/shipment/LspShipment.java | 4 ++ .../logistics/shipment/LspShipmentImpl.java | 12 ++++ 10 files changed, 131 insertions(+), 116 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java index dbf68e4a..d43c77ba 100644 --- a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java @@ -41,7 +41,7 @@ public abstract class LSPResourceScheduler { protected LSPResource resource; - protected ArrayList lspShipmentsWithTime; + protected ArrayList lspShipmentsWithTime; protected LSPPlan lspPlan; @@ -83,23 +83,23 @@ private void presortIncomingShipments() { for (LogisticChainElement element : resource.getClientElements()) { lspShipmentsWithTime.addAll(element.getIncomingShipments().getLspShipmentsWTime()); } - lspShipmentsWithTime.sort(Comparator.comparingDouble(LspShipmentWithTime::getTime)); + lspShipmentsWithTime.sort(Comparator.comparingDouble(LspShipment::getTime)); } private void switchHandledShipments(int bufferTime) { - for (LspShipmentWithTime lspShipmentWithTime : lspShipmentsWithTime) { + for (LspShipment lspShipmentWithTime : lspShipmentsWithTime) { var shipmentPlan = - LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getLspShipment().getId()); + LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId()); double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime; - LspShipmentWithTime outgoingTuple = - new LspShipmentWithTime(endOfTransportTime, lspShipmentWithTime.getLspShipment()); + LspShipment outgoingLspShipment = lspShipmentWithTime; + lspShipmentWithTime.setTime(endOfTransportTime); for (LogisticChainElement element : resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipmentWithTime)) { - element.getOutgoingShipments().getLspShipmentsWTime().add(outgoingTuple); + element.getOutgoingShipments().getLspShipmentsWTime().add(outgoingLspShipment); element.getIncomingShipments().getLspShipmentsWTime().remove(lspShipmentWithTime); if (element.getNextElement() != null) { - element.getNextElement().getIncomingShipments().getLspShipmentsWTime().add(outgoingTuple); - element.getOutgoingShipments().getLspShipmentsWTime().remove(outgoingTuple); + element.getNextElement().getIncomingShipments().getLspShipmentsWTime().add(outgoingLspShipment); + element.getOutgoingShipments().getLspShipmentsWTime().remove(outgoingLspShipment); } } } diff --git a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java index ab649710..04f66219 100644 --- a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java +++ b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java @@ -34,8 +34,8 @@ public class LspShipmentWithTime { public LspShipmentWithTime(double time, LspShipment lspShipment) { + LspShipmentUtils.setTimeOfLspShipment(lspShipment, time); this.lspShipment = lspShipment; - LspShipmentUtils.setTimeOfLspShipment(this.lspShipment, time); } public LspShipment getLspShipment() { diff --git a/src/main/java/org/matsim/freight/logistics/WaitingShipments.java b/src/main/java/org/matsim/freight/logistics/WaitingShipments.java index e76da764..55e72fa3 100644 --- a/src/main/java/org/matsim/freight/logistics/WaitingShipments.java +++ b/src/main/java/org/matsim/freight/logistics/WaitingShipments.java @@ -43,9 +43,9 @@ public interface WaitingShipments { void addShipment(double time, LspShipment lspShipment); - Collection getSortedLspShipments(); + Collection getSortedLspShipments(); - Collection getLspShipmentsWTime(); + Collection getLspShipmentsWTime(); void clear(); } diff --git a/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java b/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java index 2c73f797..dc06af7f 100644 --- a/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java +++ b/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java @@ -25,10 +25,11 @@ import java.util.Comparator; import java.util.List; import org.matsim.freight.logistics.shipment.LspShipment; +import org.matsim.freight.logistics.shipment.LspShipmentUtils; /* package-private */ class WaitingShipmentsImpl implements WaitingShipments { - private final List shipments; + private final List shipments; WaitingShipmentsImpl() { this.shipments = new ArrayList<>(); @@ -36,14 +37,14 @@ @Override public void addShipment(double time, LspShipment lspShipment) { - LspShipmentWithTime tuple = new LspShipmentWithTime(time, lspShipment); - this.shipments.add(tuple); - shipments.sort(Comparator.comparingDouble(LspShipmentWithTime::getTime)); + lspShipment.setTime(time); + this.shipments.add(lspShipment); + shipments.sort(Comparator.comparingDouble(LspShipment::getTime)); } @Override - public Collection getSortedLspShipments() { - shipments.sort(Comparator.comparingDouble(LspShipmentWithTime::getTime)); + public Collection getSortedLspShipments() { + shipments.sort(Comparator.comparingDouble(LspShipment::getTime)); return shipments; } @@ -52,7 +53,7 @@ public void clear() { } @Override - public Collection getLspShipmentsWTime() { + public Collection getLspShipmentsWTime() { return shipments; } @@ -62,8 +63,8 @@ public String toString() { strb.append("WaitingShipmentsImpl{").append("No of Shipments= ").append(shipments.size()); if (!shipments.isEmpty()) { strb.append("; ShipmentIds="); - for (LspShipmentWithTime shipment : getSortedLspShipments()) { - strb.append("[").append(shipment.getLspShipment().getId()).append("]"); + for (LspShipment shipment : getSortedLspShipments()) { + strb.append("[").append(shipment.getId()).append("]"); } } strb.append('}'); 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 6588a1e2..0d514527 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -74,21 +74,21 @@ public void initializeValues(LSPResource resource) { @Override public void scheduleResource() { - for (LspShipmentWithTime tupleToBeAssigned : lspShipmentsWithTime) { + for (LspShipment tupleToBeAssigned : lspShipmentsWithTime) { CarrierService carrierService = convertToCarrierService(tupleToBeAssigned); carrier.getServices().put(carrierService.getId(), carrierService); } CarrierSchedulerUtils.solveVrpWithJsprit(carrier, scenario); } - private CarrierService convertToCarrierService(LspShipmentWithTime tuple) { + private CarrierService convertToCarrierService(LspShipment tuple) { Id serviceId = - Id.create(tuple.getLspShipment().getId().toString(), CarrierService.class); + Id.create(tuple.getId().toString(), CarrierService.class); CarrierService.Builder builder = - CarrierService.Builder.newInstance(serviceId, tuple.getLspShipment().getFrom()); - builder.setServiceStartTimeWindow(tuple.getLspShipment().getPickupTimeWindow()); - builder.setCapacityDemand(tuple.getLspShipment().getSize()); - builder.setServiceDuration(tuple.getLspShipment().getDeliveryServiceTime()); + CarrierService.Builder.newInstance(serviceId, tuple.getFrom()); + builder.setServiceStartTimeWindow(tuple.getPickupTimeWindow()); + builder.setCapacityDemand(tuple.getSize()); + builder.setServiceDuration(tuple.getDeliveryServiceTime()); CarrierService carrierService = builder.build(); pairs.add(new LSPCarrierPair(tuple, carrierService)); return carrierService; @@ -96,7 +96,7 @@ private CarrierService convertToCarrierService(LspShipmentWithTime tuple) { @Override protected void updateShipments() { - for (LspShipmentWithTime tuple : lspShipmentsWithTime) { + for (LspShipment tuple : lspShipmentsWithTime) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { @@ -119,7 +119,7 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -133,18 +133,18 @@ private void addShipmentLoadElement( double startTimeOfLoading = legBeforeService.getExpectedDepartureTime() + legBeforeService.getExpectedTransportTime(); builder.setStartTime(startTimeOfLoading); - builder.setEndTime(startTimeOfLoading + tuple.getLspShipment().getDeliveryServiceTime()); + builder.setEndTime(startTimeOfLoading + tuple.getDeliveryServiceTime()); LspShipmentPlanElement load = builder.build(); String idString = load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -172,18 +172,18 @@ private void addShipmentTransportElement( + transport.getLogisticChainElement().getId() + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, transport); } private void addCollectionServiceEventHandler( - CarrierService carrierService, LspShipmentWithTime tuple, LSPCarrierResource resource) { + CarrierService carrierService, LspShipment tuple, LSPCarrierResource resource) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { CollectionServiceEndEventHandler endHandler = new CollectionServiceEndEventHandler( - carrierService, tuple.getLspShipment(), element, resource); - tuple.getLspShipment().addSimulationTracker(endHandler); + carrierService, tuple, element, resource); + tuple.addSimulationTracker(endHandler); break; } } @@ -191,22 +191,22 @@ private void addCollectionServiceEventHandler( private void addCollectionTourEndEventHandler( CarrierService carrierService, - LspShipmentWithTime tuple, + LspShipment tuple, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { LSPTourEndEventHandler handler = new LSPTourEndEventHandler( - tuple.getLspShipment(), carrierService, element, resource, tour); - tuple.getLspShipment().addSimulationTracker(handler); + tuple, carrierService, element, resource, tour); + tuple.addSimulationTracker(handler); break; } } } private void addShipmentUnloadElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -227,7 +227,7 @@ private void addShipmentUnloadElement( + unload.getLogisticChainElement().getId() + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, unload); } @@ -241,5 +241,5 @@ private double getUnloadEndTime(Tour tour) { return unloadEndTime; } - private record LSPCarrierPair(LspShipmentWithTime tuple, CarrierService carrierService) {} + private record LSPCarrierPair(LspShipment tuple, 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 7eaf9e73..2e9703a3 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -34,6 +34,7 @@ import org.matsim.freight.carriers.Tour.ServiceActivity; import org.matsim.freight.carriers.Tour.TourElement; import org.matsim.freight.logistics.*; +import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; @@ -84,17 +85,17 @@ protected void scheduleResource() { int load = 0; double cumulatedLoadingTime = 0; double availabilityTimeOfLastShipment = 0; - ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); - ArrayList shipmentsInCurrentTour = new ArrayList<>(); + ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); + ArrayList shipmentsInCurrentTour = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); - for (LspShipmentWithTime tuple : copyOfAssignedShipments) { + for (LspShipment tuple : copyOfAssignedShipments) { // TODO KMT: Verstehe es nur mäßig, was er hier mit den Fahrzeugtypen macht. Er nimmt einfach // 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(); - if ((load + tuple.getLspShipment().getSize()) + if ((load + tuple.getSize()) > vehicleType.getCapacity().getOther().intValue()) { load = 0; Carrier auxiliaryCarrier = @@ -107,8 +108,8 @@ protected void scheduleResource() { shipmentsInCurrentTour.clear(); } shipmentsInCurrentTour.add(tuple); - load = load + tuple.getLspShipment().getSize(); - cumulatedLoadingTime = cumulatedLoadingTime + tuple.getLspShipment().getDeliveryServiceTime(); + load = load + tuple.getSize(); + cumulatedLoadingTime = cumulatedLoadingTime + tuple.getDeliveryServiceTime(); availabilityTimeOfLastShipment = tuple.getTime(); } @@ -169,13 +170,13 @@ private Collection unifyTourIds(Collection carrierPl return scheduledToursUnified; } - private CarrierService convertToCarrierService(LspShipmentWithTime tuple) { + private CarrierService convertToCarrierService(LspShipment tuple) { Id serviceId = - Id.create(tuple.getLspShipment().getId().toString(), CarrierService.class); + Id.create(tuple.getId().toString(), CarrierService.class); CarrierService.Builder builder = - CarrierService.Builder.newInstance(serviceId, tuple.getLspShipment().getTo()); - builder.setCapacityDemand(tuple.getLspShipment().getSize()); - builder.setServiceDuration(tuple.getLspShipment().getDeliveryServiceTime()); + CarrierService.Builder.newInstance(serviceId, tuple.getTo()); + builder.setCapacityDemand(tuple.getSize()); + builder.setServiceDuration(tuple.getDeliveryServiceTime()); CarrierService carrierService = builder.build(); pairs.add(new LSPCarrierPair(tuple, carrierService)); return carrierService; @@ -183,7 +184,7 @@ private CarrierService convertToCarrierService(LspShipmentWithTime tuple) { @Override protected void updateShipments() { - for (LspShipmentWithTime tuple : lspShipmentsWithTime) { + for (LspShipment tuple : lspShipmentsWithTime) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { @@ -206,7 +207,7 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -232,12 +233,12 @@ private void addShipmentLoadElement( String idString = load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -274,12 +275,12 @@ private void addShipmentTransportElement( + transport.getLogisticChainElement().getId() + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, transport); } private void addShipmentUnloadElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -306,11 +307,11 @@ private void addShipmentUnloadElement( + String.valueOf(unload.getLogisticChainElement().getId()) + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, unload); } - private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrentTour, double startTime) { + private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrentTour, double startTime) { final Id carrierId = Id.create(carrier.getId().toString() + carrierCnt, Carrier.class); carrierCnt++; Carrier auxiliaryCarrier = CarriersUtils.createCarrier(carrierId); @@ -327,7 +328,7 @@ private Carrier createAuxiliaryCarrier(ArrayList shipmentsI auxiliaryCarrier.getCarrierCapabilities().getCarrierVehicles().put(cv.getId(), cv); auxiliaryCarrier.getCarrierCapabilities().setFleetSize(FleetSize.FINITE); - for (LspShipmentWithTime tuple : shipmentsInCurrentTour) { + for (LspShipment tuple : shipmentsInCurrentTour) { CarrierService carrierService = convertToCarrierService(tuple); auxiliaryCarrier.getServices().put(carrierService.getId(), carrierService); } @@ -335,13 +336,12 @@ private Carrier createAuxiliaryCarrier(ArrayList shipmentsI } private void addDistributionServiceEventHandler( - CarrierService carrierService, LspShipmentWithTime tuple, LSPCarrierResource resource) { + CarrierService carrierService, LspShipment tuple, LSPCarrierResource resource) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { DistributionServiceStartEventHandler handler = - new DistributionServiceStartEventHandler( - carrierService, tuple.getLspShipment(), element, resource); - tuple.getLspShipment().addSimulationTracker(handler); + new DistributionServiceStartEventHandler(carrierService, tuple, element, resource); + tuple.addSimulationTracker(handler); break; } } @@ -349,19 +349,18 @@ private void addDistributionServiceEventHandler( private void addDistributionTourStartEventHandler( CarrierService carrierService, - LspShipmentWithTime tuple, + LspShipment tuple, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { LSPTourStartEventHandler handler = - new LSPTourStartEventHandler( - tuple.getLspShipment(), carrierService, element, resource, tour); - tuple.getLspShipment().addSimulationTracker(handler); + new LSPTourStartEventHandler(tuple, carrierService, element, resource, tour); + tuple.addSimulationTracker(handler); break; } } } - private record LSPCarrierPair(LspShipmentWithTime tuple, CarrierService carrierService) {} + private record LSPCarrierPair(LspShipment tuple, CarrierService carrierService) {} } 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 6c61da0c..ada47ff5 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -32,6 +32,7 @@ import org.matsim.freight.carriers.jsprit.NetworkBasedTransportCosts; import org.matsim.freight.carriers.jsprit.NetworkRouter; import org.matsim.freight.logistics.*; +import org.matsim.freight.logistics.shipment.LspShipment; import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; import org.matsim.vehicles.VehicleType; @@ -76,20 +77,20 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { int load = 0; - List copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); - copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipmentWithTime::getTime)); - ArrayList shipmentsInCurrentTour = new ArrayList<>(); + List copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); + copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipment::getTime)); + ArrayList shipmentsInCurrentTour = new ArrayList<>(); // ArrayList scheduledTours = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); - for (LspShipmentWithTime tuple : copyOfAssignedShipments) { + for (LspShipment tuple : copyOfAssignedShipments) { // Add job as "services" to the carrier. So the carrier has this available CarrierService carrierService = convertToCarrierService(tuple); carrier.getServices().put(carrierService.getId(), carrierService); VehicleType vehicleType = ResourceImplementationUtils.getVehicleTypeCollection(carrier).iterator().next(); - if ((load + tuple.getLspShipment().getSize()) + if ((load + tuple.getSize()) > vehicleType.getCapacity().getOther().intValue()) { load = 0; CarrierPlan plan = createPlan(carrier, shipmentsInCurrentTour); @@ -97,7 +98,7 @@ protected void scheduleResource() { shipmentsInCurrentTour.clear(); } shipmentsInCurrentTour.add(tuple); - load = load + tuple.getLspShipment().getSize(); + load = load + tuple.getSize(); } if (!shipmentsInCurrentTour.isEmpty()) { CarrierPlan plan = createPlan(carrier, shipmentsInCurrentTour); @@ -114,7 +115,7 @@ protected void scheduleResource() { carrier.setSelectedPlan(plan); } - private CarrierPlan createPlan(Carrier carrier, List tuples) { + private CarrierPlan createPlan(Carrier carrier, List tuples) { // TODO: Allgemein: Hier ist alles manuell zusammen gesetzt; es findet KEINE Tourenplanung // statt! @@ -132,8 +133,8 @@ private CarrierPlan createPlan(Carrier carrier, List tuples double totalLoadingTime = 0; double latestTupleTime = 0; - for (LspShipmentWithTime tuple : tuples) { - totalLoadingTime = totalLoadingTime + tuple.getLspShipment().getDeliveryServiceTime(); + for (LspShipment tuple : tuples) { + totalLoadingTime = totalLoadingTime + tuple.getDeliveryServiceTime(); if (tuple.getTime() > latestTupleTime) { latestTupleTime = tuple.getTime(); } @@ -222,34 +223,34 @@ private double scorePlanManually(CarrierPlan plan) { return (-score); // negative, because we are looking at "costs" instead of "utility" } - private CarrierService convertToCarrierService(LspShipmentWithTime tuple) { + private CarrierService convertToCarrierService(LspShipment tuple) { Id serviceId = - Id.create(tuple.getLspShipment().getId().toString(), CarrierService.class); + Id.create(tuple.getId().toString(), CarrierService.class); CarrierService.Builder builder = CarrierService.Builder.newInstance(serviceId, resource.getEndLinkId()); - builder.setCapacityDemand(tuple.getLspShipment().getSize()); - builder.setServiceDuration(tuple.getLspShipment().getDeliveryServiceTime()); + builder.setCapacityDemand(tuple.getSize()); + builder.setServiceDuration(tuple.getDeliveryServiceTime()); return builder.build(); } @Override protected void updateShipments() { - for (LspShipmentWithTime lspShipmentWithTime : lspShipmentsWithTime) { + for (LspShipment LspShipment : lspShipmentsWithTime) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof Tour.ServiceActivity serviceActivity) { LSPShipmentCarrierServicePair carrierPair = new LSPShipmentCarrierServicePair( - lspShipmentWithTime, serviceActivity.getService()); + LspShipment, serviceActivity.getService()); for (LSPShipmentCarrierServicePair pair : pairs) { if (pair.tuple == carrierPair.tuple && pair.carrierService.getId() == carrierPair.carrierService.getId()) { - addShipmentLoadElement(lspShipmentWithTime, tour); - addShipmentTransportElement(lspShipmentWithTime, tour, serviceActivity); - addShipmentUnloadElement(lspShipmentWithTime, tour, serviceActivity); - addMainTourRunStartEventHandler(pair.carrierService, lspShipmentWithTime, resource, tour); - addMainRunTourEndEventHandler(pair.carrierService, lspShipmentWithTime, resource, tour); + addShipmentLoadElement(LspShipment, tour); + addShipmentTransportElement(LspShipment, tour, serviceActivity); + addShipmentUnloadElement(LspShipment, tour, serviceActivity); + addMainTourRunStartEventHandler(pair.carrierService, LspShipment, resource, tour); + addMainRunTourEndEventHandler(pair.carrierService, LspShipment, resource, tour); } } } @@ -259,7 +260,7 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipmentWithTime tuple, Tour tour) { + LspShipment tuple, Tour tour) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -287,12 +288,12 @@ private void addShipmentLoadElement( + String.valueOf(load.getLogisticChainElement().getId()) + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -317,12 +318,12 @@ private void addShipmentTransportElement( + String.valueOf(transport.getLogisticChainElement().getId()) + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, transport); } private void addShipmentUnloadElement( - LspShipmentWithTime tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -353,21 +354,20 @@ private void addShipmentUnloadElement( + String.valueOf(unload.getLogisticChainElement().getId()) + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, unload); } private void addMainTourRunStartEventHandler( CarrierService carrierService, - LspShipmentWithTime tuple, + LspShipment tuple, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { LSPTourStartEventHandler handler = - new LSPTourStartEventHandler( - tuple.getLspShipment(), carrierService, element, resource, tour); - tuple.getLspShipment().addSimulationTracker(handler); + new LSPTourStartEventHandler(tuple, carrierService, element, resource, tour); + tuple.addSimulationTracker(handler); break; } } @@ -375,19 +375,18 @@ private void addMainTourRunStartEventHandler( private void addMainRunTourEndEventHandler( CarrierService carrierService, - LspShipmentWithTime tuple, + LspShipment tuple, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { LSPTourEndEventHandler handler = - new LSPTourEndEventHandler( - tuple.getLspShipment(),carrierService, element, resource, tour); - tuple.getLspShipment().addSimulationTracker(handler); + new LSPTourEndEventHandler(tuple, carrierService, element, resource, tour); + tuple.addSimulationTracker(handler); break; } } } - private record LSPShipmentCarrierServicePair(LspShipmentWithTime tuple, CarrierService carrierService) {} + private record LSPShipmentCarrierServicePair(LspShipment tuple, CarrierService carrierService) {} } diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index a5491b99..94c3a8dc 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -28,11 +28,11 @@ import org.matsim.freight.logistics.LSPResource; import org.matsim.freight.logistics.LSPResourceScheduler; import org.matsim.freight.logistics.LogisticChainElement; -import org.matsim.freight.logistics.LspShipmentWithTime; import org.matsim.freight.logistics.resourceImplementations.ResourceImplementationUtils.TranshipmentHubSchedulerBuilder; import org.matsim.freight.logistics.shipment.LspShipmentPlan; import org.matsim.freight.logistics.shipment.LspShipmentPlanElement; import org.matsim.freight.logistics.shipment.LspShipmentUtils; +import org.matsim.freight.logistics.shipment.LspShipment; /*package-private*/ class TransshipmentHubScheduler extends LSPResourceScheduler { @@ -55,7 +55,7 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { - for (LspShipmentWithTime tupleToBeAssigned : lspShipmentsWithTime) { + for (LspShipment tupleToBeAssigned : lspShipmentsWithTime) { updateSchedule(tupleToBeAssigned); } } @@ -66,17 +66,17 @@ protected void updateShipments() { log.error("This method is not implemented. Nothing will happen here. "); } - private void updateSchedule(LspShipmentWithTime tuple) { + private void updateSchedule(LspShipment tuple) { addShipmentHandleElement(tuple); addShipmentToEventHandler(tuple); } - private void addShipmentHandleElement(LspShipmentWithTime tuple) { + private void addShipmentHandleElement(LspShipment tuple) { LspShipmentUtils.ScheduledShipmentHandleBuilder builder = LspShipmentUtils.ScheduledShipmentHandleBuilder.newInstance(); builder.setStartTime(tuple.getTime()); builder.setEndTime( - tuple.getTime() + capacityNeedFixed + capacityNeedLinear * tuple.getLspShipment().getSize()); + tuple.getTime() + capacityNeedFixed + capacityNeedLinear * tuple.getSize()); builder.setResourceId(transshipmentHubResource.getId()); for (LogisticChainElement element : transshipmentHubResource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { @@ -89,16 +89,16 @@ private void addShipmentHandleElement(LspShipmentWithTime tuple) { + String.valueOf(handle.getLogisticChainElement().getId()) + handle.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getLspShipment().getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) .addPlanElement(id, handle); } - private void addShipmentToEventHandler(LspShipmentWithTime tuple) { + private void addShipmentToEventHandler(LspShipment tuple) { for (LogisticChainElement element : transshipmentHubResource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { LspShipmentPlan lspShipmentPlan = - LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, tuple.getLspShipment().getId()); - eventHandler.addShipment(tuple.getLspShipment(), element, lspShipmentPlan); + LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, tuple.getId()); + eventHandler.addShipment(tuple, element, lspShipmentPlan); break; } } diff --git a/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java b/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java index 700f969d..0318f1d1 100644 --- a/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java +++ b/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java @@ -60,4 +60,8 @@ public interface LspShipment Collection getRequirements(); + ///--- + double getTime(); + void setTime(double time); + } diff --git a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java index 4d0f48a5..7f498c4f 100644 --- a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java +++ b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java @@ -100,11 +100,23 @@ public Collection getRequirements() { return lspShipmentRequirements; } + @Override + public double getTime() { + return LspShipmentUtils.getTimeOfLspShipment(this); + } + + @Override + public void setTime(double time) { + LspShipmentUtils.setTimeOfLspShipment(this, time); + } + @Override public double getPickupServiceTime() { return pickupServiceTime; } + + @Override public String toString() { return "LSPShipmentImpl{" From a0f4e18eba89a46c7e639ba20d9f578b29b3c539 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:15:26 +0200 Subject: [PATCH 04/21] renaming --- .../logistics/LSPResourceScheduler.java | 26 +++++++++---------- .../CollectionCarrierScheduler.java | 4 +-- .../DistributionCarrierScheduler.java | 4 +-- .../MainRunCarrierScheduler.java | 4 +-- .../TransshipmentHubScheduler.java | 4 +-- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java index d43c77ba..68d8f6fb 100644 --- a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java @@ -41,20 +41,20 @@ public abstract class LSPResourceScheduler { protected LSPResource resource; - protected ArrayList lspShipmentsWithTime; + protected ArrayList lspShipmentsToScedule; protected LSPPlan lspPlan; public final void scheduleShipments(LSPPlan lspPlan, LSPResource resource, int bufferTime) { this.lspPlan = lspPlan; this.resource = resource; - this.lspShipmentsWithTime = new ArrayList<>(); + this.lspShipmentsToScedule = new ArrayList<>(); initializeValues(resource); presortIncomingShipments(); scheduleResource(); updateShipments(); switchHandledShipments(bufferTime); - lspShipmentsWithTime.clear(); + lspShipmentsToScedule.clear(); } /** @@ -79,27 +79,25 @@ public final void scheduleShipments(LSPPlan lspPlan, LSPResource resource, int b protected abstract void updateShipments(); private void presortIncomingShipments() { - this.lspShipmentsWithTime = new ArrayList<>(); + this.lspShipmentsToScedule = new ArrayList<>(); for (LogisticChainElement element : resource.getClientElements()) { - lspShipmentsWithTime.addAll(element.getIncomingShipments().getLspShipmentsWTime()); + lspShipmentsToScedule.addAll(element.getIncomingShipments().getLspShipmentsWTime()); } - lspShipmentsWithTime.sort(Comparator.comparingDouble(LspShipment::getTime)); + lspShipmentsToScedule.sort(Comparator.comparingDouble(LspShipment::getTime)); } private void switchHandledShipments(int bufferTime) { - for (LspShipment lspShipmentWithTime : lspShipmentsWithTime) { - var shipmentPlan = - LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId()); + for (LspShipment lspShipmentWithTime : lspShipmentsToScedule) { + var shipmentPlan = LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId()); double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime; - LspShipment outgoingLspShipment = lspShipmentWithTime; lspShipmentWithTime.setTime(endOfTransportTime); - for (LogisticChainElement element : resource.getClientElements()) { + for (LogisticChainElement element : resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipmentWithTime)) { - element.getOutgoingShipments().getLspShipmentsWTime().add(outgoingLspShipment); element.getIncomingShipments().getLspShipmentsWTime().remove(lspShipmentWithTime); + element.getOutgoingShipments().getLspShipmentsWTime().add(lspShipmentWithTime); if (element.getNextElement() != null) { - element.getNextElement().getIncomingShipments().getLspShipmentsWTime().add(outgoingLspShipment); - element.getOutgoingShipments().getLspShipmentsWTime().remove(outgoingLspShipment); + element.getNextElement().getIncomingShipments().getLspShipmentsWTime().add(lspShipmentWithTime); + element.getOutgoingShipments().getLspShipmentsWTime().remove(lspShipmentWithTime); } } } 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 0d514527..5563a290 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -74,7 +74,7 @@ public void initializeValues(LSPResource resource) { @Override public void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsWithTime) { + for (LspShipment tupleToBeAssigned : lspShipmentsToScedule) { CarrierService carrierService = convertToCarrierService(tupleToBeAssigned); carrier.getServices().put(carrierService.getId(), carrierService); } @@ -96,7 +96,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsWithTime) { + for (LspShipment tuple : lspShipmentsToScedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { 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 2e9703a3..8fd0ba62 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -85,7 +85,7 @@ protected void scheduleResource() { int load = 0; double cumulatedLoadingTime = 0; double availabilityTimeOfLastShipment = 0; - ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); + ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsToScedule); ArrayList shipmentsInCurrentTour = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); @@ -184,7 +184,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsWithTime) { + for (LspShipment tuple : lspShipmentsToScedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { 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 ada47ff5..e90f016b 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -77,7 +77,7 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { int load = 0; - List copyOfAssignedShipments = new ArrayList<>(lspShipmentsWithTime); + List copyOfAssignedShipments = new ArrayList<>(lspShipmentsToScedule); copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipment::getTime)); ArrayList shipmentsInCurrentTour = new ArrayList<>(); // ArrayList scheduledTours = new ArrayList<>(); @@ -235,7 +235,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment LspShipment : lspShipmentsWithTime) { + for (LspShipment LspShipment : lspShipmentsToScedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index 94c3a8dc..88842d28 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -43,7 +43,7 @@ private TransshipmentHubTourEndEventHandler eventHandler; TransshipmentHubScheduler(TranshipmentHubSchedulerBuilder builder) { - this.lspShipmentsWithTime = new ArrayList<>(); + this.lspShipmentsToScedule = new ArrayList<>(); this.capacityNeedLinear = builder.getCapacityNeedLinear(); this.capacityNeedFixed = builder.getCapacityNeedFixed(); } @@ -55,7 +55,7 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsWithTime) { + for (LspShipment tupleToBeAssigned : lspShipmentsToScedule) { updateSchedule(tupleToBeAssigned); } } From caa9e3850cfecf7937c26b71d34368423e9647d1 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:17:53 +0200 Subject: [PATCH 05/21] IMO, after scheduling, the outgoingElements must contain the shipment. --- .../resourceImplementations/FirstReloadLSPSchedulingTest.java | 4 ++-- .../MultipleShipmentsFirstReloadLSPSchedulingTest.java | 4 ++-- .../MultipleShipmentsSecondReloadLSPSchedulingTest.java | 4 ++-- .../SecondReloadLSPSchedulingTest.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 907bf933..72a707de 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -270,8 +270,8 @@ public void testFirstReloadLSPScheduling() { } } assertTrue(handledByTranshipmentHub); - //This asserts that the shipments waiting for handling have been handled and the queues have been cleared - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index 28fc6df2..d0836995 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -269,8 +269,8 @@ public void testFirstReloadLSPScheduling() { } } assertTrue(handledByTranshipmentHub); - //This asserts that the shipments waiting for handling have been handled and the queues have been cleared - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } 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 0d0fa0c0..2571fadb 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -379,7 +379,7 @@ public void testSecondReloadLSPScheduling() { } assertTrue(handledByTranshipmentHub); - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } @@ -406,7 +406,7 @@ public void testSecondReloadLSPScheduling() { } assertTrue(handledByTranshipmentHub); - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } 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 3fc5b72d..1b865281 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -379,7 +379,7 @@ public void testSecondReloadLSPScheduling() { } assertTrue(handledByTranshipmentHub); - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } @@ -406,7 +406,7 @@ public void testSecondReloadLSPScheduling() { } assertTrue(handledByTranshipmentHub); - assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); } From 37ffad79badf32b310f9f0e44474c80929c24e4b Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:20:05 +0200 Subject: [PATCH 06/21] simplify calls --- .../adapterTests/CollectionResourceTest.java | 4 +-- .../DistributionResourceTest.java | 4 +-- .../adapterTests/MainRunResourceTest.java | 4 +-- .../CollectionLSPReplanningTest.java | 2 +- .../lspScoring/CollectionLSPScoringTest.java | 2 +- ...pleIterationsCollectionLSPScoringTest.java | 2 +- .../MultipleChainsReplanningTest.java | 2 +- .../AssignerRequirementsTest.java | 2 +- .../CollectionTrackerTest.java | 2 +- .../CollectionLSPMobsimTest.java | 2 +- .../lspMobsimTests/CompleteLSPMobsimTest.java | 4 +-- .../FirstAndSecondReloadLSPMobsimTest.java | 4 +-- .../FirstReloadLSPMobsimTest.java | 4 +-- .../lspMobsimTests/MainRunLSPMobsimTest.java | 4 +-- .../MainRunOnlyLSPMobsimTest.java | 4 +-- ...ipleIterationsCollectionLSPMobsimTest.java | 2 +- ...ltipleIterationsCompleteLSPMobsimTest.java | 4 +-- ...ionsFirstAndSecondReloadLSPMobsimTest.java | 4 +-- ...pleIterationsFirstReloadLSPMobsimTest.java | 4 +-- ...ultipleIterationsMainRunLSPMobsimTest.java | 4 +-- ...tipleShipmentsCollectionLSPMobsimTest.java | 2 +- ...ultipleShipmentsCompleteLSPMobsimTest.java | 4 +-- ...entsFirstAndSecondReloadLSPMobsimTest.java | 4 +-- ...ipleShipmentsFirstReloadLSPMobsimTest.java | 4 +-- ...MultipleShipmentsMainRunLSPMobsimTest.java | 4 +-- ...ultipleShipmentsCompleteLSPMobsimTest.java | 4 +-- .../CollectionLspShipmentAssigmentTest.java | 2 +- .../CompleteLspShipmentAssignerTest.java | 4 +-- .../CollectionShipmentBuilderTest.java | 2 +- .../CompleteShipmentBuilderTest.java | 4 +-- .../DistributionShipmentBuilderTest.java | 2 +- .../CollectionLSPSchedulingTest.java | 12 +++---- .../CompleteLSPSchedulingTest.java | 36 +++++++++---------- .../FirstReloadLSPSchedulingTest.java | 28 +++++++-------- .../MainRunLSPSchedulingTest.java | 32 ++++++++--------- ...eShipmentsCollectionLSPSchedulingTest.java | 12 +++---- ...pleShipmentsCompleteLSPSchedulingTest.java | 36 +++++++++---------- ...ShipmentsFirstReloadLSPSchedulingTest.java | 28 +++++++-------- ...ipleShipmentsMainRunLSPSchedulingTest.java | 32 ++++++++--------- ...hipmentsSecondReloadLSPSchedulingTest.java | 36 +++++++++---------- .../SecondReloadLSPSchedulingTest.java | 36 +++++++++---------- 41 files changed, 194 insertions(+), 194 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index 1d60b887..a1543516 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -114,7 +114,7 @@ public void testCollectionResource() { assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { - assertSame(types.get(0), collectionType); + assertSame(types.getFirst(), collectionType); assertEquals(10, collectionType.getCapacity().getOther().intValue()); assertEquals(0.0004, collectionType.getCostInformation().getCostsPerMeter(), 0.0); assertEquals(0.38, collectionType.getCostInformation().getCostsPerSecond(), 0.0); @@ -124,7 +124,7 @@ public void testCollectionResource() { } ArrayList vehicles = new ArrayList<>(capabilities.getCarrierVehicles().values()); if (vehicles.size() == 1) { - assertSame(vehicles.get(0), collectionCarrierVehicle); + assertSame(vehicles.getFirst(), collectionCarrierVehicle); assertSame(collectionCarrierVehicle.getType(), collectionType); assertSame(collectionCarrierVehicle.getLinkId(), collectionLinkId); } diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index a4db475d..7f97fe64 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -118,7 +118,7 @@ public void testCollectionResource() { assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { - assertSame(types.get(0), distributionType); + assertSame(types.getFirst(), distributionType); assertEquals(10, distributionType.getCapacity().getOther().intValue()); assertEquals(0.0004, distributionType.getCostInformation().getCostsPerMeter(), 0.0); assertEquals(0.38, distributionType.getCostInformation().getCostsPerSecond(), 0.0); @@ -128,7 +128,7 @@ public void testCollectionResource() { } ArrayList vehicles = new ArrayList<>(capabilities.getCarrierVehicles().values()); if (vehicles.size() == 1) { - assertSame(vehicles.get(0), distributionCarrierVehicle); + assertSame(vehicles.getFirst(), distributionCarrierVehicle); assertSame(distributionCarrierVehicle.getType(), distributionType); assertSame(distributionCarrierVehicle.getLinkId(), distributionLinkId); } diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 5dfe0fce..9a54da10 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -116,7 +116,7 @@ public void testMainRunResource() { assertFalse(capabilities.getVehicleTypes().isEmpty()); ArrayList types = new ArrayList<>(capabilities.getVehicleTypes()); if (types.size() == 1) { - assertSame(types.get(0), mainRunType); + assertSame(types.getFirst(), mainRunType); assertEquals(30, mainRunType.getCapacity().getOther().intValue()); assertEquals(0.0008, mainRunType.getCostInformation().getCostsPerMeter(), 0.0); assertEquals(0.38, mainRunType.getCostInformation().getCostsPerSecond(), 0.0); @@ -125,7 +125,7 @@ public void testMainRunResource() { } ArrayList vehicles = new ArrayList<>(capabilities.getCarrierVehicles().values()); if (vehicles.size() == 1) { - assertSame(vehicles.get(0), carrierVehicle); + assertSame(vehicles.getFirst(), carrierVehicle); assertSame(carrierVehicle.getType(), mainRunType); assertSame(carrierVehicle.getLinkId(), fromLinkId); } diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java index fb34b02e..5068c98c 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java @@ -157,7 +157,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index a4bba784..f165eb84 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -116,7 +116,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java index e9ad8611..7423567c 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java @@ -143,7 +143,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java index fb13ae0c..e9ca9469 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java @@ -249,7 +249,7 @@ public void install() { LSP lsp = LSPUtils.getLSPs(controler.getScenario()).getLSPs().values().iterator().next(); initialPlanCount = lsp.getPlans().size(); - initialPlanShipmentPlanCount = lsp.getPlans().get(0).getShipmentPlans().size(); + initialPlanShipmentPlanCount = lsp.getPlans().getFirst().getShipmentPlans().size(); controler.run(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index 4e1c2b3f..7a175216 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -171,7 +171,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index a21406e5..4b9945e5 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -158,7 +158,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java index 4419384b..d3d8a293 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java @@ -155,7 +155,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java index 1988bcec..ffc2f870 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java @@ -246,7 +246,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -261,7 +261,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java index 2b6e7a76..efe494a3 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java @@ -218,7 +218,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -233,7 +233,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java index d8fdf860..48b9f52a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java @@ -162,7 +162,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -177,7 +177,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java index 7d4e9723..e6602073 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java @@ -194,7 +194,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -209,7 +209,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java index ecc10a2a..62b222b5 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java @@ -140,7 +140,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -155,7 +155,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java index 66960b3e..b1c3628c 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java @@ -144,7 +144,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java index 8f8c8a04..81d2d937 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java @@ -260,7 +260,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -275,7 +275,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java index 391ca626..e22de9f6 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java @@ -224,7 +224,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -239,7 +239,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java index c5bb82b0..88321f48 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java @@ -166,7 +166,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -181,7 +181,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java index 1a6fa2f4..7a6ffec7 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java @@ -202,7 +202,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -217,7 +217,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java index fb6f8f90..4f3b2711 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java @@ -139,7 +139,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java index f6f3960a..22df4df0 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java @@ -263,7 +263,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -278,7 +278,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java index fd7a39fb..dcc82858 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java @@ -223,7 +223,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -238,7 +238,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java index da82b7cf..d81d3a22 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java @@ -162,7 +162,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -177,7 +177,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java index e160cc96..b8037a03 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java @@ -196,7 +196,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -211,7 +211,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java index adbecdef..d20cb939 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java @@ -254,7 +254,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -269,7 +269,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, MatsimRandom.getRandom()); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java index fbe1c7f3..30afaeba 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java @@ -120,7 +120,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java index 0dc32141..c64a5c1f 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java @@ -233,7 +233,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -248,7 +248,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CollectionShipmentBuilderTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CollectionShipmentBuilderTest.java index 7e886f5a..11957dbf 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CollectionShipmentBuilderTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CollectionShipmentBuilderTest.java @@ -64,7 +64,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CompleteShipmentBuilderTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CompleteShipmentBuilderTest.java index ad1fd3ea..cb3ea748 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CompleteShipmentBuilderTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/CompleteShipmentBuilderTest.java @@ -61,7 +61,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -76,7 +76,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/DistributionShipmentBuilderTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/DistributionShipmentBuilderTest.java index aaaa3966..380a86b9 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentTest/DistributionShipmentBuilderTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentTest/DistributionShipmentBuilderTest.java @@ -64,7 +64,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 76b370b3..6b381d7e 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -123,7 +123,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -186,15 +186,15 @@ public void testCollectionLSPScheduling() { assertEquals(planElements.get(1).getStartTime(), planElements.get(0).getEndTime(), 0.0); assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 0700e202..3593cae3 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -247,7 +247,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -262,7 +262,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -418,18 +418,18 @@ public void testCompletedLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -455,8 +455,8 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -486,8 +486,8 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -495,12 +495,12 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(endHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(endHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(endHandler.getLspShipment(), shipment); assertSame(endHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(endHandler.getResourceId(), resources.get(0).getId()); + assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -512,12 +512,12 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(serviceHandler.getElement(), solutionElements.get(0)); + assertSame(serviceHandler.getElement(), solutionElements.getFirst()); assertSame(serviceHandler.getLspShipment(), shipment); assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); + assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 72a707de..11caf4ab 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -149,7 +149,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -164,7 +164,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -241,19 +241,19 @@ public void testFirstReloadLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { CarrierService service = entry.getKey(); @@ -281,8 +281,8 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -299,10 +299,10 @@ public void testFirstReloadLSPScheduling() { assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); - assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); + assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); - assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); + assertSame(serviceHandler.getResourceId(), planElements.getFirst().getResourceId()); assertSame(serviceHandler.getResourceId(), lsp.getResources().iterator().next().getId()); } 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 f6ba4882..b604fc96 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -184,7 +184,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -199,7 +199,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -309,18 +309,18 @@ public void testMainRunLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { CarrierService service = entry.getKey(); @@ -350,8 +350,8 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -359,12 +359,12 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(endHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(endHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(endHandler.getLspShipment(), shipment); assertSame(endHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(endHandler.getResourceId(), resources.get(0).getId()); + assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -376,12 +376,12 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(serviceHandler.getElement(), solutionElements.get(0)); + assertSame(serviceHandler.getElement(), solutionElements.getFirst()); assertSame(serviceHandler.getLspShipment(), shipment); assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); + assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index 2d361882..3507e56a 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -126,7 +126,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, random); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -189,15 +189,15 @@ public void testCollectionLSPScheduling() { assertEquals(planElements.get(1).getStartTime(), planElements.get(0).getEndTime(), 0.0); assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 a923362b..14fd9f71 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -250,7 +250,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -265,7 +265,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList, rand); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -421,18 +421,18 @@ public void testCompletedLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -458,8 +458,8 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -489,8 +489,8 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -498,12 +498,12 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(endHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(endHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(endHandler.getLspShipment(), shipment); assertSame(endHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(endHandler.getResourceId(), resources.get(0).getId()); + assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -515,12 +515,12 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(serviceHandler.getElement(), solutionElements.get(0)); + assertSame(serviceHandler.getElement(), solutionElements.getFirst()); assertSame(serviceHandler.getLspShipment(), shipment); assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); + assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index d0836995..cf01e31f 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -148,7 +148,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -163,7 +163,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -240,19 +240,19 @@ public void testFirstReloadLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { CarrierService service = entry.getKey(); @@ -280,8 +280,8 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -298,10 +298,10 @@ public void testFirstReloadLSPScheduling() { assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(serviceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); assertSame(serviceHandler.getCarrierService().getServiceStartTimeWindow(), shipment.getPickupTimeWindow()); - assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); + assertSame(serviceHandler.getElement(), planElements.getFirst().getLogisticChainElement()); assertSame(serviceHandler.getElement(), lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements().iterator().next()); assertSame(serviceHandler.getLspShipment(), shipment); - assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); + assertSame(serviceHandler.getResourceId(), planElements.getFirst().getResourceId()); assertSame(serviceHandler.getResourceId(), lsp.getResources().iterator().next().getId()); } 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 b530b0cd..dba0cc94 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -184,7 +184,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -199,7 +199,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -309,18 +309,18 @@ public void testMainRunLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { CarrierService service = entry.getKey(); @@ -350,8 +350,8 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(endHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -359,12 +359,12 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(endHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(endHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(endHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(endHandler.getLspShipment(), shipment); assertSame(endHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(endHandler.getResourceId(), resources.get(0).getId()); + assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -376,12 +376,12 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(serviceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(serviceHandler.getElement(), solutionElements.get(0)); + assertSame(serviceHandler.getElement(), solutionElements.getFirst()); assertSame(serviceHandler.getLspShipment(), shipment); assertSame(serviceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(serviceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(serviceHandler.getResourceId(), resources.get(0).getId()); + assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); 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 2571fadb..f215df75 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -213,7 +213,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -228,7 +228,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -348,18 +348,18 @@ public void testSecondReloadLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -385,8 +385,8 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -419,8 +419,8 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -428,12 +428,12 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(collectionEndHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(collectionEndHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(collectionEndHandler.getLspShipment(), shipment); assertSame(collectionEndHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(collectionEndHandler.getResourceId(), resources.get(0).getId()); + assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -445,12 +445,12 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(collectionServiceHandler.getElement(), solutionElements.get(0)); + assertSame(collectionServiceHandler.getElement(), solutionElements.getFirst()); assertSame(collectionServiceHandler.getLspShipment(), shipment); assertSame(collectionServiceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(collectionServiceHandler.getResourceId(), resources.get(0).getId()); + assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); 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 1b865281..92856a25 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -213,7 +213,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingToLink = linkList.get(0); + Link pendingToLink = linkList.getFirst(); if ((pendingToLink.getFromNode().getCoord().getX() <= 18000 && pendingToLink.getFromNode().getCoord().getY() <= 4000 && pendingToLink.getFromNode().getCoord().getX() >= 14000 && @@ -228,7 +228,7 @@ public void initialize() { while (true) { Collections.shuffle(linkList); - Link pendingFromLink = linkList.get(0); + Link pendingFromLink = linkList.getFirst(); if (pendingFromLink.getFromNode().getCoord().getX() <= 4000 && pendingFromLink.getFromNode().getCoord().getY() <= 4000 && pendingFromLink.getToNode().getCoord().getX() <= 4000 && @@ -348,18 +348,18 @@ public void testSecondReloadLSPScheduling() { assertEquals("LOAD", planElements.get(0).getElementType()); assertTrue(planElements.get(0).getEndTime() >= (0)); - assertTrue(planElements.get(0).getEndTime() <= (24*3600)); - assertTrue(planElements.get(0).getStartTime() <= planElements.get(0).getEndTime()); - assertTrue(planElements.get(0).getStartTime() >= (0)); - assertTrue(planElements.get(0).getStartTime() <= (24*3600)); - assertSame(planElements.get(0).getResourceId(), collectionResource.getId()); - assertSame(planElements.get(0).getLogisticChainElement(), collectionElement); + assertTrue(planElements.getFirst().getEndTime() <= (24*3600)); + assertTrue(planElements.getFirst().getStartTime() <= planElements.getFirst().getEndTime()); + assertTrue(planElements.getFirst().getStartTime() >= (0)); + assertTrue(planElements.getFirst().getStartTime() <= (24*3600)); + assertSame(planElements.getFirst().getResourceId(), collectionResource.getId()); + assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -385,8 +385,8 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.iterator().next() instanceof TransshipmentHubTourEndEventHandler); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.iterator().next(); + assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); while (iter.hasNext()) { @@ -419,8 +419,8 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.get(0) instanceof LSPTourEndEventHandler); - LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.get(0); + assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); assertEquals(collectionEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -428,12 +428,12 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionEndHandler.getLogisticChainElement(), planElements.get(2).getLogisticChainElement()); - assertSame(collectionEndHandler.getLogisticChainElement(), solutionElements.get(0)); + assertSame(collectionEndHandler.getLogisticChainElement(), solutionElements.getFirst()); assertSame(collectionEndHandler.getLspShipment(), shipment); assertSame(collectionEndHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionEndHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(collectionEndHandler.getResourceId(), resources.get(0).getId()); + assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); @@ -445,12 +445,12 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getElement(), planElements.get(0).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(1).getLogisticChainElement()); assertSame(collectionServiceHandler.getElement(), planElements.get(2).getLogisticChainElement()); - assertSame(collectionServiceHandler.getElement(), solutionElements.get(0)); + assertSame(collectionServiceHandler.getElement(), solutionElements.getFirst()); assertSame(collectionServiceHandler.getLspShipment(), shipment); assertSame(collectionServiceHandler.getResourceId(), planElements.get(0).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(1).getResourceId()); assertSame(collectionServiceHandler.getResourceId(), planElements.get(2).getResourceId()); - assertSame(collectionServiceHandler.getResourceId(), resources.get(0).getId()); + assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); From a1024e0553a75e968df4600900fc98268ec3f22c Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:20:40 +0200 Subject: [PATCH 07/21] simplify assertions --- .../AssignerRequirementsTest.java | 5 +++-- .../CollectionTrackerTest.java | 7 +++---- .../CollectionLSPSchedulingTest.java | 4 ++-- .../CompleteLSPSchedulingTest.java | 16 ++++++++-------- .../FirstReloadLSPSchedulingTest.java | 6 +++--- .../MainRunLSPSchedulingTest.java | 10 +++++----- ...ipleShipmentsCollectionLSPSchedulingTest.java | 4 ++-- ...ltipleShipmentsCompleteLSPSchedulingTest.java | 16 ++++++++-------- ...pleShipmentsFirstReloadLSPSchedulingTest.java | 6 +++--- ...ultipleShipmentsMainRunLSPSchedulingTest.java | 10 +++++----- ...leShipmentsSecondReloadLSPSchedulingTest.java | 12 ++++++------ .../SecondReloadLSPSchedulingTest.java | 12 ++++++------ 12 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index 7a175216..a19ddce7 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -42,6 +42,7 @@ package org.matsim.freight.logistics.examples.requirementsChecking; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; @@ -203,11 +204,11 @@ public void initialize() { public void testAssignerRequirements() { for (Id shipmentId : blueChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(blueChain.getLSP(), shipmentId); - assertTrue(shipment.getRequirements().iterator().next() instanceof BlueRequirement); + assertInstanceOf(BlueRequirement.class, shipment.getRequirements().iterator().next()); } for (Id shipmentId : redChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(redChain.getLSP(), shipmentId); - assertTrue(shipment.getRequirements().iterator().next() instanceof RedRequirement); + assertInstanceOf(RedRequirement.class, shipment.getRequirements().iterator().next()); } } diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index 4b9945e5..76ec9466 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -21,9 +21,6 @@ package org.matsim.freight.logistics.examples.simulationTrackers; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.util.*; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -58,6 +55,8 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +import static org.junit.jupiter.api.Assertions.*; + public class CollectionTrackerTest { private static final Logger log = LogManager.getLogger(CollectionTrackerTest.class); @RegisterExtension @@ -209,7 +208,7 @@ public void testCollectionTracker() { assertEquals(1, logisticChain.getSimulationTrackers().size()); LSPSimulationTracker tracker = logisticChain.getSimulationTrackers().iterator().next(); - assertTrue(tracker instanceof LinearCostTracker); + assertInstanceOf(LinearCostTracker.class, tracker); LinearCostTracker linearTracker = (LinearCostTracker) tracker; double totalScheduledCosts = 0; double totalTrackedCosts = 0; diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 6b381d7e..41b00365 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -193,7 +193,7 @@ public void testCollectionLSPScheduling() { assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -205,7 +205,7 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 3593cae3..01ac0685 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -428,7 +428,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -455,7 +455,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -486,7 +486,7 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -503,7 +503,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -520,7 +520,7 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -538,7 +538,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -556,7 +556,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); //DistributionRunStart - assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -574,7 +574,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); //DistributionServiceStart - assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); + assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index 11caf4ab..d79f3141 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -252,7 +252,7 @@ public void testFirstReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -281,7 +281,7 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -293,7 +293,7 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), lsp.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 b604fc96..5909c999 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -319,7 +319,7 @@ public void testMainRunLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -367,7 +367,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -384,7 +384,7 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -402,7 +402,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunTourEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index 3507e56a..e4f84cd4 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -196,7 +196,7 @@ public void testCollectionLSPScheduling() { assertEquals(2, shipment.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -208,7 +208,7 @@ public void testCollectionLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), collectionLSP.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 14fd9f71..ec2ed677 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -431,7 +431,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -458,7 +458,7 @@ public void testCompletedLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -489,7 +489,7 @@ public void testCompletedLSPScheduling() { ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -506,7 +506,7 @@ public void testCompletedLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -523,7 +523,7 @@ public void testCompletedLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -541,7 +541,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunTourEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -559,7 +559,7 @@ public void testCompletedLSPScheduling() { assertSame(mainRunEndHandler.getResourceId(), resources.get(2).getId()); //DistributionTourStart - assertTrue(eventHandlers.get(4) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(4)); LSPTourStartEventHandler lspTourStartEventHandler = (LSPTourStartEventHandler) eventHandlers.get(4); assertSame(lspTourStartEventHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(lspTourStartEventHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -577,7 +577,7 @@ public void testCompletedLSPScheduling() { assertSame(lspTourStartEventHandler.getResourceId(), resources.get(4).getId()); //DistributionServiceStart - assertTrue(eventHandlers.get(5) instanceof DistributionServiceStartEventHandler); + assertInstanceOf(DistributionServiceStartEventHandler.class, eventHandlers.get(5)); DistributionServiceStartEventHandler distributionServiceHandler = (DistributionServiceStartEventHandler) eventHandlers.get(5); assertSame(distributionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getTo()); assertEquals(distributionServiceHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index cf01e31f..30507398 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -251,7 +251,7 @@ public void testFirstReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -280,7 +280,7 @@ public void testFirstReloadLSPScheduling() { eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -292,7 +292,7 @@ public void testFirstReloadLSPScheduling() { assertSame(endHandler.getResourceId(), planElements.get(2).getResourceId()); assertSame(endHandler.getResourceId(), lsp.getResources().iterator().next().getId()); - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); 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 dba0cc94..205d0022 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -319,7 +319,7 @@ public void testMainRunLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); for (Entry entry : reloadEventHandler.getServicesWaitedFor().entrySet()) { @@ -350,7 +350,7 @@ public void testMainRunLSPScheduling() { ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); ArrayList resources = new ArrayList<>(lsp.getResources()); - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler endHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(endHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(endHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -367,7 +367,7 @@ public void testMainRunLSPScheduling() { assertSame(endHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler serviceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(serviceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(serviceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -384,7 +384,7 @@ public void testMainRunLSPScheduling() { assertSame(serviceHandler.getResourceId(), resources.getFirst().getId()); //MainRunTourStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -402,7 +402,7 @@ public void testMainRunLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 f215df75..6fa3888e 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -358,7 +358,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -385,7 +385,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -419,7 +419,7 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -436,7 +436,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -453,7 +453,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -471,7 +471,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); 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 92856a25..e1440539 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -358,7 +358,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -385,7 +385,7 @@ public void testSecondReloadLSPScheduling() { assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertTrue(eventHandlers.getFirst() instanceof TransshipmentHubTourEndEventHandler); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); @@ -419,7 +419,7 @@ public void testSecondReloadLSPScheduling() { ArrayList resources = new ArrayList<>(lsp.getResources()); //CollectionTourEnd - assertTrue(eventHandlers.getFirst() instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.getFirst()); LSPTourEndEventHandler collectionEndHandler = (LSPTourEndEventHandler) eventHandlers.getFirst(); assertSame(collectionEndHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionEndHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -436,7 +436,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionEndHandler.getResourceId(), resources.getFirst().getId()); //CollectionServiceEnd - assertTrue(eventHandlers.get(1) instanceof CollectionServiceEndEventHandler); + assertInstanceOf(CollectionServiceEndEventHandler.class, eventHandlers.get(1)); CollectionServiceEndEventHandler collectionServiceHandler = (CollectionServiceEndEventHandler) eventHandlers.get(1); assertSame(collectionServiceHandler.getCarrierService().getLocationLinkId(), shipment.getFrom()); assertEquals(collectionServiceHandler.getCarrierService().getCapacityDemand(), shipment.getSize()); @@ -453,7 +453,7 @@ public void testSecondReloadLSPScheduling() { assertSame(collectionServiceHandler.getResourceId(), resources.getFirst().getId()); //MainRunStart - assertTrue(eventHandlers.get(2) instanceof LSPTourStartEventHandler); + assertInstanceOf(LSPTourStartEventHandler.class, eventHandlers.get(2)); LSPTourStartEventHandler mainRunStartHandler = (LSPTourStartEventHandler) eventHandlers.get(2); assertSame(mainRunStartHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunStartHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); @@ -471,7 +471,7 @@ public void testSecondReloadLSPScheduling() { assertSame(mainRunStartHandler.getResourceId(), resources.get(2).getId()); //MainRunEnd - assertTrue(eventHandlers.get(3) instanceof LSPTourEndEventHandler); + assertInstanceOf(LSPTourEndEventHandler.class, eventHandlers.get(3)); LSPTourEndEventHandler mainRunEndHandler = (LSPTourEndEventHandler) eventHandlers.get(3); assertSame(mainRunEndHandler.getCarrierService().getLocationLinkId(), toLinkId); assertEquals(mainRunEndHandler.getCarrierService().getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); From cfdd81d1c3d929f84879ae37ead73e87aa7a92cc Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:21:18 +0200 Subject: [PATCH 08/21] parameterized logging --- .../examples/simulationTrackers/CollectionTrackerTest.java | 2 +- .../lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index 76ec9466..6b16b5c1 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -280,7 +280,7 @@ public void testCollectionTracker() { // (yy I do not understand why we do not need to do this for the end activity of the tour.) } } - log.warn("scheduledDistanceCosts=" + scheduledDistanceCosts); + log.warn("scheduledDistanceCosts={}", scheduledDistanceCosts); } totalScheduledCosts += scheduledDistanceCosts; assertEquals(scheduledDistanceCosts, trackedDistanceCosts, Math.max(scheduledDistanceCosts, trackedDistanceCosts) * 0.01); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java index 22df4df0..3217baa3 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java @@ -338,7 +338,7 @@ public void initialize() { @Test public void testCompleteLSPMobsim() { for (LspShipment shipment : completeLSP.getLspShipments()) { - log.info("comparing shipment: " + shipment.getId()); + log.info("comparing shipment: {}", shipment.getId()); assertFalse(shipment.getShipmentLog().getPlanElements().isEmpty()); ArrayList scheduleElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(completeLSP.getSelectedPlan(), shipment.getId()).getPlanElements().values()); scheduleElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); From aa704b48c475ab50a7b19af03b6df440545c77a6 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:31:56 +0200 Subject: [PATCH 09/21] remove deprecated setting of vehType --- .../logistics/adapterTests/CollectionResourceTest.java | 1 - .../logistics/adapterTests/DistributionResourceTest.java | 1 - .../logistics/adapterTests/MainRunResourceTest.java | 1 - .../lspReplanning/CollectionLSPReplanningTest.java | 1 - .../examples/lspScoring/CollectionLSPScoringTest.java | 5 ++++- .../MultipleIterationsCollectionLSPScoringTest.java | 1 - .../requirementsChecking/AssignerRequirementsTest.java | 2 -- .../examples/simulationTrackers/CollectionTrackerTest.java | 1 - .../logisticChainElementTests/CollectionElementTest.java | 1 - .../logisticChainElementTests/MainRunElementTest.java | 1 - .../logistics/logisticChainTests/CollectionChainTest.java | 1 - .../logisticChainTests/CompleteLogisticChainTest.java | 3 --- .../lspCreationTests/CollectionLSPCreationTest.java | 1 - .../lspCreationTests/CompleteLSPCreationTest.java | 3 --- .../logistics/lspMobsimTests/CollectionLSPMobsimTest.java | 1 - .../logistics/lspMobsimTests/CompleteLSPMobsimTest.java | 3 --- .../lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java | 2 -- .../logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java | 1 - .../logistics/lspMobsimTests/MainRunLSPMobsimTest.java | 2 -- .../logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java | 1 - .../MultipleIterationsCollectionLSPMobsimTest.java | 1 - .../MultipleIterationsCompleteLSPMobsimTest.java | 3 --- ...ultipleIterationsFirstAndSecondReloadLSPMobsimTest.java | 2 -- .../MultipleIterationsFirstReloadLSPMobsimTest.java | 1 - .../MultipleIterationsMainRunLSPMobsimTest.java | 3 +-- .../MultipleShipmentsCollectionLSPMobsimTest.java | 1 - .../MultipleShipmentsCompleteLSPMobsimTest.java | 7 ++----- ...MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java | 4 +--- .../MultipleShipmentsFirstReloadLSPMobsimTest.java | 1 - .../MultipleShipmentsMainRunLSPMobsimTest.java | 2 -- .../RepeatedMultipleShipmentsCompleteLSPMobsimTest.java | 3 --- .../logistics/lspPlanTests/CollectionLSPPlanTest.java | 1 - .../logistics/lspPlanTests/CompleteLSPPlanTest.java | 3 --- .../CollectionLspShipmentAssigmentTest.java | 1 - .../CompleteLspShipmentAssignerTest.java | 3 --- .../CollectionLSPSchedulingTest.java | 1 - .../resourceImplementations/CompleteLSPSchedulingTest.java | 3 --- .../FirstReloadLSPSchedulingTest.java | 1 - .../resourceImplementations/MainRunLSPSchedulingTest.java | 2 -- .../MultipleShipmentsCollectionLSPSchedulingTest.java | 1 - .../MultipleShipmentsCompleteLSPSchedulingTest.java | 3 --- .../MultipleShipmentsFirstReloadLSPSchedulingTest.java | 1 - .../MultipleShipmentsMainRunLSPSchedulingTest.java | 2 -- .../MultipleShipmentsSecondReloadLSPSchedulingTest.java | 2 -- .../SecondReloadLSPSchedulingTest.java | 2 -- 45 files changed, 8 insertions(+), 79 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index a1543516..5711bf84 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -74,7 +74,6 @@ public void initialize() { collectionCarrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(collectionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 7f97fe64..69dd7836 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -75,7 +75,6 @@ public void initialize() { distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 9a54da10..777eb871 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -75,7 +75,6 @@ public void initialize() { CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(mainRunType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java index 5068c98c..2e0b80c5 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java @@ -106,7 +106,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index f165eb84..5fe09bbe 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -77,7 +77,10 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionVehicleType); Carrier carrier = CarriersUtils.createCarrier(Id.create("CollectionCarrier", Carrier.class)); - carrier.setCarrierCapabilities(CarrierCapabilities.Builder.newInstance().addType(collectionVehicleType).addVehicle(carrierVehicle).setFleetSize(FleetSize.INFINITE).build()); + carrier.setCarrierCapabilities(CarrierCapabilities.Builder.newInstance() + .addVehicle(carrierVehicle) + .setFleetSize(FleetSize.INFINITE) + .build()); LSPResource collectionResource = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier) .setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)).setLocationLinkId(collectionLink.getId()).build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java index 7423567c..2910e9dc 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java @@ -93,7 +93,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index a19ddce7..063ebf65 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -95,7 +95,6 @@ public void initialize() { CarrierVehicle redVehicle = CarrierVehicle.newInstance(redVehicleId, collectionLinkId, collectionType); CarrierCapabilities redCapabilities = CarrierCapabilities.Builder.newInstance() - .addType(collectionType) .addVehicle(redVehicle) .setFleetSize(FleetSize.INFINITE) .build(); @@ -127,7 +126,6 @@ public void initialize() { CarrierVehicle blueVehicle = CarrierVehicle.newInstance(blueVehicleId, collectionLinkId, collectionType); CarrierCapabilities blueCapabilities = CarrierCapabilities.Builder.newInstance() - .addType(collectionType) .addVehicle(blueVehicle) .setFleetSize(FleetSize.INFINITE) .build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index 6b16b5c1..de622ebd 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -96,7 +96,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java index e8681b29..8c4dea37 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java @@ -67,7 +67,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java index 5a7fe385..a9c0d3c6 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java @@ -71,7 +71,6 @@ public void initialize() { CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(mainRunType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java index 4c8ea5b5..8d417335 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java @@ -67,7 +67,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java index 13afaa97..ba69e76f 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java @@ -79,7 +79,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -127,7 +126,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("MainRunVehicle"), fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = collectionCapabilitiesBuilder.build(); @@ -180,7 +178,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java index 75401fa5..5d8db51f 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java @@ -68,7 +68,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java index 1a8600d6..93bc4ddb 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java @@ -70,7 +70,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -119,7 +118,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = collectionCapabilitiesBuilder.build(); @@ -169,7 +167,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java index d3d8a293..c8e99e94 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java @@ -100,7 +100,6 @@ public void initialize() { // define carrier: Id carrierId = Id.create("CollectionCarrier", Carrier.class); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java index ffc2f870..7e435277 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CompleteLSPMobsimTest.java @@ -86,7 +86,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -135,7 +134,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -185,7 +183,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java index efe494a3..79e2751f 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstAndSecondReloadLSPMobsimTest.java @@ -90,7 +90,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -141,7 +140,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java index 48b9f52a..7155658e 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/FirstReloadLSPMobsimTest.java @@ -91,7 +91,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java index e6602073..9022a2d9 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunLSPMobsimTest.java @@ -90,7 +90,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -139,7 +138,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java index 62b222b5..961f9020 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MainRunOnlyLSPMobsimTest.java @@ -89,7 +89,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java index b1c3628c..208cf65a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java @@ -93,7 +93,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java index 81d2d937..0e25899e 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCompleteLSPMobsimTest.java @@ -95,7 +95,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -146,7 +145,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -196,7 +194,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java index e22de9f6..534b5552 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java @@ -96,7 +96,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -147,7 +146,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java index 88321f48..96e68e1e 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstReloadLSPMobsimTest.java @@ -94,7 +94,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java index 7a6ffec7..9a25f460 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsMainRunLSPMobsimTest.java @@ -60,6 +60,7 @@ import org.matsim.vehicles.Vehicle; import org.matsim.vehicles.VehicleType; +@SuppressWarnings("ALL") public class MultipleIterationsMainRunLSPMobsimTest { @RegisterExtension @@ -95,7 +96,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -146,7 +146,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java index 4f3b2711..9bf7a021 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java @@ -88,7 +88,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLink.getId(), collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java index 3217baa3..1f6257e3 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCompleteLSPMobsimTest.java @@ -98,7 +98,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -149,7 +148,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -199,7 +197,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); @@ -308,10 +305,10 @@ public void initialize() { LSPUtils.addLSPs(scenario, lsps); controler.addOverridingModule(new LSPModule()); controler.addOverridingModule( new AbstractModule(){ - @Override public void install(){ + @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); - strategyManager.addStrategy(new AssignmentStrategyFactory().createStrategy(), null, 1); + strategyManager.addStrategy(new AssignmentStrategyFactory().createStrategy(), null, 1); return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java index dcc82858..352674b7 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstAndSecondReloadLSPMobsimTest.java @@ -95,7 +95,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -146,7 +145,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -271,7 +269,7 @@ public void initialize() { @Override public void install(){ bind( LSPStrategyManager.class ).toProvider(() -> { LSPStrategyManager strategyManager = new LSPStrategyManagerImpl(); - strategyManager.addStrategy(new AssignmentStrategyFactory().createStrategy(), null, 1); + strategyManager.addStrategy(new AssignmentStrategyFactory().createStrategy(), null, 1); return strategyManager; }); bind( CarrierStrategyManager.class ).toProvider(() -> { diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java index d81d3a22..5d949c0a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsFirstReloadLSPMobsimTest.java @@ -90,7 +90,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java index b8037a03..4b9c04a2 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsMainRunLSPMobsimTest.java @@ -90,7 +90,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -140,7 +139,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java index d20cb939..a4521fc2 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/RepeatedMultipleShipmentsCompleteLSPMobsimTest.java @@ -90,7 +90,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -141,7 +140,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -191,7 +189,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java index c6797f4d..41285a8a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java @@ -67,7 +67,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java index 3efe8d0f..f691b6c6 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java @@ -70,7 +70,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -120,7 +119,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = collectionCapabilitiesBuilder.build(); @@ -170,7 +168,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java index 30afaeba..3ae2ed4a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java @@ -71,7 +71,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java index c64a5c1f..a3b520d4 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CompleteLspShipmentAssignerTest.java @@ -75,7 +75,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -124,7 +123,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = collectionCapabilitiesBuilder.build(); @@ -174,7 +172,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 41b00365..6a992b7a 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -73,7 +73,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(Id.createVehicleId("CollectionVehicle"), collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); 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 01ac0685..e4227cbd 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CompleteLSPSchedulingTest.java @@ -86,7 +86,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -137,7 +136,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -186,7 +184,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java index d79f3141..8ad0b1c4 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/FirstReloadLSPSchedulingTest.java @@ -78,7 +78,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); 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 5909c999..7f6900e6 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MainRunLSPSchedulingTest.java @@ -80,7 +80,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -129,7 +128,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index e4f84cd4..77e1d8c2 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -75,7 +75,6 @@ public void initialize() { CarrierVehicle carrierVehicle = CarrierVehicle.newInstance(vollectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(collectionType); capabilitiesBuilder.addVehicle(carrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities capabilities = capabilitiesBuilder.build(); 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 ec2ed677..8b09edd0 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCompleteLSPSchedulingTest.java @@ -86,7 +86,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -138,7 +137,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); @@ -188,7 +186,6 @@ public void initialize() { CarrierVehicle distributionCarrierVehicle = CarrierVehicle.newInstance(distributionVehicleId, distributionLinkId, distributionType); CarrierCapabilities.Builder capabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - capabilitiesBuilder.addType(distributionType); capabilitiesBuilder.addVehicle(distributionCarrierVehicle); capabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities distributionCapabilities = capabilitiesBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java index 30507398..d101b4c9 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsFirstReloadLSPSchedulingTest.java @@ -78,7 +78,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); 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 205d0022..4f0605cf 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsMainRunLSPSchedulingTest.java @@ -80,7 +80,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -129,7 +128,6 @@ public void initialize() { CarrierVehicle mainRunCarrierVehicle = CarrierVehicle.newInstance(mainRunVehicleId, fromLinkId, mainRunType); CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); 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 6fa3888e..42425002 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -84,7 +84,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -136,7 +135,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); 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 e1440539..69d5e998 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -84,7 +84,6 @@ public void initialize() { CarrierVehicle collectionCarrierVehicle = CarrierVehicle.newInstance(collectionVehicleId, collectionLinkId, collectionType); CarrierCapabilities.Builder collectionCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - collectionCapabilitiesBuilder.addType(collectionType); collectionCapabilitiesBuilder.addVehicle(collectionCarrierVehicle); collectionCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities collectionCapabilities = collectionCapabilitiesBuilder.build(); @@ -136,7 +135,6 @@ public void initialize() { CarrierCapabilities.Builder mainRunCapabilitiesBuilder = CarrierCapabilities.Builder.newInstance(); - mainRunCapabilitiesBuilder.addType(mainRunType); mainRunCapabilitiesBuilder.addVehicle(mainRunCarrierVehicle); mainRunCapabilitiesBuilder.setFleetSize(FleetSize.INFINITE); CarrierCapabilities mainRunCapabilities = mainRunCapabilitiesBuilder.build(); From cd4e45683f394ea8f1b00dccb9cfded4084cd7d1 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:33:15 +0200 Subject: [PATCH 10/21] remove unused variables --- .../logistics/adapterTests/CollectionResourceTest.java | 4 ++-- .../logistics/adapterTests/DistributionResourceTest.java | 4 ++-- .../logistics/adapterTests/MainRunResourceTest.java | 4 ++-- .../lspReplanning/CollectionLSPReplanningTest.java | 4 ++-- .../multipleChains/MultipleChainsReplanningTest.java | 4 ++-- .../requirementsChecking/AssignerRequirementsTest.java | 1 - .../simulationTrackers/CollectionTrackerTest.java | 4 ++-- .../logisticChainElementTests/CollectionElementTest.java | 4 ++-- .../DistributionElementTest.java | 8 ++++---- .../logisticChainElementTests/MainRunElementTest.java | 4 ++-- .../logistics/logisticChainTests/CollectionChainTest.java | 4 ++-- .../logisticChainTests/CompleteLogisticChainTest.java | 4 ++-- .../lspCreationTests/CollectionLSPCreationTest.java | 8 ++++---- .../lspCreationTests/CompleteLSPCreationTest.java | 4 ++-- .../MultipleIterationsCollectionLSPMobsimTest.java | 4 ++-- .../MultipleShipmentsCollectionLSPMobsimTest.java | 4 ++-- .../logistics/lspPlanTests/CollectionLSPPlanTest.java | 4 ++-- .../logistics/lspPlanTests/CompleteLSPPlanTest.java | 8 ++++---- .../CollectionLspShipmentAssigmentTest.java | 4 ++-- .../CollectionLSPSchedulingTest.java | 4 ++-- .../MultipleShipmentsCollectionLSPSchedulingTest.java | 4 ++-- 21 files changed, 46 insertions(+), 47 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index 5711bf84..1dd5b2b3 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -57,9 +57,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("CollectionCarrier", Carrier.class); + Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 69dd7836..2a986b5d 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -58,9 +58,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("DistributionCarrier", Carrier.class); + Id carrierId = Id.create("DistributionCarrier", Carrier.class); Id vehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 777eb871..d809ce99 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -55,10 +55,10 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("MainRunCarrier", Carrier.class); + Id carrierId = Id.create("MainRunCarrier", Carrier.class); Id vehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(30); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java index 2e0b80c5..fa77bb1e 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspReplanning/CollectionLSPReplanningTest.java @@ -113,8 +113,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java index e9ca9469..235eba85 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java @@ -91,9 +91,9 @@ private static Scenario prepareScenario(Config config) { } private static LSP createLSP(Scenario scenario) { - Network network = scenario.getNetwork(); + scenario.getNetwork(); - // A plan with two different logistic chains on the left and right, with respective carriers is created + // A plan with two different logistic chains on the left and right, with respective carriers is created LSPPlan multipleOneEchelonChainsPlan; { LogisticChainElement leftCarrierElement; diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index 063ebf65..e8d3b165 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -43,7 +43,6 @@ package org.matsim.freight.logistics.examples.requirementsChecking; import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.Collections; diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index de622ebd..2b18d69f 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -103,8 +103,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java index 8c4dea37..c0a99798 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java @@ -51,9 +51,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("CollectionCarrier", Carrier.class); + Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java index 6dcc2a4c..1e4cd113 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java @@ -53,9 +53,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("DistributionCarrier", Carrier.class); + Id carrierId = Id.create("DistributionCarrier", Carrier.class); Id vehicleTypeId = Id.create("DistributionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); @@ -77,8 +77,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("DistributionCarrierResource", LSPResource.class); - adapter = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrier) + Id.create("DistributionCarrierResource", LSPResource.class); + adapter = ResourceImplementationUtils.DistributionCarrierResourceBuilder.newInstance(carrier) .setDistributionScheduler(ResourceImplementationUtils.createDefaultDistributionCarrierScheduler(scenario)) .setLocationLinkId(distributionLinkId) .build(); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java index a9c0d3c6..423c80b4 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java @@ -51,10 +51,10 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("MainRunCarrier", Carrier.class); + Id carrierId = Id.create("MainRunCarrier", Carrier.class); Id vehicleTypeId = Id.create("MainRunCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(30); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java index 8d417335..89d31019 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java @@ -51,9 +51,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("CollectionCarrier", Carrier.class); + Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java index ba69e76f..560caa7b 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java @@ -61,9 +61,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); + Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder .newInstance(collectionVehicleTypeId); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java index 5d8db51f..f35e6c94 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java @@ -52,9 +52,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("CollectionCarrier", Carrier.class); + Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); @@ -75,8 +75,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java index 93bc4ddb..a514b797 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java @@ -52,10 +52,10 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); + Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); collectionVehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java index 208cf65a..b76d11ca 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsCollectionLSPMobsimTest.java @@ -100,8 +100,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java index 9bf7a021..3a051156 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleShipmentsCollectionLSPMobsimTest.java @@ -95,8 +95,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java index 41285a8a..cae6372a 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java @@ -51,9 +51,9 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id carrierId = Id.create("CollectionCarrier", Carrier.class); + Id carrierId = Id.create("CollectionCarrier", Carrier.class); Id vehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder vehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(vehicleTypeId); vehicleTypeBuilder.setCapacity(10); diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java index f691b6c6..a2216fee 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java @@ -52,10 +52,10 @@ public void initialize() { config.addCoreModules(); Scenario scenario = ScenarioUtils.createScenario(config); new MatsimNetworkReader(scenario.getNetwork()).readFile("scenarios/2regions/2regions-network.xml"); - Network network = scenario.getNetwork(); + scenario.getNetwork(); - Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); + Id collectionCarrierId = Id.create("CollectionCarrier", Carrier.class); Id collectionVehicleTypeId = Id.create("CollectionCarrierVehicleType", VehicleType.class); CarrierVehicleType.Builder collectionVehicleTypeBuilder = CarrierVehicleType.Builder.newInstance(collectionVehicleTypeId); collectionVehicleTypeBuilder.setCapacity(10); @@ -77,8 +77,8 @@ public void initialize() { collectionCarrier.setCarrierCapabilities(collectionCapabilities); - Id collectionResourceId = Id.create("CollectionCarrierResource", LSPResource.class); - final LSPResource collectionCarrierResource = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(collectionCarrier) + Id.create("CollectionCarrierResource", LSPResource.class); + final LSPResource collectionCarrierResource = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(collectionCarrier) .setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)) .setLocationLinkId(collectionLinkId) .build(); diff --git a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java index 3ae2ed4a..36f8e395 100644 --- a/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspShipmentAssignmentTests/CollectionLspShipmentAssigmentTest.java @@ -78,8 +78,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); LSPResource collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java index 6a992b7a..4064ef67 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/CollectionLSPSchedulingTest.java @@ -80,8 +80,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); collectionResource = adapterBuilder.build(); diff --git a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java index 77e1d8c2..458a833b 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsCollectionLSPSchedulingTest.java @@ -82,8 +82,8 @@ public void initialize() { carrier.setCarrierCapabilities(capabilities); - Id adapterId = Id.create("CollectionCarrierResource", LSPResource.class); - CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); + Id.create("CollectionCarrierResource", LSPResource.class); + CollectionCarrierResourceBuilder adapterBuilder = ResourceImplementationUtils.CollectionCarrierResourceBuilder.newInstance(carrier); adapterBuilder.setCollectionScheduler(ResourceImplementationUtils.createDefaultCollectionCarrierScheduler(scenario)); adapterBuilder.setLocationLinkId(collectionLinkId); collectionResource = adapterBuilder.build(); From 38f18d98cf397b031e14b3481e14740abf1492f3 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:33:45 +0200 Subject: [PATCH 11/21] cleanup imports --- .../freight/logistics/adapterTests/CollectionResourceTest.java | 1 - .../freight/logistics/adapterTests/DistributionResourceTest.java | 1 - .../freight/logistics/adapterTests/MainRunResourceTest.java | 1 - .../examples/multipleChains/MultipleChainsReplanningTest.java | 1 - .../logisticChainElementTests/CollectionElementTest.java | 1 - .../logisticChainElementTests/DistributionElementTest.java | 1 - .../logistics/logisticChainElementTests/MainRunElementTest.java | 1 - .../logistics/logisticChainTests/CollectionChainTest.java | 1 - .../logistics/logisticChainTests/CompleteLogisticChainTest.java | 1 - .../logistics/lspCreationTests/CollectionLSPCreationTest.java | 1 - .../logistics/lspCreationTests/CompleteLSPCreationTest.java | 1 - .../freight/logistics/lspPlanTests/CollectionLSPPlanTest.java | 1 - .../freight/logistics/lspPlanTests/CompleteLSPPlanTest.java | 1 - 13 files changed, 13 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index 1dd5b2b3..cd5bacc0 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 2a986b5d..7448513b 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index d809ce99..5cd59cd1 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java index 235eba85..9dd5cc58 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/MultipleChainsReplanningTest.java @@ -33,7 +33,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.groups.VspExperimentalConfigGroup; diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java index c0a99798..9f425365 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/CollectionElementTest.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java index 1e4cd113..a816d633 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/DistributionElementTest.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java index 423c80b4..1e83c360 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainElementTests/MainRunElementTest.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java index 89d31019..df06fa8f 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CollectionChainTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java index 560caa7b..cea7f72d 100644 --- a/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java +++ b/src/test/java/org/matsim/freight/logistics/logisticChainTests/CompleteLogisticChainTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java index f35e6c94..e7634cf6 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CollectionLSPCreationTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java index a514b797..32db2031 100644 --- a/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspCreationTests/CompleteLSPCreationTest.java @@ -28,7 +28,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java index cae6372a..ee000e6f 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CollectionLSPPlanTest.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; diff --git a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java index a2216fee..2d811c99 100644 --- a/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspPlanTests/CompleteLSPPlanTest.java @@ -27,7 +27,6 @@ import org.matsim.api.core.v01.Id; import org.matsim.api.core.v01.Scenario; import org.matsim.api.core.v01.network.Link; -import org.matsim.api.core.v01.network.Network; import org.matsim.core.config.Config; import org.matsim.core.network.io.MatsimNetworkReader; import org.matsim.core.scenario.ScenarioUtils; From c51375285f3d06a353dea4f12d230881fcaf8a1b Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:41:53 +0200 Subject: [PATCH 12/21] improve tests --- .../logistics/adapterTests/DistributionResourceTest.java | 5 +---- .../freight/logistics/adapterTests/MainRunResourceTest.java | 5 +---- .../examples/simulationTrackers/CollectionTrackerTest.java | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 7448513b..4f677ded 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -93,10 +93,7 @@ public void testCollectionResource() { assertNotNull(distributionResource.getClientElements()); assertTrue(distributionResource.getClientElements().isEmpty()); assertTrue(LSPCarrierResource.class.isAssignableFrom(distributionResource.getClass())); - if (LSPCarrierResource.class.isAssignableFrom(distributionResource.getClass())) { -// assertTrue(Carrier.class.isAssignableFrom(distributionResource.getClassOfResource())); - assertSame(distributionResource.getCarrier(), distributionCarrier); - } + assertSame(distributionResource.getCarrier(), distributionCarrier); assertSame(distributionResource.getEndLinkId(), distributionLinkId); assertSame(distributionResource.getStartLinkId(), distributionLinkId); assertNotNull(distributionResource.getSimulationTrackers()); diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java index 5cd59cd1..05cf35e5 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/MainRunResourceTest.java @@ -92,10 +92,7 @@ public void testMainRunResource() { assertNotNull(mainRunResource.getClientElements()); assertTrue(mainRunResource.getClientElements().isEmpty()); assertTrue(LSPCarrierResource.class.isAssignableFrom(mainRunResource.getClass())); - if (LSPCarrierResource.class.isAssignableFrom(mainRunResource.getClass())) { -// assertTrue(Carrier.class.isAssignableFrom(mainRunResource.getClassOfResource())); - assertSame(mainRunResource.getCarrier(), carrier); - } + assertSame(mainRunResource.getCarrier(), carrier); assertSame(mainRunResource.getEndLinkId(), toLinkId); assertSame(mainRunResource.getStartLinkId(), fromLinkId); assertNotNull(mainRunResource.getSimulationTrackers()); diff --git a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java index 2b18d69f..f55f5a8d 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/simulationTrackers/CollectionTrackerTest.java @@ -291,7 +291,7 @@ public void testCollectionTracker() { double fixedTrackedCostsPerShipment = (totalTrackedCosts * shareOfFixedCosts) / totalNumberOfTrackedShipments; double fixedScheduledCostsPerShipment = (totalScheduledCosts * shareOfFixedCosts) / totalNumberOfScheduledShipments; - assertEquals(totalTrackedWeight, totalTrackedWeight, 0); + assertEquals(totalTrackedWeight, totalScheduledWeight, 0); assertEquals(totalNumberOfTrackedShipments, totalNumberOfScheduledShipments, 0); assertEquals(totalTrackedCosts, totalScheduledCosts, Math.max(totalScheduledCosts, totalTrackedCosts) * 0.01); assertEquals(linearTrackedCostsPerShipment, linearScheduledCostsPerShipment, Math.max(linearTrackedCostsPerShipment, linearScheduledCostsPerShipment) * 0.01); From 463ec1fddff8cbacfe37cb7848b1bb3195f74528 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:45:11 +0200 Subject: [PATCH 13/21] add not null check --- .../AssignerRequirementsTest.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java index e8d3b165..7968f1f8 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/requirementsChecking/AssignerRequirementsTest.java @@ -1,24 +1,3 @@ -/* - *********************************************************************** * - * 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.* @@ -201,11 +180,13 @@ public void initialize() { public void testAssignerRequirements() { for (Id shipmentId : blueChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(blueChain.getLSP(), shipmentId); + assert shipment != null; assertInstanceOf(BlueRequirement.class, shipment.getRequirements().iterator().next()); } for (Id shipmentId : redChain.getLspShipmentIds()) { LspShipment shipment = LSPUtils.findLspShipment(redChain.getLSP(), shipmentId); - assertInstanceOf(RedRequirement.class, shipment.getRequirements().iterator().next()); + assert shipment != null; + assertInstanceOf(RedRequirement.class, shipment.getRequirements().iterator().next()); } } From 804b99d06644c234ede7bf60dbe80d7a33f2f5b3 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:46:43 +0200 Subject: [PATCH 14/21] java language level improvement --- .../examples/lspScoring/CollectionLSPScoringTest.java | 2 +- .../MultipleIterationsCollectionLSPScoringTest.java | 2 +- .../examples/multipleChains/WorstPlanSelectorTest.java | 2 +- .../logistics/lspMobsimTests/CollectionLSPMobsimTest.java | 7 +------ 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java index 5fe09bbe..15180dda 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/CollectionLSPScoringTest.java @@ -152,7 +152,7 @@ public void initialize() { controler.addOverridingModule( new LSPModule() ); controler.addOverridingModule( new AbstractModule(){ @Override public void install(){ - bind( LSPScorerFactory.class ).toInstance( () -> new ExampleLSPScoring.TipScorer() ); + bind( LSPScorerFactory.class ).toInstance(ExampleLSPScoring.TipScorer::new); } }); diff --git a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java index 2910e9dc..7c2b37ab 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/lspScoring/MultipleIterationsCollectionLSPScoringTest.java @@ -174,7 +174,7 @@ public void initialize() { controler.addOverridingModule( new LSPModule() ); controler.addOverridingModule( new AbstractModule(){ @Override public void install(){ - bind( LSPScorerFactory.class ).toInstance( () -> new ExampleLSPScoring.TipScorer() ); + bind( LSPScorerFactory.class ).toInstance(ExampleLSPScoring.TipScorer::new); bind( LSPStrategyManager.class ).toInstance( new LSPModule.LSPStrategyManagerEmptyImpl() ); bind( CarrierStrategyManager.class ).toProvider(() -> { CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); diff --git a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java index 1334632b..47ad17c8 100644 --- a/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java +++ b/src/test/java/org/matsim/freight/logistics/examples/multipleChains/WorstPlanSelectorTest.java @@ -260,7 +260,7 @@ public void install() { final EventBasedCarrierScorer4MultipleChains carrierScorer = new EventBasedCarrierScorer4MultipleChains(); bind(CarrierScoringFunctionFactory.class).toInstance(carrierScorer); - bind(LSPScorerFactory.class).toInstance( () -> new MyLSPScorer()); + bind(LSPScorerFactory.class).toInstance(MyLSPScorer::new); bind(CarrierStrategyManager.class).toProvider(() -> { CarrierStrategyManager strategyManager = CarrierControlerUtils.createDefaultCarrierStrategyManager(); strategyManager.addStrategy(new GenericPlanStrategyImpl<>(new BestPlanSelector<>()), null, 1); diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java index c8e99e94..bf98cbda 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/CollectionLSPMobsimTest.java @@ -182,12 +182,7 @@ public void initialize() { lsps = new LSPs(lspList); } Controler controler = new Controler(scenario); - controler.getEvents().addHandler(new BasicEventHandler() { - @Override - public void handleEvent(Event event) { - log.warn(event); - } - }); + controler.getEvents().addHandler((BasicEventHandler) event -> log.warn(event)); controler.addOverridingModule(new AbstractModule() { @Override From e2122a7c14cc0cc89085ea388e8e8774a6c2baba Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:48:07 +0200 Subject: [PATCH 15/21] fix typos --- .../logistics/adapterTests/CollectionResourceTest.java | 2 +- .../logistics/adapterTests/DistributionResourceTest.java | 4 ++-- .../MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java index cd5bacc0..f044ca9d 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/CollectionResourceTest.java @@ -40,7 +40,7 @@ public class CollectionResourceTest { - //die Trackers sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. + //Die Tracker sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. //Man kann sie deshalb ja extra außerhalb des Builders einsetzen. private org.matsim.vehicles.VehicleType collectionType; diff --git a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java index 4f677ded..4e764d60 100644 --- a/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java +++ b/src/test/java/org/matsim/freight/logistics/adapterTests/DistributionResourceTest.java @@ -41,8 +41,8 @@ public class DistributionResourceTest { - //die Trackers sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. - //Man kann sie deshalb ja extra au�erhalb des Builders einsetzen. + //Die Tracker sind ja erst ein Bestandteil des Scheduling bzw. Replanning und kommen hier noch nicht rein. + //Man kann sie deshalb ja extra außerhalb des Builders einsetzen. private org.matsim.vehicles.VehicleType distributionType; private CarrierVehicle distributionCarrierVehicle; diff --git a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java index 534b5552..050dda7d 100644 --- a/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java +++ b/src/test/java/org/matsim/freight/logistics/lspMobsimTests/MultipleIterationsFirstAndSecondReloadLSPMobsimTest.java @@ -312,6 +312,6 @@ public void testFirstReloadLSPMobsim() { @Test public void compareEvents(){ MatsimTestUtils.assertEqualEventsFiles(utils.getClassInputDirectory() + "output_events.xml.gz", utils.getOutputDirectory() + "output_events.xml.gz" ); - //Please note, that this result contains also reloding / hubHandlingStarts after the main run (even if there is no further distribution carrier) + //Please note, that this result contains also reloading / hubHandlingStarts after the main run (even if there is no further distribution carrier) } } From 908b4967fa6286572f0f6525b571bc1edd12c999 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:49:00 +0200 Subject: [PATCH 16/21] remove LspShipmentWithTime.java --- .../logistics/LspShipmentWithTime.java | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java diff --git a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java b/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java deleted file mode 100644 index 04f66219..00000000 --- a/src/main/java/org/matsim/freight/logistics/LspShipmentWithTime.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * *********************************************************************** * - * * 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; - -import org.matsim.freight.logistics.shipment.LspShipment; -import org.matsim.freight.logistics.shipment.LspShipmentUtils; - -public class LspShipmentWithTime { - // yyyyyy find better solution for this. It is not so good to define an interface, and then - // immediately define a class that goes beyond it. - // Maybe the time should be added to the interface? However, I don't even know what that time - // means (delivery time? current time?). kai, - // jun'22 - - private final LspShipment lspShipment; - - - public LspShipmentWithTime(double time, LspShipment lspShipment) { - LspShipmentUtils.setTimeOfLspShipment(lspShipment, time); - this.lspShipment = lspShipment; - } - - public LspShipment getLspShipment() { - return lspShipment; - } - - public double getTime() { - return LspShipmentUtils.getTimeOfLspShipment(this.lspShipment); -// return time; - } - -} From 14761106a53a2cb631b80d397bfe42554085069c Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:50:04 +0200 Subject: [PATCH 17/21] fix typo --- .../freight/logistics/LSPResourceScheduler.java | 14 +++++++------- .../CollectionCarrierScheduler.java | 4 ++-- .../DistributionCarrierScheduler.java | 4 ++-- .../MainRunCarrierScheduler.java | 4 ++-- .../TransshipmentHubScheduler.java | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java index 68d8f6fb..83c5e555 100644 --- a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java @@ -41,20 +41,20 @@ public abstract class LSPResourceScheduler { protected LSPResource resource; - protected ArrayList lspShipmentsToScedule; + protected ArrayList lspShipmentsToSchedule; protected LSPPlan lspPlan; public final void scheduleShipments(LSPPlan lspPlan, LSPResource resource, int bufferTime) { this.lspPlan = lspPlan; this.resource = resource; - this.lspShipmentsToScedule = new ArrayList<>(); + this.lspShipmentsToSchedule = new ArrayList<>(); initializeValues(resource); presortIncomingShipments(); scheduleResource(); updateShipments(); switchHandledShipments(bufferTime); - lspShipmentsToScedule.clear(); + lspShipmentsToSchedule.clear(); } /** @@ -79,15 +79,15 @@ public final void scheduleShipments(LSPPlan lspPlan, LSPResource resource, int b protected abstract void updateShipments(); private void presortIncomingShipments() { - this.lspShipmentsToScedule = new ArrayList<>(); + this.lspShipmentsToSchedule = new ArrayList<>(); for (LogisticChainElement element : resource.getClientElements()) { - lspShipmentsToScedule.addAll(element.getIncomingShipments().getLspShipmentsWTime()); + lspShipmentsToSchedule.addAll(element.getIncomingShipments().getLspShipmentsWTime()); } - lspShipmentsToScedule.sort(Comparator.comparingDouble(LspShipment::getTime)); + lspShipmentsToSchedule.sort(Comparator.comparingDouble(LspShipment::getTime)); } private void switchHandledShipments(int bufferTime) { - for (LspShipment lspShipmentWithTime : lspShipmentsToScedule) { + for (LspShipment lspShipmentWithTime : lspShipmentsToSchedule) { var shipmentPlan = LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId()); double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime; lspShipmentWithTime.setTime(endOfTransportTime); 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 5563a290..c2c721b7 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -74,7 +74,7 @@ public void initializeValues(LSPResource resource) { @Override public void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsToScedule) { + for (LspShipment tupleToBeAssigned : lspShipmentsToSchedule) { CarrierService carrierService = convertToCarrierService(tupleToBeAssigned); carrier.getServices().put(carrierService.getId(), carrierService); } @@ -96,7 +96,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsToScedule) { + for (LspShipment tuple : lspShipmentsToSchedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { 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 8fd0ba62..c1ba5484 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -85,7 +85,7 @@ protected void scheduleResource() { int load = 0; double cumulatedLoadingTime = 0; double availabilityTimeOfLastShipment = 0; - ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsToScedule); + ArrayList copyOfAssignedShipments = new ArrayList<>(lspShipmentsToSchedule); ArrayList shipmentsInCurrentTour = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); @@ -184,7 +184,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsToScedule) { + for (LspShipment tuple : lspShipmentsToSchedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { 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 e90f016b..40d80f73 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -77,7 +77,7 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { int load = 0; - List copyOfAssignedShipments = new ArrayList<>(lspShipmentsToScedule); + List copyOfAssignedShipments = new ArrayList<>(lspShipmentsToSchedule); copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipment::getTime)); ArrayList shipmentsInCurrentTour = new ArrayList<>(); // ArrayList scheduledTours = new ArrayList<>(); @@ -235,7 +235,7 @@ private CarrierService convertToCarrierService(LspShipment tuple) { @Override protected void updateShipments() { - for (LspShipment LspShipment : lspShipmentsToScedule) { + for (LspShipment LspShipment : lspShipmentsToSchedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index 88842d28..b2ed65fe 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -43,7 +43,7 @@ private TransshipmentHubTourEndEventHandler eventHandler; TransshipmentHubScheduler(TranshipmentHubSchedulerBuilder builder) { - this.lspShipmentsToScedule = new ArrayList<>(); + this.lspShipmentsToSchedule = new ArrayList<>(); this.capacityNeedLinear = builder.getCapacityNeedLinear(); this.capacityNeedFixed = builder.getCapacityNeedFixed(); } @@ -55,7 +55,7 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsToScedule) { + for (LspShipment tupleToBeAssigned : lspShipmentsToSchedule) { updateSchedule(tupleToBeAssigned); } } From 9b2e27cf95d91b67729c3f84b99f56d17aefdd6f Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:57:11 +0200 Subject: [PATCH 18/21] rename tuple to lspShipment, because the tuple "ShipmentWithTime" no longer exists --- .../CollectionCarrierScheduler.java | 83 +++++++++--------- .../DistributionCarrierScheduler.java | 85 +++++++++++-------- .../MainRunCarrierScheduler.java | 76 ++++++++--------- .../TransshipmentHubScheduler.java | 28 +++--- 4 files changed, 144 insertions(+), 128 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 c2c721b7..abc6c317 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -74,42 +74,42 @@ public void initializeValues(LSPResource resource) { @Override public void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsToSchedule) { - CarrierService carrierService = convertToCarrierService(tupleToBeAssigned); + for (LspShipment lspShipmentToBeAssigned : lspShipmentsToSchedule) { + CarrierService carrierService = convertToCarrierService(lspShipmentToBeAssigned); carrier.getServices().put(carrierService.getId(), carrierService); } CarrierSchedulerUtils.solveVrpWithJsprit(carrier, scenario); } - private CarrierService convertToCarrierService(LspShipment tuple) { + private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = - Id.create(tuple.getId().toString(), CarrierService.class); + Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService.Builder builder = - CarrierService.Builder.newInstance(serviceId, tuple.getFrom()); - builder.setServiceStartTimeWindow(tuple.getPickupTimeWindow()); - builder.setCapacityDemand(tuple.getSize()); - builder.setServiceDuration(tuple.getDeliveryServiceTime()); + CarrierService.Builder.newInstance(serviceId, lspShipment.getFrom()); + builder.setServiceStartTimeWindow(lspShipment.getPickupTimeWindow()); + builder.setCapacityDemand(lspShipment.getSize()); + builder.setServiceDuration(lspShipment.getDeliveryServiceTime()); CarrierService carrierService = builder.build(); - pairs.add(new LSPCarrierPair(tuple, carrierService)); + pairs.add(new LSPCarrierPair(lspShipment, carrierService)); return carrierService; } @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsToSchedule) { + for (LspShipment lspShipment : lspShipmentsToSchedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof Tour.ServiceActivity serviceActivity) { - LSPCarrierPair carrierPair = new LSPCarrierPair(tuple, serviceActivity.getService()); + LSPCarrierPair carrierPair = new LSPCarrierPair(lspShipment, serviceActivity.getService()); for (LSPCarrierPair pair : pairs) { - if (pair.tuple == carrierPair.tuple + if (pair.lspShipment == carrierPair.lspShipment && pair.carrierService.getId() == carrierPair.carrierService.getId()) { - addShipmentLoadElement(tuple, tour, serviceActivity); - addShipmentTransportElement(tuple, tour, serviceActivity); - addShipmentUnloadElement(tuple, tour, serviceActivity); - addCollectionTourEndEventHandler(pair.carrierService, tuple, resource, tour); - addCollectionServiceEventHandler(pair.carrierService, tuple, resource); + addShipmentLoadElement(lspShipment, tour, serviceActivity); + addShipmentTransportElement(lspShipment, tour, serviceActivity); + addShipmentUnloadElement(lspShipment, tour, serviceActivity); + addCollectionTourEndEventHandler(pair.carrierService, lspShipment, resource, tour); + addCollectionServiceEventHandler(pair.carrierService, lspShipment, resource); } } } @@ -119,47 +119,52 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); + for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } + int serviceIndex = tour.getTourElements().indexOf(serviceActivity); Leg legBeforeService = (Leg) tour.getTourElements().get(serviceIndex - 1); double startTimeOfLoading = legBeforeService.getExpectedDepartureTime() + legBeforeService.getExpectedTransportTime(); builder.setStartTime(startTimeOfLoading); - builder.setEndTime(startTimeOfLoading + tuple.getDeliveryServiceTime()); + builder.setEndTime(startTimeOfLoading + lspShipment.getDeliveryServiceTime()); LspShipmentPlanElement load = builder.build(); String idString = load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); + for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } + int serviceIndex = tour.getTourElements().indexOf(serviceActivity); Leg legAfterService = (Leg) tour.getTourElements().get(serviceIndex + 1); double startTimeOfTransport = legAfterService.getExpectedDepartureTime(); builder.setStartTime(startTimeOfTransport); Leg lastLeg = (Leg) tour.getTourElements().getLast(); - double endTimeOfTransport = - lastLeg.getExpectedDepartureTime() + lastLeg.getExpectedTransportTime(); + double endTimeOfTransport = lastLeg.getExpectedDepartureTime() + lastLeg.getExpectedTransportTime(); builder.setEndTime(endTimeOfTransport); builder.setCarrierId(carrier.getId()); builder.setFromLinkId(serviceActivity.getLocation()); @@ -172,18 +177,19 @@ private void addShipmentTransportElement( + transport.getLogisticChainElement().getId() + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, transport); } private void addCollectionServiceEventHandler( - CarrierService carrierService, LspShipment tuple, LSPCarrierResource resource) { + CarrierService carrierService, LspShipment lspShipment, LSPCarrierResource resource) { + for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { CollectionServiceEndEventHandler endHandler = new CollectionServiceEndEventHandler( - carrierService, tuple, element, resource); - tuple.addSimulationTracker(endHandler); + carrierService, lspShipment, element, resource); + lspShipment.addSimulationTracker(endHandler); break; } } @@ -191,27 +197,28 @@ private void addCollectionServiceEventHandler( private void addCollectionTourEndEventHandler( CarrierService carrierService, - LspShipment tuple, + LspShipment lspShipment, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourEndEventHandler handler = new LSPTourEndEventHandler( - tuple, carrierService, element, resource, tour); - tuple.addSimulationTracker(handler); + lspShipment, carrierService, element, resource, tour); + lspShipment.addSimulationTracker(handler); break; } } } private void addShipmentUnloadElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticsChainElement(element); } } @@ -227,7 +234,7 @@ private void addShipmentUnloadElement( + unload.getLogisticChainElement().getId() + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, unload); } @@ -241,5 +248,5 @@ private double getUnloadEndTime(Tour tour) { return unloadEndTime; } - private record LSPCarrierPair(LspShipment tuple, CarrierService carrierService) {} + 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 c1ba5484..b78da4e1 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -89,13 +89,13 @@ protected void scheduleResource() { ArrayList shipmentsInCurrentTour = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); - for (LspShipment tuple : copyOfAssignedShipments) { + for (LspShipment lspShipment : copyOfAssignedShipments) { // TODO KMT: Verstehe es nur mäßig, was er hier mit den Fahrzeugtypen macht. Er nimmt einfach // 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(); - if ((load + tuple.getSize()) + if ((load + lspShipment.getSize()) > vehicleType.getCapacity().getOther().intValue()) { load = 0; Carrier auxiliaryCarrier = @@ -107,10 +107,10 @@ protected void scheduleResource() { cumulatedLoadingTime = 0; shipmentsInCurrentTour.clear(); } - shipmentsInCurrentTour.add(tuple); - load = load + tuple.getSize(); - cumulatedLoadingTime = cumulatedLoadingTime + tuple.getDeliveryServiceTime(); - availabilityTimeOfLastShipment = tuple.getTime(); + shipmentsInCurrentTour.add(lspShipment); + load = load + lspShipment.getSize(); + cumulatedLoadingTime = cumulatedLoadingTime + lspShipment.getDeliveryServiceTime(); + availabilityTimeOfLastShipment = lspShipment.getTime(); } if (!shipmentsInCurrentTour.isEmpty()) { @@ -170,34 +170,34 @@ private Collection unifyTourIds(Collection carrierPl return scheduledToursUnified; } - private CarrierService convertToCarrierService(LspShipment tuple) { + private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = - Id.create(tuple.getId().toString(), CarrierService.class); + Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService.Builder builder = - CarrierService.Builder.newInstance(serviceId, tuple.getTo()); - builder.setCapacityDemand(tuple.getSize()); - builder.setServiceDuration(tuple.getDeliveryServiceTime()); + CarrierService.Builder.newInstance(serviceId, lspShipment.getTo()); + builder.setCapacityDemand(lspShipment.getSize()); + builder.setServiceDuration(lspShipment.getDeliveryServiceTime()); CarrierService carrierService = builder.build(); - pairs.add(new LSPCarrierPair(tuple, carrierService)); + pairs.add(new LSPCarrierPair(lspShipment, carrierService)); return carrierService; } @Override protected void updateShipments() { - for (LspShipment tuple : lspShipmentsToSchedule) { + for (LspShipment lspShipment : lspShipmentsToSchedule) { for (ScheduledTour scheduledTour : carrier.getSelectedPlan().getScheduledTours()) { Tour tour = scheduledTour.getTour(); for (TourElement element : tour.getTourElements()) { if (element instanceof ServiceActivity serviceActivity) { - LSPCarrierPair carrierPair = new LSPCarrierPair(tuple, serviceActivity.getService()); + LSPCarrierPair carrierPair = new LSPCarrierPair(lspShipment, serviceActivity.getService()); for (LSPCarrierPair pair : pairs) { - if (pair.tuple == carrierPair.tuple + if (pair.lspShipment == carrierPair.lspShipment && pair.carrierService.getId() == carrierPair.carrierService.getId()) { - addShipmentLoadElement(tuple, tour, serviceActivity); - addShipmentTransportElement(tuple, tour, serviceActivity); - addShipmentUnloadElement(tuple, tour, serviceActivity); - addDistributionTourStartEventHandler(pair.carrierService, tuple, resource, tour); - addDistributionServiceEventHandler(pair.carrierService, tuple, resource); + addShipmentLoadElement(lspShipment, tour, serviceActivity); + addShipmentTransportElement(lspShipment, tour, serviceActivity); + addShipmentUnloadElement(lspShipment, tour, serviceActivity); + addDistributionTourStartEventHandler(pair.carrierService, lspShipment, resource, tour); + addDistributionServiceEventHandler(pair.carrierService, lspShipment, resource); } } } @@ -207,15 +207,18 @@ protected void updateShipments() { } private void addShipmentLoadElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); + for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); @@ -233,20 +236,23 @@ private void addShipmentLoadElement( String idString = load.getResourceId() + "" + load.getLogisticChainElement().getId() + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, load); } private void addShipmentTransportElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); + for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); final Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); @@ -275,20 +281,23 @@ private void addShipmentTransportElement( + transport.getLogisticChainElement().getId() + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, transport); } private void addShipmentUnloadElement( LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); + for (LogisticChainElement element : resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { builder.setLogisticsChainElement(element); } } + int serviceIndex = tour.getTourElements().indexOf(serviceActivity); ServiceActivity serviceAct = (ServiceActivity) tour.getTourElements().get(serviceIndex); @@ -328,20 +337,21 @@ private Carrier createAuxiliaryCarrier(ArrayList shipmentsInCurrent auxiliaryCarrier.getCarrierCapabilities().getCarrierVehicles().put(cv.getId(), cv); auxiliaryCarrier.getCarrierCapabilities().setFleetSize(FleetSize.FINITE); - for (LspShipment tuple : shipmentsInCurrentTour) { - CarrierService carrierService = convertToCarrierService(tuple); + for (LspShipment lspShipment : shipmentsInCurrentTour) { + CarrierService carrierService = convertToCarrierService(lspShipment); auxiliaryCarrier.getServices().put(carrierService.getId(), carrierService); } return auxiliaryCarrier; } private void addDistributionServiceEventHandler( - CarrierService carrierService, LspShipment tuple, LSPCarrierResource resource) { + CarrierService carrierService, LspShipment lspShipment, LSPCarrierResource resource) { + for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { DistributionServiceStartEventHandler handler = - new DistributionServiceStartEventHandler(carrierService, tuple, element, resource); - tuple.addSimulationTracker(handler); + new DistributionServiceStartEventHandler(carrierService, lspShipment, element, resource); + lspShipment.addSimulationTracker(handler); break; } } @@ -349,18 +359,19 @@ private void addDistributionServiceEventHandler( private void addDistributionTourStartEventHandler( CarrierService carrierService, - LspShipment tuple, + LspShipment lspShipment, LSPCarrierResource resource, Tour tour) { + for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourStartEventHandler handler = - new LSPTourStartEventHandler(tuple, carrierService, element, resource, tour); - tuple.addSimulationTracker(handler); + new LSPTourStartEventHandler(lspShipment, carrierService, element, resource, tour); + lspShipment.addSimulationTracker(handler); break; } } } - private record LSPCarrierPair(LspShipment tuple, CarrierService carrierService) {} + private record LSPCarrierPair(LspShipment lspShipment, CarrierService carrierService) {} } 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 40d80f73..54bc52b4 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -83,22 +83,22 @@ protected void scheduleResource() { // ArrayList scheduledTours = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); - for (LspShipment tuple : copyOfAssignedShipments) { + for (LspShipment lspShipment : copyOfAssignedShipments) { // Add job as "services" to the carrier. So the carrier has this available - CarrierService carrierService = convertToCarrierService(tuple); + CarrierService carrierService = convertToCarrierService(lspShipment); carrier.getServices().put(carrierService.getId(), carrierService); VehicleType vehicleType = ResourceImplementationUtils.getVehicleTypeCollection(carrier).iterator().next(); - if ((load + tuple.getSize()) + if ((load + lspShipment.getSize()) > vehicleType.getCapacity().getOther().intValue()) { load = 0; CarrierPlan plan = createPlan(carrier, shipmentsInCurrentTour); scheduledPlans.add(plan); shipmentsInCurrentTour.clear(); } - shipmentsInCurrentTour.add(tuple); - load = load + tuple.getSize(); + shipmentsInCurrentTour.add(lspShipment); + load = load + lspShipment.getSize(); } if (!shipmentsInCurrentTour.isEmpty()) { CarrierPlan plan = createPlan(carrier, shipmentsInCurrentTour); @@ -115,7 +115,7 @@ protected void scheduleResource() { carrier.setSelectedPlan(plan); } - private CarrierPlan createPlan(Carrier carrier, List tuples) { + private CarrierPlan createPlan(Carrier carrier, List lspShipments) { // TODO: Allgemein: Hier ist alles manuell zusammen gesetzt; es findet KEINE Tourenplanung // statt! @@ -133,14 +133,14 @@ private CarrierPlan createPlan(Carrier carrier, List tuples) { double totalLoadingTime = 0; double latestTupleTime = 0; - for (LspShipment tuple : tuples) { - totalLoadingTime = totalLoadingTime + tuple.getDeliveryServiceTime(); - if (tuple.getTime() > latestTupleTime) { - latestTupleTime = tuple.getTime(); + for (LspShipment lspShipment : lspShipments) { + totalLoadingTime = totalLoadingTime + lspShipment.getDeliveryServiceTime(); + if (lspShipment.getTime() > latestTupleTime) { + latestTupleTime = lspShipment.getTime(); } tourBuilder.addLeg(new Leg()); - CarrierService carrierService = convertToCarrierService(tuple); - pairs.add(new LSPShipmentCarrierServicePair(tuple, carrierService)); + CarrierService carrierService = convertToCarrierService(lspShipment); + pairs.add(new LSPShipmentCarrierServicePair(lspShipment, carrierService)); tourBuilder.scheduleService(carrierService); } @@ -223,13 +223,13 @@ private double scorePlanManually(CarrierPlan plan) { return (-score); // negative, because we are looking at "costs" instead of "utility" } - private CarrierService convertToCarrierService(LspShipment tuple) { + private CarrierService convertToCarrierService(LspShipment lspShipment) { Id serviceId = - Id.create(tuple.getId().toString(), CarrierService.class); + Id.create(lspShipment.getId().toString(), CarrierService.class); CarrierService.Builder builder = CarrierService.Builder.newInstance(serviceId, resource.getEndLinkId()); - builder.setCapacityDemand(tuple.getSize()); - builder.setServiceDuration(tuple.getDeliveryServiceTime()); + builder.setCapacityDemand(lspShipment.getSize()); + builder.setServiceDuration(lspShipment.getDeliveryServiceTime()); return builder.build(); } @@ -244,7 +244,7 @@ protected void updateShipments() { new LSPShipmentCarrierServicePair( LspShipment, serviceActivity.getService()); for (LSPShipmentCarrierServicePair pair : pairs) { - if (pair.tuple == carrierPair.tuple + if (pair.lspShipment == carrierPair.lspShipment && pair.carrierService.getId() == carrierPair.carrierService.getId()) { addShipmentLoadElement(LspShipment, tour); addShipmentTransportElement(LspShipment, tour, serviceActivity); @@ -259,13 +259,12 @@ protected void updateShipments() { } } - private void addShipmentLoadElement( - LspShipment tuple, Tour tour) { + private void addShipmentLoadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } @@ -288,17 +287,16 @@ private void addShipmentLoadElement( + String.valueOf(load.getLogisticChainElement().getId()) + load.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, load); } - private void addShipmentTransportElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + private void addShipmentTransportElement(LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentTransportBuilder builder = LspShipmentUtils.ScheduledShipmentTransportBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticChainElement(element); } } @@ -318,17 +316,16 @@ private void addShipmentTransportElement( + String.valueOf(transport.getLogisticChainElement().getId()) + transport.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, transport); } - private void addShipmentUnloadElement( - LspShipment tuple, Tour tour, Tour.ServiceActivity serviceActivity) { + private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); for (LogisticChainElement element : resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticsChainElement(element); } } @@ -354,20 +351,21 @@ private void addShipmentUnloadElement( + String.valueOf(unload.getLogisticChainElement().getId()) + unload.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, unload); } private void addMainTourRunStartEventHandler( - CarrierService carrierService, - LspShipment tuple, + CarrierService carrierService, + LspShipment lspShipment, LSPCarrierResource resource, Tour tour) { + for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourStartEventHandler handler = - new LSPTourStartEventHandler(tuple, carrierService, element, resource, tour); - tuple.addSimulationTracker(handler); + new LSPTourStartEventHandler(lspShipment, carrierService, element, resource, tour); + lspShipment.addSimulationTracker(handler); break; } } @@ -375,18 +373,18 @@ private void addMainTourRunStartEventHandler( private void addMainRunTourEndEventHandler( CarrierService carrierService, - LspShipment tuple, + LspShipment lspShipment, LSPCarrierResource resource, Tour tour) { for (LogisticChainElement element : this.resource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LSPTourEndEventHandler handler = - new LSPTourEndEventHandler(tuple, carrierService, element, resource, tour); - tuple.addSimulationTracker(handler); + new LSPTourEndEventHandler(lspShipment, carrierService, element, resource, tour); + lspShipment.addSimulationTracker(handler); break; } } } - private record LSPShipmentCarrierServicePair(LspShipment tuple, CarrierService carrierService) {} + private record LSPShipmentCarrierServicePair(LspShipment lspShipment, CarrierService carrierService) {} } diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index b2ed65fe..9d1d7348 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -55,8 +55,8 @@ protected void initializeValues(LSPResource resource) { @Override protected void scheduleResource() { - for (LspShipment tupleToBeAssigned : lspShipmentsToSchedule) { - updateSchedule(tupleToBeAssigned); + for (LspShipment lspShipmentToBeAssigned : lspShipmentsToSchedule) { + updateSchedule(lspShipmentToBeAssigned); } } @@ -66,20 +66,20 @@ protected void updateShipments() { log.error("This method is not implemented. Nothing will happen here. "); } - private void updateSchedule(LspShipment tuple) { - addShipmentHandleElement(tuple); - addShipmentToEventHandler(tuple); + private void updateSchedule(LspShipment lspShipment) { + addShipmentHandleElement(lspShipment); + addShipmentToEventHandler(lspShipment); } - private void addShipmentHandleElement(LspShipment tuple) { + private void addShipmentHandleElement(LspShipment lspShipment) { LspShipmentUtils.ScheduledShipmentHandleBuilder builder = LspShipmentUtils.ScheduledShipmentHandleBuilder.newInstance(); - builder.setStartTime(tuple.getTime()); + builder.setStartTime(lspShipment.getTime()); builder.setEndTime( - tuple.getTime() + capacityNeedFixed + capacityNeedLinear * tuple.getSize()); + lspShipment.getTime() + capacityNeedFixed + capacityNeedLinear * lspShipment.getSize()); builder.setResourceId(transshipmentHubResource.getId()); for (LogisticChainElement element : transshipmentHubResource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { builder.setLogisticsChainElement(element); } } @@ -89,16 +89,16 @@ private void addShipmentHandleElement(LspShipment tuple) { + String.valueOf(handle.getLogisticChainElement().getId()) + handle.getElementType(); Id id = Id.create(idString, LspShipmentPlanElement.class); - LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, tuple.getId()) + LspShipmentUtils.getOrCreateShipmentPlan(super.lspPlan, lspShipment.getId()) .addPlanElement(id, handle); } - private void addShipmentToEventHandler(LspShipment tuple) { + private void addShipmentToEventHandler(LspShipment lspShipment) { for (LogisticChainElement element : transshipmentHubResource.getClientElements()) { - if (element.getIncomingShipments().getLspShipmentsWTime().contains(tuple)) { + if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { LspShipmentPlan lspShipmentPlan = - LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, tuple.getId()); - eventHandler.addShipment(tuple, element, lspShipmentPlan); + LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipment.getId()); + eventHandler.addShipment(lspShipment, element, lspShipmentPlan); break; } } From 1f901f0fe7f41a68a3644b276d3dca027db9347a Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 13:59:43 +0200 Subject: [PATCH 19/21] remove unused var from method signature --- .../CollectionCarrierScheduler.java | 5 ++--- .../DistributionCarrierScheduler.java | 12 ++++-------- .../MainRunCarrierScheduler.java | 13 +++++-------- 3 files changed, 11 insertions(+), 19 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 abc6c317..4d8c35b3 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/CollectionCarrierScheduler.java @@ -107,7 +107,7 @@ protected void updateShipments() { && pair.carrierService.getId() == carrierPair.carrierService.getId()) { addShipmentLoadElement(lspShipment, tour, serviceActivity); addShipmentTransportElement(lspShipment, tour, serviceActivity); - addShipmentUnloadElement(lspShipment, tour, serviceActivity); + addShipmentUnloadElement(lspShipment, tour); addCollectionTourEndEventHandler(pair.carrierService, lspShipment, resource, tour); addCollectionServiceEventHandler(pair.carrierService, lspShipment, resource); } @@ -211,8 +211,7 @@ private void addCollectionTourEndEventHandler( } } - private void addShipmentUnloadElement( - LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); 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 b78da4e1..ad42d7d2 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -193,7 +193,7 @@ protected void updateShipments() { for (LSPCarrierPair pair : pairs) { if (pair.lspShipment == carrierPair.lspShipment && pair.carrierService.getId() == carrierPair.carrierService.getId()) { - addShipmentLoadElement(lspShipment, tour, serviceActivity); + addShipmentLoadElement(lspShipment, tour); addShipmentTransportElement(lspShipment, tour, serviceActivity); addShipmentUnloadElement(lspShipment, tour, serviceActivity); addDistributionTourStartEventHandler(pair.carrierService, lspShipment, resource, tour); @@ -206,9 +206,7 @@ protected void updateShipments() { } } - private void addShipmentLoadElement( - LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { - + private void addShipmentLoadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentLoadBuilder builder = LspShipmentUtils.ScheduledShipmentLoadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -219,8 +217,7 @@ private void addShipmentLoadElement( } } - int startIndex = - tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); double startTimeOfTransport = legAfterStart.getExpectedDepartureTime(); double cumulatedLoadingTime = 0; @@ -253,8 +250,7 @@ private void addShipmentTransportElement( } } - int startIndex = - tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); final Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); final int serviceIndex = tour.getTourElements().indexOf(serviceActivity); final Leg legBeforeService = (Leg) tour.getTourElements().get(serviceIndex - 1); 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 54bc52b4..33f47487 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -248,7 +248,7 @@ protected void updateShipments() { && pair.carrierService.getId() == carrierPair.carrierService.getId()) { addShipmentLoadElement(LspShipment, tour); addShipmentTransportElement(LspShipment, tour, serviceActivity); - addShipmentUnloadElement(LspShipment, tour, serviceActivity); + addShipmentUnloadElement(LspShipment, tour); addMainTourRunStartEventHandler(pair.carrierService, LspShipment, resource, tour); addMainRunTourEndEventHandler(pair.carrierService, LspShipment, resource, tour); } @@ -268,8 +268,7 @@ private void addShipmentLoadElement(LspShipment lspShipment, Tour tour) { builder.setLogisticChainElement(element); } } - int startIndex = - tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); double startTimeOfTransport = legAfterStart.getExpectedDepartureTime(); double cumulatedLoadingTime = 0; @@ -300,8 +299,7 @@ private void addShipmentTransportElement(LspShipment lspShipment, Tour tour, Tou builder.setLogisticChainElement(element); } } - int startIndex = - tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); double startTimeOfTransport = legAfterStart.getExpectedDepartureTime(); builder.setStartTime(startTimeOfTransport); @@ -320,7 +318,7 @@ private void addShipmentTransportElement(LspShipment lspShipment, Tour tour, Tou .addPlanElement(id, transport); } - private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour, Tour.ServiceActivity serviceActivity) { + private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour) { LspShipmentUtils.ScheduledShipmentUnloadBuilder builder = LspShipmentUtils.ScheduledShipmentUnloadBuilder.newInstance(); builder.setResourceId(resource.getId()); @@ -335,8 +333,7 @@ private void addShipmentUnloadElement(LspShipment lspShipment, Tour tour, Tour.S cumulatedLoadingTime = cumulatedLoadingTime + activity.getDuration(); } } - int startIndex = - tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); + int startIndex = tour.getTourElements().indexOf(tour.getTourElements().indexOf(tour.getStart())); Leg legAfterStart = (Leg) tour.getTourElements().get(startIndex + 1); builder.setStartTime( legAfterStart.getExpectedDepartureTime() + legAfterStart.getExpectedTransportTime()); From 28217d0dd5f38c01e012c0d6c6e3abea993e15c3 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 14:26:28 +0200 Subject: [PATCH 20/21] some encapsulation. fix and comment test --- ...hipmentsSecondReloadLSPSchedulingTest.java | 104 ++++++++-------- .../SecondReloadLSPSchedulingTest.java | 112 ++++++++++-------- 2 files changed, 122 insertions(+), 94 deletions(-) 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 42425002..4766d616 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/MultipleShipmentsSecondReloadLSPSchedulingTest.java @@ -354,63 +354,73 @@ public void testSecondReloadLSPScheduling() { assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } - assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); - ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); - Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); - - while (iter.hasNext()) { - Entry entry = iter.next(); - CarrierService service = entry.getKey(); - LspShipment shipment = entry.getValue().lspShipment; - LogisticChainElement element = entry.getValue().element; - assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); - assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - boolean handledByTranshipmentHub = false; - for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { - if (clientElement == element) { - handledByTranshipmentHub = true; - break; + { + assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); + ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); + Iterator> + iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); + + while (iter.hasNext()) { + Entry + entry = iter.next(); + CarrierService service = entry.getKey(); + LspShipment shipment = entry.getValue().lspShipment; + LogisticChainElement element = entry.getValue().element; + assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); + boolean handledByTranshipmentHub = false; + for (LogisticChainElement clientElement : + reloadEventHandler.getTranshipmentHub().getClientElements()) { + if (clientElement == element) { + handledByTranshipmentHub = true; + break; + } } - } - assertTrue(handledByTranshipmentHub); + assertTrue(handledByTranshipmentHub); - assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); - assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + //There IS a next element following the 1st hub, so the outgoing shipments does NOT contain the shipment anymore (got handled). + assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + } } - assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); - eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); - iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); - - while (iter.hasNext()) { - Entry entry = iter.next(); - CarrierService service = entry.getKey(); - LspShipment shipment = entry.getValue().lspShipment; - LogisticChainElement element = entry.getValue().element; - assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); - assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - boolean handledByTranshipmentHub = false; - for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { - if (clientElement == element) { - handledByTranshipmentHub = true; - break; + { + assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); + ArrayList eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); + Iterator> + iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); + + while (iter.hasNext()) { + Entry entry = iter.next(); + CarrierService service = entry.getKey(); + LspShipment shipment = entry.getValue().lspShipment; + LogisticChainElement element = entry.getValue().element; + assertSame(service.getLocationLinkId(), toLinkId); + assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); + boolean handledByTranshipmentHub = false; + for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { + if (clientElement == element) { + handledByTranshipmentHub = true; + break; + } } - } - assertTrue(handledByTranshipmentHub); + assertTrue(handledByTranshipmentHub); - assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); - assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + //There is NO next element following the 2nd hub, so the outgoing shipments remain in the list of the 2nd hub. + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + } } for (LspShipment shipment : lsp.getLspShipments()) { assertEquals(4, shipment.getSimulationTrackers().size()); - eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); + ArrayList> eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); 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 69d5e998..f7a32ede 100644 --- a/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java +++ b/src/test/java/org/matsim/freight/logistics/resourceImplementations/SecondReloadLSPSchedulingTest.java @@ -354,63 +354,81 @@ public void testSecondReloadLSPScheduling() { assertSame(planElements.getFirst().getLogisticChainElement(), collectionElement); } - assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); - ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); - assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); - TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); - Iterator> iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); - - while (iter.hasNext()) { - Entry entry = iter.next(); - CarrierService service = entry.getKey(); - LspShipment shipment = entry.getValue().lspShipment; - LogisticChainElement element = entry.getValue().element; - assertSame(service.getLocationLinkId(), shipment.getFrom()); - assertEquals(service.getCapacityDemand(), shipment.getSize()); - assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - boolean handledByTranshipmentHub = false; - for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { - if (clientElement == element) { - handledByTranshipmentHub = true; - break; + { + assertEquals(1, firstTranshipmentHubResource.getSimulationTrackers().size()); + ArrayList eventHandlers = new ArrayList<>(firstTranshipmentHubResource.getSimulationTrackers()); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); + TransshipmentHubTourEndEventHandler reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); + Iterator> + iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); + + while (iter.hasNext()) { + Entry + entry = iter.next(); + CarrierService service = entry.getKey(); + LspShipment shipment = entry.getValue().lspShipment; + LogisticChainElement element = entry.getValue().element; + assertSame(service.getLocationLinkId(), shipment.getFrom()); + assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); + boolean handledByTranshipmentHub = false; + for (LogisticChainElement clientElement : + reloadEventHandler.getTranshipmentHub().getClientElements()) { + if (clientElement == element) { + handledByTranshipmentHub = true; + break; + } } - } - assertTrue(handledByTranshipmentHub); + assertTrue(handledByTranshipmentHub); - assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); - assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + //There IS a next element following the 1st hub, so the outgoing shipments does NOT contain the shipment anymore (got handled). + assertFalse(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + } } - assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); - eventHandlers = new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); - assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); - reloadEventHandler = (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); - iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); - - while (iter.hasNext()) { - Entry entry = iter.next(); - CarrierService service = entry.getKey(); - LspShipment shipment = entry.getValue().lspShipment; - LogisticChainElement element = entry.getValue().element; - assertSame(service.getLocationLinkId(), toLinkId); - assertEquals(service.getCapacityDemand(), shipment.getSize()); - assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); - boolean handledByTranshipmentHub = false; - for (LogisticChainElement clientElement : reloadEventHandler.getTranshipmentHub().getClientElements()) { - if (clientElement == element) { - handledByTranshipmentHub = true; - break; + { + assertEquals(1, secondTranshipmentHubResource.getSimulationTrackers().size()); + ArrayList eventHandlers = + new ArrayList<>(secondTranshipmentHubResource.getSimulationTrackers()); + assertInstanceOf(TransshipmentHubTourEndEventHandler.class, eventHandlers.getFirst()); + TransshipmentHubTourEndEventHandler reloadEventHandler = + (TransshipmentHubTourEndEventHandler) eventHandlers.getFirst(); + Iterator< + Entry< + CarrierService, + TransshipmentHubTourEndEventHandler.TransshipmentHubEventHandlerPair>> + iter = reloadEventHandler.getServicesWaitedFor().entrySet().iterator(); + + while (iter.hasNext()) { + Entry + entry = iter.next(); + CarrierService service = entry.getKey(); + LspShipment shipment = entry.getValue().lspShipment; + LogisticChainElement element = entry.getValue().element; + assertSame(service.getLocationLinkId(), toLinkId); + assertEquals(service.getCapacityDemand(), shipment.getSize()); + assertEquals(service.getServiceDuration(), shipment.getDeliveryServiceTime(), 0.0); + boolean handledByTranshipmentHub = false; + for (LogisticChainElement clientElement : + reloadEventHandler.getTranshipmentHub().getClientElements()) { + if (clientElement == element) { + handledByTranshipmentHub = true; + break; + } } - } - assertTrue(handledByTranshipmentHub); + assertTrue(handledByTranshipmentHub); - assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); - assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + //There is NO next element following the 2nd hub, so the outgoing shipments remain in the list of the 2nd hub. + assertTrue(element.getOutgoingShipments().getLspShipmentsWTime().contains(shipment)); + assertFalse(element.getIncomingShipments().getLspShipmentsWTime().contains(shipment)); + } } + for (LspShipment shipment : lsp.getLspShipments()) { assertEquals(4, shipment.getSimulationTrackers().size()); - eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); + ArrayList eventHandlers = new ArrayList<>(shipment.getSimulationTrackers()); ArrayList planElements = new ArrayList<>(LspShipmentUtils.getOrCreateShipmentPlan(lsp.getSelectedPlan(), shipment.getId()).getPlanElements().values()); planElements.sort(LspShipmentUtils.createShipmentPlanElementComparator()); ArrayList solutionElements = new ArrayList<>(lsp.getSelectedPlan().getLogisticChains().iterator().next().getLogisticChainElements()); From d583037644b58a658033a28f5a8a7d1a17ca2089 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Wed, 14 Aug 2024 14:42:06 +0200 Subject: [PATCH 21/21] remove the temporarily added get/setTime(..) methods. They where only there for make refactoring a bit easier. --- .../matsim/freight/logistics/LSPResourceScheduler.java | 4 ++-- .../matsim/freight/logistics/WaitingShipmentsImpl.java | 6 +++--- .../DistributionCarrierScheduler.java | 2 +- .../MainRunCarrierScheduler.java | 10 +++++----- .../TransshipmentHubScheduler.java | 6 +++--- .../matsim/freight/logistics/shipment/LspShipment.java | 4 ---- .../freight/logistics/shipment/LspShipmentImpl.java | 10 ---------- 7 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java index 83c5e555..c63d9258 100644 --- a/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/LSPResourceScheduler.java @@ -83,14 +83,14 @@ private void presortIncomingShipments() { for (LogisticChainElement element : resource.getClientElements()) { lspShipmentsToSchedule.addAll(element.getIncomingShipments().getLspShipmentsWTime()); } - lspShipmentsToSchedule.sort(Comparator.comparingDouble(LspShipment::getTime)); + lspShipmentsToSchedule.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment)); } private void switchHandledShipments(int bufferTime) { for (LspShipment lspShipmentWithTime : lspShipmentsToSchedule) { var shipmentPlan = LspShipmentUtils.getOrCreateShipmentPlan(lspPlan, lspShipmentWithTime.getId()); double endOfTransportTime = shipmentPlan.getMostRecentEntry().getEndTime() + bufferTime; - lspShipmentWithTime.setTime(endOfTransportTime); + LspShipmentUtils.setTimeOfLspShipment(lspShipmentWithTime, endOfTransportTime); for (LogisticChainElement element : resource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipmentWithTime)) { element.getIncomingShipments().getLspShipmentsWTime().remove(lspShipmentWithTime); diff --git a/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java b/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java index dc06af7f..6404d32a 100644 --- a/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java +++ b/src/main/java/org/matsim/freight/logistics/WaitingShipmentsImpl.java @@ -37,14 +37,14 @@ @Override public void addShipment(double time, LspShipment lspShipment) { - lspShipment.setTime(time); + LspShipmentUtils.setTimeOfLspShipment(lspShipment, time); this.shipments.add(lspShipment); - shipments.sort(Comparator.comparingDouble(LspShipment::getTime)); + shipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment)); } @Override public Collection getSortedLspShipments() { - shipments.sort(Comparator.comparingDouble(LspShipment::getTime)); + shipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment)); return shipments; } 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 ad42d7d2..16aae7ca 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/DistributionCarrierScheduler.java @@ -110,7 +110,7 @@ protected void scheduleResource() { shipmentsInCurrentTour.add(lspShipment); load = load + lspShipment.getSize(); cumulatedLoadingTime = cumulatedLoadingTime + lspShipment.getDeliveryServiceTime(); - availabilityTimeOfLastShipment = lspShipment.getTime(); + availabilityTimeOfLastShipment = LspShipmentUtils.getTimeOfLspShipment(lspShipment); } if (!shipmentsInCurrentTour.isEmpty()) { 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 33f47487..18846fc8 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/MainRunCarrierScheduler.java @@ -78,7 +78,7 @@ protected void initializeValues(LSPResource resource) { protected void scheduleResource() { int load = 0; List copyOfAssignedShipments = new ArrayList<>(lspShipmentsToSchedule); - copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipment::getTime)); + copyOfAssignedShipments.sort(Comparator.comparingDouble(LspShipmentUtils::getTimeOfLspShipment)); ArrayList shipmentsInCurrentTour = new ArrayList<>(); // ArrayList scheduledTours = new ArrayList<>(); List scheduledPlans = new LinkedList<>(); @@ -131,12 +131,12 @@ private CarrierPlan createPlan(Carrier carrier, List lspShipments) tourBuilder.scheduleStart(Id.create(resource.getStartLinkId(), Link.class)); double totalLoadingTime = 0; - double latestTupleTime = 0; + double latestLspShipmentTime = 0; for (LspShipment lspShipment : lspShipments) { totalLoadingTime = totalLoadingTime + lspShipment.getDeliveryServiceTime(); - if (lspShipment.getTime() > latestTupleTime) { - latestTupleTime = lspShipment.getTime(); + if (LspShipmentUtils.getTimeOfLspShipment(lspShipment) > latestLspShipmentTime) { + latestLspShipmentTime = LspShipmentUtils.getTimeOfLspShipment(lspShipment); } tourBuilder.addLeg(new Leg()); CarrierService carrierService = convertToCarrierService(lspShipment); @@ -158,7 +158,7 @@ private CarrierPlan createPlan(Carrier carrier, List lspShipments) Tour vehicleTour = tourBuilder.build(); CarrierVehicle vehicle = carrier.getCarrierCapabilities().getCarrierVehicles().values().iterator().next(); - double tourStartTime = latestTupleTime + totalLoadingTime; + double tourStartTime = latestLspShipmentTime + totalLoadingTime; ScheduledTour sTour = ScheduledTour.newInstance(vehicleTour, vehicle, tourStartTime); tours.add(sTour); diff --git a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java index 9d1d7348..e4d15190 100644 --- a/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java +++ b/src/main/java/org/matsim/freight/logistics/resourceImplementations/TransshipmentHubScheduler.java @@ -74,9 +74,8 @@ private void updateSchedule(LspShipment lspShipment) { private void addShipmentHandleElement(LspShipment lspShipment) { LspShipmentUtils.ScheduledShipmentHandleBuilder builder = LspShipmentUtils.ScheduledShipmentHandleBuilder.newInstance(); - builder.setStartTime(lspShipment.getTime()); - builder.setEndTime( - lspShipment.getTime() + capacityNeedFixed + capacityNeedLinear * lspShipment.getSize()); + builder.setStartTime(LspShipmentUtils.getTimeOfLspShipment(lspShipment)); + builder.setEndTime(LspShipmentUtils.getTimeOfLspShipment(lspShipment) + capacityNeedFixed + capacityNeedLinear * lspShipment.getSize()); builder.setResourceId(transshipmentHubResource.getId()); for (LogisticChainElement element : transshipmentHubResource.getClientElements()) { if (element.getIncomingShipments().getLspShipmentsWTime().contains(lspShipment)) { @@ -84,6 +83,7 @@ private void addShipmentHandleElement(LspShipment lspShipment) { } } LspShipmentPlanElement handle = builder.build(); + String idString = handle.getResourceId() + String.valueOf(handle.getLogisticChainElement().getId()) diff --git a/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java b/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java index 0318f1d1..700f969d 100644 --- a/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java +++ b/src/main/java/org/matsim/freight/logistics/shipment/LspShipment.java @@ -60,8 +60,4 @@ public interface LspShipment Collection getRequirements(); - ///--- - double getTime(); - void setTime(double time); - } diff --git a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java index 7f498c4f..8ff44b2a 100644 --- a/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java +++ b/src/main/java/org/matsim/freight/logistics/shipment/LspShipmentImpl.java @@ -100,16 +100,6 @@ public Collection getRequirements() { return lspShipmentRequirements; } - @Override - public double getTime() { - return LspShipmentUtils.getTimeOfLspShipment(this); - } - - @Override - public void setTime(double time) { - LspShipmentUtils.setTimeOfLspShipment(this, time); - } - @Override public double getPickupServiceTime() { return pickupServiceTime;