public final PlanStrategy build() { PlanStrategyImpl impl = new PlanStrategyImpl(planSelector) ; for (PlanStrategyModule module : modules) { impl.addStrategyModule(module); } return impl; } }
@Override public void finish() { delegate.finish(); } }
@Override public void init(ReplanningContext replanningContext) { delegate.init(replanningContext); }
protected StrategyCounter(final PlanSelector<Plan, Person> selector) { planStrategyDelegate = new PlanStrategyImpl( selector ) ; }
@Override public void init(ReplanningContext replanningContext) { /* * Somehow this is ugly. Should be initialized in the constructor. But I do not know, how to initialize the lc scenario elements * such that they are already available at the time of constructing this object. ah feb'13 */ DestinationChoiceContext lcContext = (DestinationChoiceContext) scenario.getScenarioElement(DestinationChoiceContext.ELEMENT_NAME); Config config = lcContext.getScenario().getConfig(); DestinationChoiceConfigGroup dccg = (DestinationChoiceConfigGroup) config.getModule(DestinationChoiceConfigGroup.GROUP_NAME); MaxDCScoreWrapper maxDcScoreWrapper = (MaxDCScoreWrapper)scenario.getScenarioElement(MaxDCScoreWrapper.ELEMENT_NAME); if ( !DestinationChoiceConfigGroup.Algotype.bestResponse.equals(dccg.getAlgorithm())) { throw new RuntimeException("wrong class for selected location choice algorithm type; aborting ...") ; } String planSelector = dccg.getPlanSelector(); if (planSelector.equals("BestScore")) { delegate = new PlanStrategyImpl(new BestPlanSelector<Plan, Person>()); } else if (planSelector.equals("ChangeExpBeta")) { delegate = new PlanStrategyImpl(new ExpBetaPlanChanger(config.planCalcScore().getBrainExpBeta())); } else if (planSelector.equals("SelectRandom")) { delegate = new PlanStrategyImpl(new RandomPlanSelector()); } else { delegate = new PlanStrategyImpl(new ExpBetaPlanSelector(config.planCalcScore())); } delegate.addStrategyModule(new TripsToLegsModule(tripRouterProvider, config.global())); delegate.addStrategyModule(new BestReplyDestinationChoice(tripRouterProvider, lcContext, maxDcScoreWrapper.getPersonsMaxDCScoreUnscaled(), scoringFunctionFactory, travelTimes, travelDisutilities)); delegate.addStrategyModule(new ReRoute(lcContext.getScenario(), tripRouterProvider)); delegate.init(replanningContext); }
/** * @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()); }
@Override public void run(HasPlansAndId<Plan, Person> person) { delegate.run(person); }
public void addStrategyModule(PlanStrategyModule module) { planStrategyDelegate.addStrategyModule(module); }
public static boolean isOnlySelector(GenericPlanStrategy<Plan, Person> planStrategy) { if (planStrategy instanceof PlanStrategyImpl) { return ((PlanStrategyImpl) planStrategy).getNumberOfStrategyModules() == 0; } return false; }
@Override public String toString() { return planStrategyDelegate.toString(); }
@Override public PlanStrategy get() { PlanStrategy strategy = new PlanStrategyImpl(new BestPlanSelector()); return strategy; }
@Override public void run(HasPlansAndId<Plan, Person> person) { this.strategy.run(person); }
public int getNumberOfStrategyModules() { return planStrategyDelegate.getNumberOfStrategyModules(); }
@Override public PlanStrategy get() { final PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); strategy.addStrategyModule(new TimeAllocationMutator(this.tripRouterProvider, this.plansConfigGroup, this.timeAllocationMutatorConfigGroup, this.globalConfigGroup, this.population)); strategy.addStrategyModule(new ReRoute(this.activityFacilities, this.tripRouterProvider, this.globalConfigGroup)); return strategy; } }
@Override public PlanStrategy get() { return new PlanStrategyImpl(new ExpBetaPlanSelector(config)); }
@Override public void finish() { this.strategy.finish(); }
@Override public void run(HasPlansAndId<Plan, Person> person) { delegate.run(person); }
@Override public void init(ReplanningContext replanningContext) { this.strategy.init(replanningContext); }
@Override public PlanStrategy get() { PlanStrategyImpl strategy = new PlanStrategyImpl(new RandomPlanSelector()); strategy.addStrategyModule(new org.matsim.core.replanning.modules.SubtourModeChoice(tripRouterProvider, globalConfigGroup, subtourModeChoiceConfigGroup)); strategy.addStrategyModule(new ReRoute(facilities, tripRouterProvider, globalConfigGroup)); return strategy; }
@Override public PlanStrategy get() { PlanStrategy strategy = new PlanStrategyImpl(new RandomPlanSelector()); return strategy; }