Skip to content

Commit

Permalink
Merge pull request #3062 from steffenaxer/DrtCompanionRideGenerator
Browse files Browse the repository at this point in the history
Make companion validation work with facilities
  • Loading branch information
steffenaxer authored Jan 20, 2024
2 parents 278463c + 846e6d6 commit f0c388b
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,23 @@ private void addCompanionAgents() {
private void validateGroups() {
this.passengerGroups.values().forEach(g -> {
GroupTrip representative = g.get(0);
Id<Link> fromLinkId = representative.trip.getOriginActivity().getLinkId();
Id<Link> toLinkId = representative.trip.getDestinationActivity().getLinkId();

Id<Link> fromLinkId = PopulationUtils.decideOnLinkIdForActivity(
representative.trip.getOriginActivity(),scenario);
Id<Link> 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);
});
}
Expand Down

0 comments on commit f0c388b

Please sign in to comment.