Skip to content

Commit

Permalink
Ensure unique identifier (#3030)
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenaxer authored Dec 31, 2023
1 parent d0633a7 commit a165e1e
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit a165e1e

Please sign in to comment.