From ef954c172ca50696894334734eb054ecf3bf7bf3 Mon Sep 17 00:00:00 2001 From: Ricardo Ewert Date: Fri, 21 Jun 2024 11:22:59 +0200 Subject: [PATCH] simplify --- .../DemandReaderFromCSV.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java index 8c323946cb5..15af77ce3f5 100644 --- a/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java +++ b/contribs/application/src/main/java/org/matsim/freightDemandGeneration/DemandReaderFromCSV.java @@ -902,8 +902,8 @@ else if (population == null) HashMap, Link> demandBasesLinks; double sumOfDemandBasedLinks; boolean pickupIsDemandBase = true; - Link linkPickup; - Link linkDelivery; + Link linkPickup = null; + Link linkDelivery= null; double sumOfPossibleLinkLengthPickup = possibleLinksPickup.values().stream().mapToDouble(Link::getLength).sum(); double sumOfPossibleLinkLengthDelivery = possibleLinksDelivery.values().stream().mapToDouble(Link::getLength).sum(); if (numberOfPickupLocations == null && numberOfDeliveryLocations == null) @@ -928,11 +928,7 @@ else if (numberOfPickupLocations != null) { demandBasedLink); if (pickupIsDemandBase) { linkPickup = demandBasedLink; - linkDelivery = findNextUsedLink(scenario, indexShape, possibleLinksDelivery, - numberOfDeliveryLocations, areasForDeliveryLocations, setLocationsOfDelivery, - usedDeliveryLocations, possiblePersonsDelivery, nearestLinkPerPersonDelivery, - crsTransformationNetworkAndShape, countOfLinks - 1); - while (usedDeliveryLocations.contains(linkDelivery.getId().toString())) { + while (linkDelivery == null || usedDeliveryLocations.contains(linkDelivery.getId().toString())) { linkDelivery = findNextUsedLink(scenario, indexShape, possibleLinksDelivery, numberOfDeliveryLocations, areasForDeliveryLocations, setLocationsOfDelivery, usedDeliveryLocations, possiblePersonsDelivery, nearestLinkPerPersonDelivery, @@ -944,11 +940,7 @@ else if (numberOfPickupLocations != null) { } } else { linkDelivery = demandBasedLink; - linkPickup = findNextUsedLink(scenario, indexShape, possibleLinksPickup, - numberOfPickupLocations, areasForPickupLocations, setLocationsOfPickup, - usedPickupLocations, possiblePersonsPickup, nearestLinkPerPersonPickup, - crsTransformationNetworkAndShape, countOfLinks - 1); - while (usedPickupLocations.contains(linkPickup.getId().toString())) { + while (linkPickup == null || usedPickupLocations.contains(linkPickup.getId().toString())) { linkPickup = findNextUsedLink(scenario, indexShape, possibleLinksPickup, numberOfPickupLocations, areasForPickupLocations, setLocationsOfPickup, usedPickupLocations, possiblePersonsPickup, nearestLinkPerPersonPickup,