private static List<JointTrip> getChoiceSet( final JointTravelStructure structure, final Collection<Id<Person>> agentsToIgnore) { if (agentsToIgnore.isEmpty()) return structure.getJointTrips(); final List<JointTrip> choiceSet = new ArrayList<JointTrip>(); for (JointTrip t : structure.getJointTrips()) { if (agentsToIgnore.contains(t.getDriverId())) continue; if (agentsToIgnore.contains(t.getPassengerId())) continue; choiceSet.add(t); } return choiceSet; }
public ActedUponInformation run( final JointPlan plan, final Collection<Id<Person>> agentsToIgnore) { final JointTravelStructure structure = JointTravelUtils.analyseJointTravel(plan); if (structure.getJointTrips().size() == 0) { log.warn( getClass().getSimpleName() + " was called on a plan with no joint trips." + " Make sure it is what you want!"); return null; } final List<JointTrip> choiceSet = getChoiceSet(structure, agentsToIgnore); if (choiceSet.isEmpty()) return null; final JointTrip toRemove = choiceSet.get(random.nextInt(choiceSet.size())); removePassengerTrip(toRemove, plan); removeDriverTrip(toRemove, plan); return new ActedUponInformation(toRemove.getDriverId(), toRemove.getPassengerId()); }