MATSIM
ActivityEndIdentifier.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * ActivityEndIdentifier.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2011 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.withinday.replanning.identifiers;
22 
23 import java.util.Set;
24 import java.util.TreeSet;
25 
26 import org.matsim.api.core.v01.Id;
31 
33 
35 
36  // use the Factory!
37  /*package*/ ActivityEndIdentifier(ActivityReplanningMap activityReplanningMap) {
38  this.activityReplanningMap = activityReplanningMap;
39  }
40 
41  @Override
42  public Set<MobsimAgent> getAgentsToReplan(double time) {
43  Set<MobsimAgent> agentsToReplan = new TreeSet<MobsimAgent>(new ById());
44 
45  for (MobsimAgent mobsimAgent : this.activityReplanningMap.getActivityEndingAgents(time)) {
46  Id<Person> agentId = mobsimAgent.getId();
47  if (this.applyFilters(agentId, time)) agentsToReplan.add(mobsimAgent);
48  }
49 
50  /*
51  * Here was lots of additional code that identified agents which ended their activity, then
52  * performed a leg starting and ending on the same link and then performed an activity with
53  * duration of 0 seconds. Such agents then start the leg after the next activity in the next
54  * time step. As a result, that leg was not replanned. However, Performing this check should
55  * be implemented at another place (i.e. in a replanner or in a module that ensure that each
56  * activity has a duration of at least one second).
57  *
58  * cdobler, aug'13
59  */
60 
61  return agentsToReplan;
62  }
63 
64 }
final void applyFilters(Set< Id< Person >> set, double time)