fun writePopulation(outputfolder: String) { var outputfolder = outputfolder outputfolder = outputfolder + if (outputfolder.endsWith("/")) "" else "/" if (sc.getPopulation().getPersons().size() === 0 || sc.getPopulation() .getPersonAttributes() == null ) { throw RuntimeException("Either no persons or person attributes to write.") } else { LOG.info("Writing population to file... (" + sc.getPopulation().getPersons().size() + ")") val pw = PopulationWriter(sc.getPopulation(), sc.getNetwork()) pw.writeV5(outputfolder + "Population.xml") LOG.info("Writing person attributes to file...") val oaw = ObjectAttributesXmlWriter(sc.getPopulation().getPersonAttributes()) oaw.putAttributeConverter(IncomeImpl::class.java, SAIncomeConverter()) oaw.setPrettyPrint(true) oaw.writeFile(outputfolder + "PersonAttributes.xml") } }
Writes the population and their attributes to file .