/** * Finishes the calculation of the plans' scores and assigns the new scores * to the plans if desired. */ public void finish() { if (iteration == -1) { throw new RuntimeException("Please initialize me before the iteration starts."); } controlerListenerManager.fireControlerAfterMobsimEvent(iteration); scoringFunctionsForPopulation.finishScoringFunctions(); newScoreAssigner.assignNewScores(this.iteration, scoringFunctionsForPopulation, population); finished = true; }
@Override public void notifyScoring(final ScoringEvent event) { scoringFunctionsForPopulation.finishScoringFunctions(); NewScoreAssignerImpl newScoreAssigner = new NewScoreAssignerImpl(this.planCalcScoreConfigGroup, this.controlerConfigGroup); newScoreAssigner.assignNewScores(event.getIteration(), this.scoringFunctionsForPopulation, this.population); }
@Test(expected = RuntimeException.class) public void exceptionInScoringFunctionPropagates() { Config config = ConfigUtils.createConfig(); Scenario scenario = ScenarioUtils.createScenario(config); Id<Person> personId = Id.createPersonId(1); scenario.getPopulation().addPerson(scenario.getPopulation().getFactory().createPerson(personId)); EventsManager events = EventsUtils.createEventsManager(config); ControlerListenerManagerImpl controlerListenerManager = new ControlerListenerManagerImpl(); ScoringFunctionFactory throwingScoringFunctionFactory = new ThrowingScoringFunctionFactory(); EventsToActivities e2acts = new EventsToActivities(controlerListenerManager); EventsToLegs e2legs = new EventsToLegs(scenario.getNetwork()); EventsToLegsAndActivities e2legsActs = new EventsToLegsAndActivities(e2legs, e2acts); events.addHandler(e2legsActs); ScoringFunctionsForPopulation scoringFunctionsForPopulation = new ScoringFunctionsForPopulation( controlerListenerManager, events, e2acts, e2legs, scenario.getPopulation(), throwingScoringFunctionFactory ); controlerListenerManager.fireControlerIterationStartsEvent(0); events.processEvent(new PersonMoneyEvent(3600.0, personId, 3.4)); scoringFunctionsForPopulation.finishScoringFunctions(); }
scoringFunctionsForPopulation.finishScoringFunctions();
scoringFunctionsForPopulation.finishScoringFunctions();