@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { this.eventsToFacilityLoad.resetAll(event.getIteration()); }
/** * Notifies all ControlerBeforeMobsimListeners * */ public void fireControlerBeforeMobsimEvent(final int iteration) { BeforeMobsimEvent event = new BeforeMobsimEvent(this.controler, iteration); BeforeMobsimListener[] listener = this.coreListenerList.getListeners(BeforeMobsimListener.class); for (BeforeMobsimListener aListener : listener) { log.info("calling notifyBeforeMobsim on " + aListener.getClass().getName()); aListener.notifyBeforeMobsim(event); } listener = this.listenerList.getListeners(BeforeMobsimListener.class); for (BeforeMobsimListener aListener : listener) { log.info("calling notifyBeforeMobsim on " + aListener.getClass().getName()); aListener.notifyBeforeMobsim(event); } log.info("[it." + iteration + "] all ControlerBeforeMobsimListeners called."); }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { ActivityData overallActivityData = this.overallCount.getLast(); for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) { if (this.observedAgents != null && !this.observedAgents.contains(person.getId())) continue; Plan plan = person.getSelectedPlan(); Activity firstActivity = (Activity) plan.getPlanElements().get(0); LinkedList<ActivityData> list = activityCountData.get(firstActivity.getType()); // ignore not observed activity types if (list == null) continue; ActivityData activityData = list.getLast(); activityData.activityCount += 1; overallActivityData.activityCount += 1; } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { // 2nd major Cadyts method is "analyzer.addToDemand", dz 09/15 // Register demand for this iteration with Cadyts. // Note that planToPlanStep will return null for plans which have never been executed. // This is fine, since the number of these plans will go to zero in normal simulations, // and Cadyts can handle this "noise". Checked this with Gunnar. // mz 2015 for (Person person : event.getServices().getScenario().getPopulation().getPersons().values()) { Plan<Measurement> planSteps = this.measurementListener.getCadytsPlan(person.getSelectedPlan()); this.calibrator.addToDemand(planSteps); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { eventsManager.resetHandlers(event.getIteration()); final boolean writingEventsAtAll = this.writeEventsInterval > 0; final boolean regularWriteEvents = writingEventsAtAll && ( event.getIteration()>0 && event.getIteration() % writeEventsInterval == 0 ) ; // (w/o the "writingEventsAtAll && ..." this is a division by zero when writeEventsInterval=0. kai, apr'18) final boolean earlyIteration = event.getIteration() <= writeMoreUntilIteration ; final boolean lastIteration = event.getIteration()==this.lastIteration ; if (writingEventsAtAll && (regularWriteEvents||earlyIteration || lastIteration ) ) { for (EventsFileFormat format : eventsFileFormats) { switch (format) { case xml: this.eventWriters.add(new EventWriterXML(controlerIO.getIterationFilename(event.getIteration(), Controler.FILENAME_EVENTS_XML))); break; default: log.warn("Unknown events file format specified: " + format.toString() + "."); } } for (EventWriter writer : this.eventWriters) { eventsManager.addHandler(writer); } } }
for (ControlerListener controlerListener : controlerListenersDeclaredByModules) { if (controlerListener instanceof BeforeMobsimListener) { ((BeforeMobsimListener) controlerListener).notifyBeforeMobsim(new BeforeMobsimEvent(null, iterationNumber));
@Override public void notifyBeforeMobsim(final BeforeMobsimEvent event) { if ( !dump( event.getIteration() ) ) return; log.info("dumping joint plans..."); JointPlansXmlWriter.write( sc.getPopulation(), jointPlans, controlerIO.getIterationFilename( event.getIteration(), "jointPlans.xml.gz" )); log.info("finished joint plans dump."); }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { int iter = event.getIteration(); if ( isActiveInThisIteration( iter ) ) { occupancyAnalyzer.reset(iter); eventsManager.addHandler(occupancyAnalyzer); } }
@Override public void notifyBeforeMobsim(final BeforeMobsimEvent event) { final boolean writingPlansAtAll = writePlansInterval > 0; final boolean regularWritePlans = writingPlansAtAll && (event.getIteration()>0 && event.getIteration() % writePlansInterval== 0); final boolean earlyIteration = event.getIteration() <= writeMoreUntilIteration ; if ( writingPlansAtAll && (regularWritePlans || earlyIteration) ) { stopwatch.beginOperation("dump all plans"); log.info("dumping plans..."); final String inputCRS = config.plans().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); if ( inputCRS == null ) { new PopulationWriter(population, network).write(controlerIO.getIterationFilename(event.getIteration(), Controler.FILENAME_POPULATION)); } else { log.info( "re-projecting population from "+internalCRS+" back to "+inputCRS+" for export" ); final CoordinateTransformation transformation = TransformationFactory.getCoordinateTransformation( internalCRS, inputCRS ); new PopulationWriter(transformation, population, network).write(controlerIO.getIterationFilename(event.getIteration(), Controler.FILENAME_POPULATION)); } log.info("finished plans dump."); stopwatch.endOperation("dump all plans"); } }
@Override public void notifyBeforeMobsim(final BeforeMobsimEvent event) { this.cadytsPtOccupAnalyzer.reset(event.getIteration()); for (Person person : scenario.getPopulation().getPersons().values()) { this.calibrator.addToDemand(ptStep.getCadytsPlan(person.getSelectedPlan())); } }
@Override public void notifyBeforeMobsim(BeforeMobsimEvent event) { selectedPlanScoreMemory = new HashMap<>(scenario.getPopulation().getPersons().size()); if (event.getIteration() == 0) { plancatcher.init(); for (Person person : scenario.getPopulation().getPersons().values()) { plancatcher.addPlansForPsim(person.getSelectedPlan()); } } else { for (Person person : scenario.getPopulation().getPersons().values()) { selectedPlanScoreMemory.put(person.getId(), person.getSelectedPlan().getScore()); } for (Plan plan : plancatcher.getPlansForPSim()) { selectedPlanScoreMemory.remove(plan.getPerson().getId()); } } executedPlanCount += plancatcher.getPlansForPSim().size(); }