Package org.matsim.core.replanning
Class GenericStrategyManager<PL extends BasicPlan,AG extends HasPlansAndId<? extends BasicPlan,AG>>
- java.lang.Object
-
- org.matsim.core.replanning.GenericStrategyManager<PL,AG>
-
- All Implemented Interfaces:
MatsimManager
public class GenericStrategyManager<PL extends BasicPlan,AG extends HasPlansAndId<? extends BasicPlan,AG>> extends Object implements MatsimManager
Notes:- This version is now a bit more restrictive than the original strategy manager in terms of public methods and in terms of final methods. Given subpopulations and pluggable worst plans remover, most situations where inheritance was needed should be gone. Please engage in a discussion with the core team if you think this class should be more liberal. kai, nov'13
- Author:
- nagel (for the generic version), rieser (for the original StrategyManager)
-
-
Constructor Summary
Constructors Constructor Description GenericStrategyManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeRequest(int iteration, GenericPlanStrategy<PL,AG> strategy, String subpopulation, double newWeight)
Schedules achangeWeightOfStrategy(GenericPlanStrategy, String, double)
command for a later iteration.void
addStrategy(GenericPlanStrategy<PL,AG> strategy, String subpopulation, double weight)
Adds a strategy to this manager with the specified weight.List<GenericPlanStrategy<PL,AG>>
getStrategies(String subpopulation)
List<Double>
getWeights(String subpopulation)
void
run(Iterable<? extends HasPlansAndId<PL,AG>> persons, Population population, int iteration, ReplanningContext replanningContext)
Randomly chooses for each person of the population a strategy and uses that strategy on the person, after adapting the strategies to any pending change requests for the specified iteration.void
setMaxPlansPerAgent(int maxPlansPerAgent)
Sets the maximal number of plans an agent can memorize.void
setPlanSelectorForRemoval(PlanSelector<PL,AG> planSelector)
Sets a plan selector to be used for choosing plans for removal, if they have more plans than the specified maximum.
-
-
-
Constructor Detail
-
GenericStrategyManager
public GenericStrategyManager()
-
-
Method Detail
-
addStrategy
public final void addStrategy(GenericPlanStrategy<PL,AG> strategy, String subpopulation, double weight)
Adds a strategy to this manager with the specified weight. This weight compared to the sum of weights of all strategies in this manager defines the probability this strategy will be used for an agent.
-
run
public final void run(Iterable<? extends HasPlansAndId<PL,AG>> persons, Population population, int iteration, ReplanningContext replanningContext)
Randomly chooses for each person of the population a strategy and uses that strategy on the person, after adapting the strategies to any pending change requests for the specified iteration.- Parameters:
iteration
- the current iteration we're handling
-
setMaxPlansPerAgent
public final void setMaxPlansPerAgent(int maxPlansPerAgent)
Sets the maximal number of plans an agent can memorize. Setting maxPlansPerAgent to zero means unlimited memory (only limited by RAM). Agents can have up to maxPlansPerAgent plans plus one additional one with the currently modified plan they're trying out.
-
addChangeRequest
public final void addChangeRequest(int iteration, GenericPlanStrategy<PL,AG> strategy, String subpopulation, double newWeight)
Schedules achangeWeightOfStrategy(GenericPlanStrategy, String, double)
command for a later iteration. The change will take place before the strategies are applied.
-
setPlanSelectorForRemoval
public final void setPlanSelectorForRemoval(PlanSelector<PL,AG> planSelector)
Sets a plan selector to be used for choosing plans for removal, if they have more plans than the specified maximum. This defaults toWorstPlanForRemovalSelector
. Thoughts about using the logit-type selectors with negative logit model scale parameter:- Look at one agent.
- Assume she has the choice between n different plans (although fewer of them are in the MATSim choice set).
- (Continuous) fraction f(i) of plan i develops as (master equation)
df(i)/dt = - p(i) * f(i) + 1/n
where p(i) is from the removal selector, and 1/n makes the assumption that each possible plan is (re-)inserted with equal probability by the innovative modules. - Steady state solution (df/dt=0) f(i) = 1/n * 1/p(i) .
- If p(i) = e-b*U(i), then f(i) = eb*U(i) / n . Or in words: If you use a logit model with a minus in front of the beta for plans removal, the resulting steady state distribution is the same logit model with normal beta.
- See Also:
setMaxPlansPerAgent(int)
-
getStrategies
public final List<GenericPlanStrategy<PL,AG>> getStrategies(String subpopulation)
-
getWeights
public final List<Double> getWeights(String subpopulation)
-
-