diff --git a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/depot/Depots.java b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/depot/Depots.java index e074587134b..0d35c029215 100644 --- a/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/depot/Depots.java +++ b/contribs/drt/src/main/java/org/matsim/contrib/drt/optimizer/depot/Depots.java @@ -69,9 +69,9 @@ public static Link findStraightLineNearestDepot(DvrpVehicle vehicle, Set l null /* already at a depot*/ : links.stream().map(l -> new DepotCandidates(l, DistanceUtils.calculateSquaredDistance(currentLink.getToNode().getCoord(), l.getFromNode().getCoord()))) - .sorted(Comparator.comparing(DepotCandidates::distance) + .min(Comparator.comparing(DepotCandidates::distance) .thenComparing(h -> h.link.getId())) - .findFirst().get().link(); + .get().link(); } record DepotCandidates(Link link, double distance) {}