diff --git a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java index 5429ca3feed..66f552ee730 100644 --- a/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java +++ b/contribs/drt-extensions/src/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionRideGenerator.java @@ -87,6 +87,7 @@ private void installSampler(DrtWithExtensionsConfigGroup drtWithExtensionsConfig } void addCompanionAgents() { + int identifier = 0; HashMap drtCompanionAgents = new HashMap<>(); Collection companions = new ArrayList<>(); for (Person person : this.scenario.getPopulation().getPersons().values()) { @@ -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++; } } } @@ -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);