@Override public SnapshotWriter get() { String fileName = controlerIO.getIterationFilename(iteration, "T.veh.gz"); return new TransimsSnapshotWriter(fileName); }
public SignalsScenarioWriter(final OutputDirectoryHierarchy controlerIo){ this.pathToSignalSystemsOutputFilename = controlerIo.getOutputFilename(FILENAME_SIGNAL_SYSTEMS); this.pathToSignalGroupsOutputFilename = controlerIo.getOutputFilename(FILENAME_SIGNAL_GROUPS); this.pathToSignalControlOutputFilename = controlerIo.getOutputFilename(FILENAME_SIGNAL_CONTROL); this.pathToAmberTimesOutputFilename = controlerIo.getOutputFilename(FILENAME_AMBER_TIMES); this.pathToIntergreenTimesOutputFilename = controlerIo.getOutputFilename(FILENAME_INTERGREEN_TIMES); this.pathToSignalCSVOutputFilename = controlerIo.getOutputFilename(FILENAME_SIGNAL_CSV); this.pathToConflictingDirectionsOutputFilename = controlerIo.getOutputFilename(FILENAME_CONFLICTING_DIRECTIONS); }
/** * Creates the path where all iteration-related data should be stored. */ public final void createIterationDirectory(final int iteration) { File dir = new File(getIterationPath(iteration)); if (!dir.mkdir()) { if (this.overwriteFiles == OverwriteFileSetting.overwriteExistingFiles && dir.exists()) { log.info("Iteration directory " + getIterationPath(iteration) + " exists already."); } else { log.warn("Could not create iteration directory " + getIterationPath(iteration) + "."); } } }
private void dumpOutputEvents() { try { File toFile = new File( controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_EVENTS_XML)); File fromFile = new File(controlerIO.getIterationFilename(controlerConfigGroup.getLastIteration(), Controler.FILENAME_EVENTS_XML)); try { Files.copy(fromFile.toPath(), toFile.toPath(),StandardCopyOption.REPLACE_EXISTING,StandardCopyOption.COPY_ATTRIBUTES); } catch (IOException e) { throw new UncheckedIOException(e); } } catch ( Exception ee ) { Logger.getLogger(this.getClass()).error("writing output events did not work; probably parameters were such that no events were " + "generated in the final iteration" ); } }
CountsHtmlAndGraphsWriter cgw = new CountsHtmlAndGraphsWriter(controlerIO.getIterationPath(event.getIteration()), cca.getComparison(), event.getIteration()); cgw.addGraphsCreator(new CountsSimRealPerHourGraphCreator("sim and real volumes")); cgw.addGraphsCreator(new CountsErrorGraphCreator("errors")); String filename = controlerIO.getIterationFilename(event.getIteration(), "countscompare.kmz"); CountSimComparisonKMLWriter kmlWriter = new CountSimComparisonKMLWriter( cca.getComparison(), network, TransformationFactory.getCoordinateTransformation(globalConfigGroup.getCoordinateSystem(), TransformationFactory.WGS84)); String filename = controlerIO.getIterationFilename(event.getIteration(), "countscompare.txt"); CountSimComparisonTableWriter ctw = new CountSimComparisonTableWriter(cca.getComparison(), Locale.ENGLISH); ctw.writeFile(filename); String filename = controlerIO.getIterationFilename(event.getIteration(), "simulatedCounts.xml.gz"); Counts<Link> simCounts = new Counts<>(); simCounts.setDescription("sim values from iteration " + event.getIteration()); simCounts.setName("sim values from iteration " + event.getIteration()); simCounts.setYear(event.getIteration());
this.getControlerIO().createIterationDirectory(iteration); resetRandomNumbers(config.global().getRandomSeed(), iteration); this.getStopwatch().writeTextFile(this.getControlerIO().getOutputFilename("stopwatch")); if (config.controler().isCreateGraphs()) { this.getStopwatch().writeGraphFile(this.getControlerIO().getOutputFilename("stopwatch"));
@Override public void notifyStartup(StartupEvent event) { String outFilename = event.getServices().getControlerIO().getOutputPath() + PConstants.statsOutputFolder; new File(outFilename).mkdir(); } });
ExternalModule(ExeRunnerDelegate exeRunnerDelegate, final String moduleId, final OutputDirectoryHierarchy controler, final Scenario scenario) { this.modulePrefix = moduleId + "_"; this.controler = controler; this.outFileRoot = controler.getTempPath() + "/"; this.scenario = scenario; this.exeRunnerDelegate = exeRunnerDelegate; }
private void dumpExperiencedPlans() { if ( config.planCalcScore().isWriteExperiencedPlans() ) { try { File toFile = new File( controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_EXPERIENCED_PLANS)); File fromFile = new File(controlerIO.getIterationFilename(controlerConfigGroup.getLastIteration(), Controler.FILENAME_EXPERIENCED_PLANS)); try { Files.copy(fromFile.toPath(), toFile.toPath(),StandardCopyOption.REPLACE_EXISTING,StandardCopyOption.COPY_ATTRIBUTES); } catch (IOException e) { throw new UncheckedIOException(e); } } catch ( Exception ee ) { Logger.getLogger(this.getClass()).error("writing output experienced plans did not work; probably parameters were such that they " + "were not generated in the final iteration", ee); } } }
@Override public void notifyStartup(StartupEvent event) { String fileName = controler.getMATSimControler().getControlerIO().getOutputPath() + "/slaveScoreStats.txt"; this.out = IOUtils.getBufferedWriter(fileName); try { this.out.write("ITERATION\tavg. EXECUTED\tavg. WORST\tavg. AVG\tavg. BEST\n"); this.out.flush(); } catch (IOException e) { throw new UncheckedIOException(e); } } }
public ExternalModule(final String exePath, final String moduleId, final OutputDirectoryHierarchy controler, final Scenario scenario) { this.modulePrefix = moduleId + "_"; this.controler = controler; this.outFileRoot = controler.getTempPath() + "/"; this.scenario = scenario; this.exeRunnerDelegate = new ExeRunnerDelegate() { @Override public boolean invoke() { String cmd = exePath + " " + outFileRoot + modulePrefix + ExternalConfigFileName; String logfilename = controler.getIterationFilename(currentIteration, modulePrefix + "stdout.log"); return (ExeRunner.run(cmd, logfilename, 3600) == 0); } }; }
@Override public boolean invoke() { String cmd = exePath + " " + outFileRoot + modulePrefix + ExternalConfigFileName; String logfilename = controler.getIterationFilename(currentIteration, modulePrefix + "stdout.log"); return (ExeRunner.run(cmd, logfilename, 3600) == 0); } };
@Inject TravelDistanceStats(ControlerConfigGroup controlerConfigGroup, GlobalConfigGroup globalConfigGroup, OutputDirectoryHierarchy controlerIO) { this(controlerConfigGroup, globalConfigGroup, controlerIO.getOutputFilename(Controler.FILENAME_TRAVELDISTANCESTATS), controlerConfigGroup.isCreateGraphs()); }
@Override public void notifyIterationEnds(IterationEndsEvent event) { parsePopulation(event.getServices().getScenario().getPopulation()); String outNameIdentifier = "actsFromParatransitUsers.txt"; if (this.firstIteration) { // write it to main output writeResults(event.getServices().getControlerIO().getOutputFilename("0." + outNameIdentifier)); this.firstIteration = false; } else { // write it somewhere writeResults(event.getServices().getControlerIO().getIterationFilename(event.getIteration(), outNameIdentifier)); } }
/** * Returns the complete filename to access an iteration-file with the given * basename. * * @param filename * the basename of the file to access * @return complete path and filename to a file in a iteration directory. if rundId is set then it is prefixed with it */ public final String getIterationFilename(final int iteration, final String filename) { StringBuilder s = new StringBuilder(getIterationPath(iteration)); s.append('/'); if (runId != null) { s.append(runId); s.append('.'); } s.append(iteration); s.append("."); s.append(filename); return s.toString(); }
if (this.firstIteration) { String outFilename = event.getServices().getControlerIO().getOutputPath() + PConstants.statsOutputFolder + PAnalysisManager.class.getSimpleName() + "/"; new File(outFilename).mkdir();
File tmpDir = new File(getTempPath()); if (!tmpDir.mkdir() && !tmpDir.exists()) { throw new RuntimeException("The tmp directory " + getTempPath() + " could not be created.");
@Override public void run() { String iterationPlansFile = this.controlerIO.getIterationFilename(this.iterationNumber, this.plansFileName); String iterationEventsFile = this.controlerIO.getIterationFilename(this.iterationNumber, this.eventsFileName); String iterationConfigFile = this.controlerIO.getIterationFilename(this.iterationNumber, configFileName); try { writePlans(iterationPlansFile); writeConfig(iterationPlansFile, iterationEventsFile, iterationConfigFile); runExe(iterationConfigFile); readEvents(iterationEventsFile); } catch (IOException e) { e.printStackTrace(); } }
/** * Initializes log4j to write log output to files in output directory. * @param outputDirectoryHierarchy TODO */ public final static void initLogging(OutputDirectoryHierarchy outputDirectoryHierarchy) { if (collectLogMessagesAppender != null) { Logger.getRootLogger().removeAppender(collectLogMessagesAppender); } try { String outputFilename = outputDirectoryHierarchy.getOutputFilename(LOGFILE); String warnLogfileName = outputDirectoryHierarchy.getOutputFilename(WARNLOGFILE); initLogging(outputFilename, warnLogfileName); } catch (IOException e) { log.error("Cannot create logfiles: " + e.getMessage()); e.printStackTrace(); } }
@Override public void notifyIterationEnds(IterationEndsEvent event) { MatsimServices controler = event.getServices(); ActivityFacilities facilities = controler.getScenario().getActivityFacilities(); if (event.getIteration() % 2 == 0) { printStatistics(facilities, event.getServices().getControlerIO().getIterationPath(event.getIteration()), event.getIteration(), this.eventsToFacilityLoad.getFacilityPenalties()); } }