MATSIM
withinday
replanning
identifiers
filter
ActivityStartingFilter.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* ActivityStartingFilter.java
4
* *
5
* *********************************************************************** *
6
* *
7
* copyright : (C) 2013 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.filter;
22
23
import
java.util.Iterator;
24
import
java.util.Map;
25
import
java.util.Set;
26
27
import
org
.
matsim
.
api
.
core
.
v01
.
Id
;
28
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Person
;
29
import
org
.
matsim
.
core
.
mobsim
.
framework
.
DriverAgent
;
30
import
org
.
matsim
.
core
.
mobsim
.
framework
.
MobsimAgent
;
31
import
org
.
matsim
.
withinday
.
replanning
.
identifiers
.
interfaces
.
AgentFilter
;
32
39
public
class
ActivityStartingFilter
implements
AgentFilter
{
40
41
private
final
Map<Id<Person>,
MobsimAgent
>
agents
;
42
43
// use the factory
44
/*package*/
ActivityStartingFilter
(Map<
Id<Person>
,
MobsimAgent
> agents) {
45
this.agents =
agents
;
46
}
47
48
@Override
49
public
void
applyAgentFilter
(Set<
Id<Person>
>
set
,
double
time) {
50
Iterator<Id<Person>> iter =
set
.iterator();
51
52
while
(iter.hasNext()) {
53
Id<Person>
id
= iter.next();
54
55
if
(!this.
applyAgentFilter
(
id
, time)) iter.remove();
56
}
57
}
58
59
@Override
60
public
boolean
applyAgentFilter
(
Id<Person>
id
,
double
time) {
61
MobsimAgent
agent = this.agents.get(
id
);
62
// check whether the agent is performing a leg
63
if
(!(agent.
getState
() ==
MobsimAgent
.
State
.
LEG
))
return
false
;
64
65
/*
66
* Check whether the agent ends its leg on the current link. If
67
* yes, remove the agent from the set.
68
*/
69
DriverAgent
driver = (
DriverAgent
) agent;
70
// Id<Link> nextLinkId = driver.chooseNextLinkId();
71
// if (nextLinkId == null) return false;
72
if
( driver.
isWantingToArriveOnCurrentLink
() )
return
false
;
73
74
return
true
;
75
}
76
77
}
org.matsim.api.core.v01.Id
Definition:
Id.java:44
org.matsim.core.mobsim.framework.MobsimAgent.State.LEG
LEG
Definition:
MobsimAgent.java:44
org.matsim.core.mobsim.framework
Definition:
AbstractMobsimModule.java:22
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.withinday.replanning.identifiers.interfaces
Definition:
AgentFilter.java:21
org
org.matsim.core.mobsim.framework.MobsimAgent.State
Definition:
MobsimAgent.java:43
org.matsim.core.mobsim.framework.MobsimAgent
Definition:
MobsimAgent.java:41
org.matsim.core.mobsim
Definition:
DefaultMobsimModule.java:23
org.matsim.api
org.matsim.withinday.replanning.identifiers
Definition:
ActivityEndIdentifier.java:21
org.matsim.withinday.replanning
org.matsim.core.mobsim.framework.MobsimAgent.getState
State getState()
org.matsim.core
org.matsim.withinday.replanning.identifiers.filter.ActivityStartingFilter.applyAgentFilter
boolean applyAgentFilter(Id< Person > id, double time)
Definition:
ActivityStartingFilter.java:60
org.matsim.withinday
org.matsim.api.core
org.matsim.withinday.replanning.identifiers.filter.ActivityStartingFilter.agents
final Map< Id< Person >, MobsimAgent > agents
Definition:
ActivityStartingFilter.java:41
org.matsim.core.mobsim.framework.DriverAgent
Definition:
DriverAgent.java:33
org.matsim.core.mobsim.framework.DriverAgent.isWantingToArriveOnCurrentLink
boolean isWantingToArriveOnCurrentLink()
org.matsim.withinday.replanning.identifiers.filter.ActivityStartingFilter.applyAgentFilter
void applyAgentFilter(Set< Id< Person >> set, double time)
Definition:
ActivityStartingFilter.java:49
org.matsim.withinday.replanning.identifiers.filter.ActivityStartingFilter
Definition:
ActivityStartingFilter.java:39
org.matsim
org.matsim.api.core.v01.population.Person
Definition:
Person.java:28
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
org.matsim.withinday.replanning.identifiers.interfaces.AgentFilter
Definition:
AgentFilter.java:36
Generated by
1.8.13