Skip to content

Commit

Permalink
Merge pull request #3069 from steffenaxer/drtCompanionLegLvl
Browse files Browse the repository at this point in the history
Clear PassengerGroupIdentifier (DrtCompanion)
  • Loading branch information
steffenaxer authored Jan 23, 2024
2 parents 641bbc7 + 4ea0e28 commit 817303c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ final class DrtCompanionRideGenerator implements BeforeMobsimListener, AfterMobs
private final Scenario scenario;
private final String drtMode;
private final int maxCapacity;

private final Set<Id<Person>> companionAgentIds = new HashSet<>();
private final Set<Leg> drtLegs = new HashSet<>();
private WeightedRandomSelection<Integer> sampler;

private final Map<Id<PassengerGroupIdentifier.PassengerGroup>, List<GroupLeg>> passengerGroups = new HashMap<>();
Expand Down Expand Up @@ -113,6 +113,7 @@ private void addCompanionAgents() {

for (Leg leg : trip.getLegsOnly()) {
if (leg.getMode().equals(this.drtMode)) {
this.drtLegs.add(leg);
// Initial person travels now in a group
Id<PassengerGroupIdentifier.PassengerGroup> currentGroupIdentifier = getGroupIdentifier();
DrtCompanionUtils.setPassengerGroupIdentifier(leg, currentGroupIdentifier);
Expand Down Expand Up @@ -221,6 +222,10 @@ private void removeCompanionAgents() {
passengerGroups.clear();
personIdentifierSuffix.set(0);
LOG.info("Removed # {} drt companion agents", counter);

// Remove attribute from legs of initial drt riders
this.drtLegs.stream().forEach(DrtCompanionUtils::removePassengerGroupIdentifier);
this.drtLegs.clear();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,9 @@ public static void setPassengerGroupIdentifier(Leg leg, Id<PassengerGroupIdentif
leg.getAttributes().putAttribute(GROUP_IDENTIFIER_ATTRIBUTE, passengerGroupIdentifierId);
}

public static void removePassengerGroupIdentifier(Leg leg)
{
leg.getAttributes().removeAttribute(GROUP_IDENTIFIER_ATTRIBUTE);
}

}

0 comments on commit 817303c

Please sign in to comment.