/** * Writes the population and their attributes to file. * * @param outputfolder */ public void writePopulation(String outputfolder) { if (this.sc.getPopulation().getPersons().size() == 0 || this.personAttributes == null) { throw new RuntimeException("Either no persons or person attributes to write."); } else { LOG.info("Writing population to file..."); PopulationWriter pw = new PopulationWriter(this.sc.getPopulation(), this.sc.getNetwork()); pw.writeV5(outputfolder + "Population.xml"); LOG.info("Writing person attributes to file..."); ObjectAttributesXmlWriter oaw = new ObjectAttributesXmlWriter(this.personAttributes); oaw.setPrettyPrint(true); oaw.writeFile(outputfolder + "PersonAttributes.xml"); } }
private static void removeActs(String networkFile, String popFile) { String popOutFile = popFile + "_removedTransitActs.xml.gz"; TransitActsRemover remover = new TransitActsRemover(); Scenario sc = ScenarioUtils.createScenario(ConfigUtils.createConfig()); new MatsimNetworkReader(sc.getNetwork()).readFile(networkFile); new PopulationReader(sc).readFile(popFile); for (Person person : sc.getPopulation().getPersons().values()) { for (Plan plan : person.getPlans()) { remover.run(plan); } } PopulationWriter popWriter = new PopulationWriter(sc.getPopulation(), sc.getNetwork()); popWriter.write(popOutFile); }
public static void main(String[] args) throws Exception { String baseDir = "../../../shared-svn/projects/cottbus/data/scenarios/cottbus_scenario/"; String networkFile = baseDir + "network_wgs84_utm33n.xml.gz"; boolean useLanduse = true; String populationOutputDirectory = baseDir + "cb_spn_gemeinde_nachfrage_landuse_ohneTagebau/"; // String shapesOutputDirectory = populationOutputDirectory + "shapes_all_modes/"; String shapesOutputDirectory = populationOutputDirectory + "shapes/"; // String populationOutputFile = populationOutputDirectory + // "commuter_population_wgs84_utm33n.xml.gz"; String populationOutputFile = populationOutputDirectory + "commuter_population_wgs84_utm33n_car_only.xml.gz"; OutputDirectoryLogging.initLoggingWithOutputDirectory(populationOutputDirectory); File shapes = new File(shapesOutputDirectory); if (!shapes.exists()) { shapes.mkdir(); } Config config1 = ConfigUtils.createConfig(); config1.network().setInputFile(networkFile); Scenario sc = ScenarioUtils.loadScenario(config1); CommuterDataReader cdr = new CommuterDataReader(); cdr.addFilterRange(12071000); cdr.addFilter("12052000"); // 12052000 == cottbus stadt cdr.readFile( "../../../shared-svn/studies/countries/de/pendler_nach_gemeinden/brandenburg_einpendler.csv"); // cdr.getCommuterRelations().add(new CommuterDataElement("12052000", "12052000", 1000)); String gemeindenBrandenburgShapeFile = "../../../shared-svn/studies/countries/de/brandenburg_gemeinde_kreisgrenzen/gemeinden/dlm_gemeinden.shp"; ShapeFileReader gemeindenReader = new ShapeFileReader(); Collection<SimpleFeature> gemeindenFeatures = gemeindenReader.readFileAndInitialize(gemeindenBrandenburgShapeFile); CommuterDemandWriter cdw = new CommuterDemandWriter( gemeindenFeatures, gemeindenReader.getCoordinateSystem(), cdr.getCommuterRelations(), MGC.getCRS(TransformationFactory.WGS84_UTM33N)); // landuse if (useLanduse) { DgLanduseReader landuseReader = new DgLanduseReader(); Tuple<Collection<SimpleFeature>, CoordinateReferenceSystem> homeLanduse = landuseReader.readLanduseDataHome(); Tuple<Collection<SimpleFeature>, CoordinateReferenceSystem> workLanduse = landuseReader.readLanduseDataWork(); cdw.addLanduse("home", homeLanduse); cdw.addLanduse("work", workLanduse); } // // cdw.setScalefactor(1.0); // all modes cdw.setScalefactor(0.55); // car mode share // cdw.setScalefactor(0.1); //testing cdw.computeDemand(sc); PopulationWriter populationWriter = new PopulationWriter(sc.getPopulation(), sc.getNetwork()); populationWriter.write(populationOutputFile); log.info("population written to " + populationOutputFile); // write some test output Config config = ConfigUtils.createConfig(); config.network().setInputFile(networkFile); config.plans().setInputFile(populationOutputFile); Scenario baseScenario = ScenarioUtils.loadScenario(config); String shapeFilename = shapesOutputDirectory + "commuter_population_home.shp"; new DgPopulation2ShapeWriter( baseScenario.getPopulation(), MGC.getCRS(TransformationFactory.WGS84_UTM33N)) .write("home", shapeFilename, MGC.getCRS(TransformationFactory.WGS84_UTM33N)); shapeFilename = shapesOutputDirectory + "commuter_population_work.shp"; new DgPopulation2ShapeWriter( baseScenario.getPopulation(), MGC.getCRS(TransformationFactory.WGS84_UTM33N)) .write("work", shapeFilename, MGC.getCRS(TransformationFactory.WGS84_UTM33N)); log.info("done!"); OutputDirectoryLogging.closeOutputDirLogging(); }
private void run() { // Braunschweig, Stadt - BS // Wolfsburg, Stadt - WB // Gifhorn - GH // Wolfenbüttel - WL // Helmstedt - HS // Peine - PE // Salzgitter, Stadt - SG // Börde - BR // Altmarkkreis Salzwedel - AS // Region Hannover - RH // Goslar - GL // Harz - HZ // Hildesheim - HH // Magdeburg, Landeshauptstadt - MB // Celle - CL // Uelzen - UL // Stendal - SD // Göttingen - GG // Salzlandkreis - SL // Jerochower Land - JL // Osnabrück, Stadt - OB // Osterode am Harz - OR // Braunschweig, Stadt - Braunschweig, Stadt | work createWorkers("BS", "BS", 62158 * config.getScalefactor(), 0.45, 0.2, 0.2, "03101", "03101"); // Braunschweig, Stadt - Braunschweig, Stadt | school createPupils("BS", "BS", 24907 * config.getScalefactor(), 0.1, 0.13, 0.22, "03101", "03101"); // Braunschweig, Stadt - Braunschweig, Stadt | university createStudents("BS", "BS", 29455 * config.getScalefactor(), 0.1, 0.13, 0.22, "03101", "03101"); // Wolfsburg, Stadt - Wolfsburg, Stadt | work createWorkers( "WB", "WB", (41470 - 18313) * config.getScalefactor(), 0.4, 0.2, 0.2, "03103", "03103"); createVWWorkers("WB", "03103", 11207, 1260 + 5328, 658, 0.4, 0.2, 0.2); // 3103 11207 1260 5328 518 18313 // Wolfsburg, Stadt - Wolfsburg, Stadt | school createPupils("WB", "WB", 13867 * config.getScalefactor(), 0.1, 0.13, 0.27, "03103", "03103"); // Wolfsburg, Stadt - Wolfsburg, Stadt | university createStudents("WB", "WB", 8823 * config.getScalefactor(), 0.01, 0.4, 0.25, "03103", "03103"); // Gifhorn - Wolfsburg, Stadt | work createWorkers( "GH", "WB", (26484 - 15152) * config.getScalefactor(), 0.8, 0.0, 0.0, "03151", "03103"); createVWWorkers("GH", "03151", 9156, 1050 + 4758, 518, 0.8, 0.0, 0.0); // 3151 9156 1050 4758 188 15152 // Gifhorn - Gifhorn | work createWorkers("GH", "GH", 26414 * config.getScalefactor(), 0.63, 0.15, 0.15, "03151", "03151"); // Gifhorn - Gifhorn | school createPupils("GH", "GH", 26429 * config.getScalefactor(), 0.2, 0.3, 0.2, "03151", "03151"); // Wolfenbüttel - Braunschweig, Stadt | work createWorkers("WL", "BS", 13304 * config.getScalefactor(), 0.8, 0.0, 0.0, "03158", "03101"); // Helmstedt - Wolfsburg, Stadt | work createWorkers( "HS", "WB", (12731 - 7908) * config.getScalefactor(), 0.8, 0.0, 0.0, "03154", "03103"); createVWWorkers("HS", "03154", 4704, 536 + 2668, 188, 0.8, 0.0, 0.0); // 3154 4704 536 2668 0 7908 // Braunschweig, Stadt - Wolfsburg, Stadt | work createWorkers( "BS", "WB", (10273 - 5006) * config.getScalefactor(), 0.65, 0.01, 0.0, "03101", "03103"); createVWWorkers("BS", "03101", 4085, 127 + 693, 101, 0.65, 0.01, 0.0); // 3101 4085 127 693 101 8107 // Peine - Braunschweig, Stadt | work createWorkers("PE", "BS", 9089 * config.getScalefactor(), 0.8, 0.0, 0.0, "03157", "03101"); // Gifhorn - Braunschweig, Stadt | work createWorkers("GH", "BS", 7586 * config.getScalefactor(), 0.8, 0.0, 0.0, "03151", "03101"); // Salzgitter, Stadt - Braunschweig, Stadt | work createWorkers("SG", "BS", 5572 * config.getScalefactor(), 0.8, 0.0, 0.0, "03102", "03101"); // Helmstedt - Braunschweig, Stadt | work createWorkers("HS", "BS", 4618 * config.getScalefactor(), 0.8, 0.0, 0.0, "03154", "03101"); // Börde - Wolfsburg, Stadt | work createWorkers( "BR", "WB", (3685 - 856) * config.getScalefactor(), 0.8, 0.0, 0.0, "15085", "03103"); createVWWorkers("BR", "15085", 396, 460, 0, 0.8, 0.0, 0.0); // 15362 396 0 460 0 856 // Altmarkkreis Salzwedel - Wolfsburg, Stadt | work createWorkers( "AS", "WB", (3305 - 740) * config.getScalefactor(), 0.8, 0.0, 0.0, "15081", "03103"); createVWWorkers("AS", "15081", 290, 450, 0, .8, .0, .0); // 15370 290 0 450 0 740 // Region Hannover - Wolfsburg, Stadt | work createWorkers( "RH", "WB", (2850 - 1148) * config.getScalefactor(), 0.8, 0.0, 0.0, "03241", "03103"); createVWWorkers("RH", "03241", 1004, 144, 0, 0.8, 0.0, .0); // 3241 1004 0 144 0 1148 // Region Hannover - Braunschweig, Stadt | work createWorkers("RH", "BS", 2833 * config.getScalefactor(), 0.8, 0.0, 0.0, "03241", "03101"); // Wolfenbüttel - Wolfsburg, Stadt | work createWorkers( "WL", "WB", (2676 - 1191) * config.getScalefactor(), 0.8, 0.0, 0.0, "03158", "03103"); createVWWorkers("WL", "03158", 943, 248, 0, .8, .0, .0); // 3158 943 0 248 0 1191 // Braunschweig, Stadt - Gifhorn | work createWorkers("BS", "GH", 2635 * config.getScalefactor(), 0.8, 0.0, 0.0, "03101", "03151"); // Braunschweig, Stadt - Wolfburg, Stadt | work createWorkers("BS", "WB", 2310 * config.getScalefactor(), 0.8, 0.0, 0.0, "03101", "03103"); // Braunschweig, Stadt - Goslar | work createWorkers("BS", "GL", 1960 * config.getScalefactor(), 0.8, 0.0, 0.0, "03101", "03153"); // Wolfsburg, Stadt - Gifhorn | work createWorkers("WB", "GH", 1844 * config.getScalefactor(), 0.8, 0.0, 0.0, "03103", "03151"); // Peine - Wolfburg, Stadt | work createWorkers( "PE", "WB", (1756 - 782) * config.getScalefactor(), 0.8, 0.0, 0.0, "03157", "03103"); createVWWorkers("PE", "03157", 551, 231, 0, .8, .0, .0); // 3157 551 0 231 0 782 // Harz - Braunschweig, Stadt | work createWorkers("HZ", "BS", 1685 * config.getScalefactor(), 0.8, 0.0, 0.0, "15085", "03101"); // Altmarkkreis Salzwedel - Gifhorn | work createWorkers("AS", "GH", 1649 * config.getScalefactor(), 0.8, 0.0, 0.0, "15081", "03151"); // Börde - Braunschweig, Stadt | work createWorkers("BR", "BS", 1260 * config.getScalefactor(), 0.8, 0.0, 0.0, "15085", "03101"); // Hildesheim - Braunschweig, Stadt | work createWorkers("HH", "BS", 1195 * config.getScalefactor(), 0.8, 0.0, 0.0, "03254", "03101"); // Salzgitter, Stadt - Wolfburg, Stadt | work createWorkers("SG", "WB", 0 * config.getScalefactor(), 0.8, 0.0, 0.0, "03102", "03103"); createVWWorkers("SG", "03102", 180, 106, 0, .8, .0, .0); // 3102 180 0 106 658 944 // Magdeburg, Landeshauptstadt - Wolfburg, Stadt | work createWorkers("MB", "WB", 847 * config.getScalefactor(), 0.8, 0.0, 0.0, "15003", "03103"); createVWWorkers("MB", "15003", 256, 140, 0, .8, .0, .0); // 15003 256 0 140 0 396 // Peine - Gifhorn | work createWorkers("PE", "GH", 834 * config.getScalefactor(), 0.8, 0.0, 0.0, "03157", "03151"); // Celle - Gifhorn | work createWorkers("CL", "GH", 815 * config.getScalefactor(), 0.8, 0.0, 0.0, "03351", "03151"); // Helmstedt - Gifhorn | work createWorkers("HS", "GH", 735 * config.getScalefactor(), 0.8, 0.0, 0.0, "03154", "03151"); // Region Hannover - Gifhorn | work createWorkers("RH", "GH", 680 * config.getScalefactor(), 0.8, 0.0, 0.0, "03241", "03151"); // Celle - Wolfburg, Stadt | work createWorkers( "CL", "WB", (607 - 315) * config.getScalefactor(), 0.8, 0.0, 0.0, "03351", "03103"); createVWWorkers("CL", "03351", 155, 160, 0, .8, .0, .0); // 3351 155 0 160 0 315 // Magdeburg, Landeshauptstadt - Braunschweig, Stadt | work createWorkers("MB", "BS", 511 * config.getScalefactor(), 0.8, 0.0, 0.0, "15003", "03101"); // Wolfenbüttel - Gifhorn | work createWorkers("WB", "GH", 496 * config.getScalefactor(), 0.8, 0.0, 0.0, "03158", "03151"); // Harz - Wolfburg, Stadt | work createWorkers("HZ", "WB", 476 * config.getScalefactor(), 0.8, 0.0, 0.0, "15085", "03103"); // Uelzen - Gifhorn | work createWorkers("UL", "GH", 474 * config.getScalefactor(), 0.8, 0.0, 0.0, "03360", "03151"); // Stendal - Wolfburg, Stadt | work createWorkers("SD", "WB", 456 * config.getScalefactor(), 0.8, 0.0, 0.0, "15090", "03103"); // Celle - Braunschweig, Stadt | work createWorkers("CL", "BS", 440 * config.getScalefactor(), 0.8, 0.0, 0.0, "03351", "03101"); // Börde - Gifhorn | work createWorkers("BR", "GH", 400 * config.getScalefactor(), 0.8, 0.0, 0.0, "15083", "03151"); // Hildesheim - Wolfburg, Stadt | work createWorkers( "HH", "WB", (391 - 107) * config.getScalefactor(), 0.8, 0.0, 0.0, "03254", "03103"); createVWWorkers("HH", "03103", 107, 0, 0, .8, .0, .0); // 3254 107 0 0 0 107 // Goslar - Wolfburg, Stadt | work createWorkers("GL", "WB", 384 * config.getScalefactor(), 0.8, 0.0, 0.0, "03153", "03103"); // Göttingen - Braunschweig, Stadt | work createWorkers("GG", "BS", 369 * config.getScalefactor(), 0.8, 0.0, 0.0, "03152", "03101"); // Uelzen - Wolfburg, Stadt | work createWorkers("UL", "WB", 338 * config.getScalefactor(), 0.8, 0.0, 0.0, "03360", "03103"); // Altmarkkreis Salzwedel - Braunschweig, Stadt | work createWorkers("AS", "BS", 245 * config.getScalefactor(), 0.8, 0.0, 0.0, "15081", "03101"); // Salzlandkreis - Wolfburg, Stadt | work createWorkers("SL", "WB", 214 * config.getScalefactor(), 0.8, 0.0, 0.0, "15089", "03103"); // Salzlandkreis - Braunschweig, Stadt | work createWorkers("SL", "BS", 185 * config.getScalefactor(), 0.8, 0.0, 0.0, "15089", "03101"); // Salzgitter, Stadt - Gifhorn | work createWorkers("SG", "GH", 174 * config.getScalefactor(), 0.8, 0.0, 0.0, "03102", "03151"); // Jerichower Land - Wolfburg, Stadt | work createWorkers("JL", "WB", 170 * config.getScalefactor(), 0.8, 0.0, 0.0, "15086", "03103"); // Harz - Gifhorn | work createWorkers("HZ", "GH", 148 * config.getScalefactor(), 0.8, 0.0, 0.0, "15085", "03151"); // Osnabrück, Stadt - Wolfburg, Stadt | work createWorkers("OB", "WB", 136 * config.getScalefactor(), 0.8, 0.0, 0.0, "03404", "03103"); // Osterode am Harz - Braunschweig, Stadt | work createWorkers("OR", "BS", 129 * config.getScalefactor(), 0.8, 0.0, 0.0, "03156", "03101"); // Jerichower Land - Braunschweig, Stadt | work createWorkers("JL", "BS", 117 * config.getScalefactor(), 0.8, 0.0, 0.0, "15086", "03101"); // Magdeburg, Landeshauptstadt - Gifhorn | work createWorkers("MB", "GH", 114 * config.getScalefactor(), 0.8, 0.0, 0.0, "15003", "03151"); // Uelzen - Braunschweig, Stadt | work createWorkers("UL", "BS", 110 * config.getScalefactor(), 0.8, 0.0, 0.0, "03360", "03101"); // Stendal - Braunschweig, Stadt | work createWorkers("SD", "BS", 108 * config.getScalefactor(), 0.8, 0.0, 0.0, "15090", "03101"); // Goslar - Gifhorn | work createWorkers("GL", "GH", 101 * config.getScalefactor(), 0.8, 0.0, 0.0, "03153", "03151"); createA2TransitTruckers(Math.round(15000 * config.getScalefactor())); createVWTruckers(Math.round(900 * config.getScalefactor())); replaceDoubtfulLegsByOtherMode(); System.out.println("generated Agents: " + commuterCounter); System.out.println("VW Workers: " + vwWorkerCounter); System.out.println("Workers: " + workerCounter); createAgentGroupNearTransitstrops(scenario, 1500, config.getTransitSchedule()); replaceSptByPtp(); PopulationWriter pw = new PopulationWriter(scenario.getPopulation(), scenario.getNetwork()); pw.write(config.getPlansOutputString()); new ObjectAttributesXmlWriter(scenario.getPopulation().getPersonAttributes()) .writeFile(config.getObjectAttributes()); }
private void run() { this.shapeMap = readShapeFile(KREISE, "Nr"); this.buildingsMap = readShapeFile(BUILDINGS, "osm_id"); this.shops = readFacilityLocations(SHOPS); this.kindergartens = readFacilityLocations(KINDERGARTEN); // CB-CB (Stadtverkehr: Modal Split mit 50% IV/ÖV) double commuters = 22709 * SCALEFACTOR; createPersons("12052000", "12052000", commuters, 0.5); // CB-LDS (Regionalverkehr: Modal Split mit 80% IV) commuters = 399 * SCALEFACTOR; createPersons("12052000", "12061000", commuters, 0.8); // CB-LOS commuters = 139 * SCALEFACTOR; createPersons("12052000", "12067000", commuters, 0.8); // CB-SPN commuters = 4338 * SCALEFACTOR; createPersons("12052000", "12071000", commuters, 0.8); // LDS-CB commuters = 1322 * SCALEFACTOR; createPersons("12061000", "12052000", commuters, 0.8); // LDS-SPN commuters = 522 * SCALEFACTOR; createPersons("12061000", "12071000", commuters, 0.8); // LOS-CB commuters = 382 * SCALEFACTOR; createPersons("12067000", "12052000", commuters, 0.8); // LOS-SPN commuters = 449 * SCALEFACTOR; createPersons("12067000", "12071000", commuters, 0.8); // SPN-CB commuters = 11869 * SCALEFACTOR; createPersons("12071000", "12052000", commuters, 0.8); // SPN-LDS commuters = 408 * SCALEFACTOR; createPersons("12071000", "12061000", commuters, 0.8); // SPN-LOS commuters = 466 * SCALEFACTOR; createPersons("12071000", "12067000", commuters, 0.8); // SPN-SPN commuters = 22524 * SCALEFACTOR; createPersons("12071000", "12071000", commuters, 0.8); /* * Achtung! 3 Nullen extra hier ggü. ISIS Daten */ System.out.println(this.shapeMap.keySet()); createCarSharingVehicleLocationsFile(); PopulationWriter pw = new PopulationWriter(scenario.getPopulation(), scenario.getNetwork()); pw.write(PLANSFILEOUTPUT); }