Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear PassengerGroupIdentifier (DrtCompanion) #3069

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

}
Loading