21 package org.matsim.core.replanning.selectors;
23 import java.util.LinkedHashMap;
26 import org.apache.logging.log4j.LogManager;
40 protected static final double MIN_WEIGHT = Double.MIN_VALUE;
41 protected final double beta;
44 this.beta = logitScaleFactor ;
58 Map<T, Double> weights = this.calcWeights(person);
60 double sumWeights = 0.0;
61 for (Double weight : weights.values()) {
68 selnum -= weights.get(plan);
93 if (plan.getScore() == null) {
96 double weight = Math.exp(this.beta * (plan.getScore() - maxScore));
109 double maxScore = Double.NEGATIVE_INFINITY;
111 if ( (plan1.getScore() != null) && plan1.getScore().isNaN() ) {
112 LogManager.getLogger(this.getClass()).error(
"encountering getScore().isNaN(). This class is not well behaved in this situation. Continuing anyway ...") ;
114 if ((plan1.getScore() != null) && (plan1.getScore() > maxScore)) {
115 maxScore = plan1.getScore();
119 Map<T, Double> weights =
new LinkedHashMap<T, Double>(person.
getPlans().size());
133 Map<T, Double> weights = expBetaPlanSelector.calcWeights(person);
134 double thisWeight = weights.get(plan);
136 double sumWeights = 0.0;
137 for (Double weight : weights.values()) {
138 sumWeights += weight;
141 return (thisWeight / sumWeights);
static final double MIN_WEIGHT
static Random getRandom()
T selectPlan(final HasPlansAndId< T, I > person)
double calcPlanWeight(final T plan, final double maxScore)
ExpBetaPlanSelector(final double logitScaleFactor)
ExpBetaPlanSelector(ScoringConfigGroup charyparNagelScoringConfigGroup)
abstract List<? extends T > getPlans()
static< T extends BasicPlan, I > double getSelectionProbability(ExpBetaPlanSelector< T, I > expBetaPlanSelector, HasPlansAndId< T, ?> person, final T plan)