/** * Ensure there is a tmp folder for the intermediary file, and it only contains the original, * unedited population. */ private static void setup(String outputFolder, String censusFolder) { /* Empty and create a temporary folder. */ File tmpFolder = new File(outputFolder + "tmp/"); if (tmpFolder.exists()) { LOG.warn("Temporary folder will be deleted!"); LOG.warn("Deleting " + tmpFolder.getAbsolutePath()); FileUtils.delete(tmpFolder); } tmpFolder.mkdirs(); /* Copy the population from then Treasury 2014 data. */ try { FileUtils.copyFile( new File(censusFolder + "population_withPlans.xml.gz"), new File(outputFolder + "tmp/persons.xml.gz")); FileUtils.copyFile( new File(censusFolder + "populationAttributes.xml.gz"), new File(outputFolder + "tmp/personAttributes.xml.gz")); FileUtils.copyFile( new File(censusFolder + "households.xml.gz"), new File(outputFolder + "tmp/households.xml.gz")); FileUtils.copyFile( new File(censusFolder + "householdAttributes_withPlanHome.xml.gz"), new File(outputFolder + "tmp/householdAttributes.xml.gz")); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Cannot copy base treasure files."); } }
public static void main(String[] args) { Header.printHeader(RunCapeTownFreight.class.toString(), args); String folder = args[0] + (args[0].endsWith("/") ? "" : "/"); Machine machine = Machine.valueOf(args[1]); /* Check if output folder exists, and DELETE if it is there. */ File f = new File(folder + "output/"); if (f.exists() && f.isDirectory()) { LOG.warn("Deleting the output folder " + folder + "output/"); FileUtils.delete(f); } /* Set up the simulation run. */ Config config = setupConfig(folder, machine); Scenario sc = setupScenario(config); Controler controler = setupControler(sc); controler.run(); Header.printFooter(); }