From e6fae24296791372cc6deab883721e587e50d74e Mon Sep 17 00:00:00 2001 From: steffenaxer <26229392+steffenaxer@users.noreply.github.com> Date: Sat, 20 Jan 2024 15:39:34 +0100 Subject: [PATCH] Make preconditions work with facilities --- .../companions/DrtCompanionRideGenerator.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java index 6d6abacf50a..4e3b6736b7d 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java @@ -161,12 +161,23 @@ private void addCompanionAgents() { private void validateGroups() { this.passengerGroups.values().forEach(g -> { GroupTrip representative = g.get(0); - Id fromLinkId = representative.trip.getOriginActivity().getLinkId(); - Id toLinkId = representative.trip.getDestinationActivity().getLinkId(); + + Id fromLinkId = PopulationUtils.decideOnLinkIdForActivity( + representative.trip.getOriginActivity(),scenario); + Id toLinkId = PopulationUtils.decideOnLinkIdForActivity( + representative.trip.getDestinationActivity(),scenario); + Preconditions.checkNotNull(fromLinkId); Preconditions.checkNotNull(toLinkId); - Preconditions.checkArgument(g.stream().allMatch(a -> a.trip.getOriginActivity().getLinkId().equals(fromLinkId))); - Preconditions.checkArgument(g.stream().allMatch(a -> a.trip.getDestinationActivity().getLinkId().equals(toLinkId))); + + Preconditions.checkArgument(g.stream().allMatch( + a -> PopulationUtils.decideOnLinkIdForActivity( + a.trip.getOriginActivity(),scenario).equals(fromLinkId))); + + Preconditions.checkArgument(g.stream().allMatch( + a -> PopulationUtils.decideOnLinkIdForActivity( + a.trip.getDestinationActivity(),scenario).equals(toLinkId))); + Preconditions.checkArgument(g.size() <= this.maxCapacity); }); }