MATSIM
core
replanning
selectors
RandomUnscoredPlanSelector.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* RandomPlanSelector.java
4
* *
5
* *********************************************************************** *
6
* *
7
* copyright : (C) 2007 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.core.replanning.selectors;
22
23
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
BasicPlan
;
24
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
HasPlansAndId
;
25
import
org
.
matsim
.
core
.
gbl
.
MatsimRandom
;
26
27
33
public
class
RandomUnscoredPlanSelector
<T
extends
BasicPlan
, I> implements
PlanSelector
<T, I> {
34
39
@Override
40
public
T
selectPlan
(
final
HasPlansAndId<T, I>
person) {
41
// following code copied from PersonImpl and then made runnable
42
43
int
cntUnscored = 0;
44
for
(T plan : person.
getPlans
()) {
45
if
(plan.getScore() == null) {
46
cntUnscored++;
47
}
48
}
49
if
(cntUnscored > 0) {
50
// select one of the unscored plans
51
int
idxUnscored =
MatsimRandom
.
getRandom
().nextInt(cntUnscored);
52
cntUnscored = 0;
53
for
(T plan : person.
getPlans
()) {
54
if
(plan.getScore() == null) {
55
if
(cntUnscored == idxUnscored) {
56
return
plan;
57
}
58
cntUnscored++;
59
}
60
}
61
}
62
return
null;
63
}
64
}
org.matsim.core.gbl.MatsimRandom.getRandom
static Random getRandom()
Definition:
MatsimRandom.java:57
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.api.core.v01.population.BasicPlan
Definition:
BasicPlan.java:24
org
org.matsim.core.replanning.selectors.RandomUnscoredPlanSelector.selectPlan
T selectPlan(final HasPlansAndId< T, I > person)
Definition:
RandomUnscoredPlanSelector.java:40
org.matsim.core.replanning.selectors.RandomUnscoredPlanSelector
Definition:
RandomUnscoredPlanSelector.java:33
org.matsim.api
org.matsim.core
org.matsim.api.core.v01.population.HasPlansAndId
Definition:
HasPlansAndId.java:29
org.matsim.core.gbl
Definition:
Gbl.java:21
org.matsim.api.core
org.matsim
org.matsim.core.replanning.selectors.PlanSelector
Definition:
PlanSelector.java:28
org.matsim.core.gbl.MatsimRandom
Definition:
MatsimRandom.java:33
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
org.matsim.api.core.v01.population.HasPlansAndId.getPlans
abstract List<? extends T > getPlans()
Generated by
1.8.13