/** * 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. * * @param iteration the current iteration we're handling */ public final void run(final Population population, final int iteration, final ReplanningContext replanningContext) { // (this is not directly delegated since the run method of this StrategyManager includes two "hooks"). delegate.handleChangeRequests(iteration); run(population, replanningContext); }
/** * @param name the name of the subpopulation attribute * in the person's object attributes. */ public final void setSubpopulationAttributeName(final String name) { delegate.setSubpopulationAttributeName(name); }
/** * 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. * */ public final void setMaxPlansPerAgent(final int maxPlansPerAgent) { delegate.setMaxPlansPerAgent(maxPlansPerAgent); }
/** * @author mrieser */ public void testGetNumberOfStrategyModules() { final PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); assertEquals(0, strategy.getNumberOfStrategyModules()); strategy.addStrategyModule(new DummyStrategyModule()); assertEquals(1, strategy.getNumberOfStrategyModules()); strategy.addStrategyModule(new DummyStrategyModule()); assertEquals(2, strategy.getNumberOfStrategyModules()); }
public final PlanStrategy build() { PlanStrategyImpl impl = new PlanStrategyImpl(planSelector) ; for (PlanStrategyModule module : modules) { impl.addStrategyModule(module); } return impl; } }
@Override public void run(HasPlansAndId<Plan, Person> person) { delegate.run(person); }
@Override public void finish() { delegate.finish(); } }
public static boolean isOnlySelector(GenericPlanStrategy<Plan, Person> planStrategy) { if (planStrategy instanceof PlanStrategyImpl) { return ((PlanStrategyImpl) planStrategy).getNumberOfStrategyModules() == 0; } return false; }
/** * 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. * */ public final void addStrategy( final PlanStrategy strategy, final String subpopulation, final double weight) { delegate.addStrategy(strategy, subpopulation, weight); }
/** * changes the weight of the specified strategy * * @return true if the strategy is part of this manager and the weight could * be changed successfully, false otherwise. */ public final boolean changeWeightOfStrategy( final GenericPlanStrategy<Plan, Person> strategy, final String subpopulation, final double newWeight) { return delegate.changeWeightOfStrategy(strategy, subpopulation, newWeight) ; }
/** * @return the weights of the strategies for the given subpopulation, in the same order as the strategies returned by {@link #getStrategies(java.lang.String)} */ public final List<Double> getWeights(final String subpopulation) { return delegate.getWeights(subpopulation); } }
/** * chooses a (weight-influenced) random strategy * * @param person The person for which the strategy should be chosen * @return the chosen strategy */ public GenericPlanStrategy<Plan, Person> chooseStrategy(final Person person, final String subpopulation) { final GenericPlanStrategy<Plan, Person> strategy = delegate.chooseStrategy(person, subpopulation); return strategy; }
/** * chooses a (weight-influenced) random strategy * * @return the chosen strategy */ /* deliberately package */ GenericPlanStrategy<PL, AG> chooseStrategy(HasPlansAndId<PL, AG> person, final String subpopulation) { // yyyyyy I can see that this would need to be replaceable, but need to find some other way than inheritance. kai, mar'18 // Just implemented first step towards pluggability. But ain't there yet. kai, apr'18 return myStrategyChooser.chooseStrategy(person,subpopulation) ; }
@Override public void finish() { delegate.finish(); } }
/** * Schedules a command for a later iteration. The * change will take place before the strategies are applied. * */ public final void addChangeRequest( final int iteration, final PlanStrategy strategy, final String subpopulation, final double newWeight) { delegate.addChangeRequest(iteration, strategy, subpopulation, newWeight); }
@Override public String toString() { return planStrategyDelegate.toString(); }
@Override public void run(HasPlansAndId<Plan, Person> person) { this.strategy.run(person); }
@Override public void finish() { this.strategy.finish(); }
@Override public void run(final HasPlansAndId<Plan, Person> person) { this.counter++; planStrategyDelegate.run(person); }
@Override public void finish() { delegate.finish(); }