Class GenericStrategyManager<PL extends BasicPlan,​AG extends HasPlansAndId<? extends BasicPlan,​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)
    • 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.
      • 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 to WorstPlanForRemovalSelector.

        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.
        The implication seems to be: divide the user-configured beta by two, use one half for choice and the other for plans removal.

        The path size version still needs to be tested (both for choice and for plans removal).
        See Also:
        setMaxPlansPerAgent(int)