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

Bugfix: DrtCompanion - Ensure unique identifier #3030

Merged
merged 1 commit into from
Dec 31, 2023
Merged
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 @@ -87,6 +87,7 @@ private void installSampler(DrtWithExtensionsConfigGroup drtWithExtensionsConfig
}

void addCompanionAgents() {
int identifier = 0;
HashMap<String, Integer> drtCompanionAgents = new HashMap<>();
Collection<Person> companions = new ArrayList<>();
for (Person person : this.scenario.getPopulation().getPersons().values()) {
Expand All @@ -104,7 +105,8 @@ void addCompanionAgents() {
int groupPart = i;

companions.add(createCompanionAgent(mainMode, person, trip, trip.getOriginActivity(),
trip.getDestinationActivity(), groupPart, groupSize));
trip.getDestinationActivity(), groupPart, groupSize, identifier));
identifier++;
}
}
}
Expand All @@ -120,9 +122,9 @@ void addCompanionAgents() {
}

private Person createCompanionAgent(String drtMode, Person originalPerson, TripStructureUtils.Trip trip,
Activity fromActivity, Activity toActivity, int groupPart, int groupSize) {
Activity fromActivity, Activity toActivity, int groupPart, int groupSize, int identifier) {
String prefix = getCompanionPrefix(drtMode);
String companionId = prefix + "_" + originalPerson.getId().toString() + "_" + groupPart;
String companionId = prefix + "_" + originalPerson.getId().toString() + "_" + identifier;
Person person = PopulationUtils.getFactory().createPerson(Id.createPersonId(companionId));
DrtCompanionUtils.setDRTCompanionType(person, DRT_COMPANION_TYPE);

Expand Down
Loading