From 22e3f93970036a108aea289d6e3d30f23e1cee5e Mon Sep 17 00:00:00 2001 From: sime94 Date: Thu, 10 Oct 2024 18:11:16 +0200 Subject: [PATCH] reduce threads to make runnable --- .../org/matsim/run/RunIntegrationTest.java | 124 ++++++++++-------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/src/test/java/org/matsim/run/RunIntegrationTest.java b/src/test/java/org/matsim/run/RunIntegrationTest.java index d3a0b0b..cf7cd3b 100644 --- a/src/test/java/org/matsim/run/RunIntegrationTest.java +++ b/src/test/java/org/matsim/run/RunIntegrationTest.java @@ -68,7 +68,10 @@ void runScenario() { "--iterations", "1", "--config:plans.inputPlansFile", "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v2024.2/lausitz-v2024.2-0.1pct.plans-initial.xml.gz", "--output", utils.getOutputDirectory(), - "--config:controller.overwriteFiles=deleteDirectoryIfExists", "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") + "--config:controller.overwriteFiles=deleteDirectoryIfExists", + "--config:global.numberOfThreads", "2", + "--config:qsim.numberOfThreads", "2", + "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") == 0 : "Must return non error code"; Assertions.assertTrue(new File(utils.getOutputDirectory()).isDirectory()); @@ -87,7 +90,10 @@ void runScenarioIncludingDrt() { "--iterations", "0", "--config:plans.inputPlansFile", inputPath, "--output", utils.getOutputDirectory(), - "--config:controller.overwriteFiles=deleteDirectoryIfExists", "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") + "--config:controller.overwriteFiles=deleteDirectoryIfExists", + "--config:global.numberOfThreads", "2", + "--config:qsim.numberOfThreads", "2", + "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") == 0 : "Must return non error code"; Assertions.assertTrue(new File(utils.getOutputDirectory()).isDirectory()); @@ -106,7 +112,10 @@ void runScenarioIncludingAdditionalPtLine() { "--iterations", "1", "--output", utils.getOutputDirectory(), "--config:plans.inputPlansFile", inputPath, - "--config:controller.overwriteFiles=deleteDirectoryIfExists", "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") + "--config:controller.overwriteFiles=deleteDirectoryIfExists", + "--config:global.numberOfThreads", "2", + "--config:qsim.numberOfThreads", "2", + "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") == 0 : "Must return non error code"; Assertions.assertTrue(new File(utils.getOutputDirectory()).isDirectory()); @@ -138,55 +147,6 @@ void runScenarioIncludingAdditionalPtLine() { } - private void createDrtTestPopulation(String inputPath) { - Random random = new Random(1); - Config config = ConfigUtils.createConfig(); - Scenario scenario = ScenarioUtils.loadScenario(config); - Population population = scenario.getPopulation(); - PopulationFactory populationFactory = population.getFactory(); - - for (int i = 0; i < 500; i++) { - Person person = populationFactory.createPerson(Id.createPersonId("dummy_person_" + i)); - PersonUtils.setIncome(person, 1000.); - Plan plan = populationFactory.createPlan(); - // a random location in the Hoyerswerda town center - Activity fromAct = populationFactory.createActivityFromCoord("home_2400", new Coord(863949.91, 5711547.75)); - // a random time between 6:00-9:00 - fromAct.setEndTime(21600 + random.nextInt(10800)); - // set the link to PT, such that agent could find a potential intermodal trip - Leg leg = populationFactory.createLeg(TransportMode.pt); - // a location close to Cottbus Hbf - Activity toAct = populationFactory.createActivityFromCoord("work_2400", new Coord(867341.75, 5746965.87)); - - plan.addActivity(fromAct); - plan.addLeg(leg); - plan.addActivity(toAct); - - person.addPlan(plan); - population.addPerson(person); - } - - Person drtOnly = populationFactory.createPerson(Id.createPersonId("drtOnly")); - PersonUtils.setIncome(drtOnly, 1000.); - Plan plan = populationFactory.createPlan(); - // a random location in the Hoyerswerda town center - Activity fromAct = populationFactory.createActivityFromCoord("home_2400", new Coord(863949.91, 5711547.75)); - // a random time between 6:00-9:00 - fromAct.setEndTime(21600 + random.nextInt(10800)); - Leg leg = populationFactory.createLeg(TransportMode.drt); - // a location in Wittichenau - Activity toAct = populationFactory.createActivityFromCoord("work_2400", new Coord(864808.3,5705774.7)); - - plan.addActivity(fromAct); - plan.addLeg(leg); - plan.addActivity(toAct); - - drtOnly.addPlan(plan); - population.addPerson(drtOnly); - - - new PopulationWriter(population).write(inputPath); -} @Test void runSpeedReductionScenario() { Config config = ConfigUtils.loadConfig(String.format("input/v%s/lausitz-v%s-10pct.config.xml", LausitzScenario.VERSION, LausitzScenario.VERSION)); @@ -197,7 +157,10 @@ void runSpeedReductionScenario() { "--iterations", "0", "--config:plans.inputPlansFile", "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/lausitz/input/v2024.2/lausitz-v2024.2-0.1pct.plans-initial.xml.gz", "--output", utils.getOutputDirectory(), - "--config:controller.overwriteFiles=deleteDirectoryIfExists", "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") + "--config:controller.overwriteFiles=deleteDirectoryIfExists", + "--config:global.numberOfThreads", "2", + "--config:qsim.numberOfThreads", "2", + "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS") == 0 : "Must return non error code"; Assertions.assertTrue(new File(utils.getOutputDirectory()).isDirectory()); @@ -227,7 +190,10 @@ void runSingleModeScenario() { "--iterations", "1", "--config:plans.inputPlansFile", inputPath, "--output", utils.getOutputDirectory(), - "--config:controller.overwriteFiles=deleteDirectoryIfExists", "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS", + "--config:controller.overwriteFiles=deleteDirectoryIfExists", + "--config:global.numberOfThreads", "2", + "--config:qsim.numberOfThreads", "2", + "--emissions", "DO_NOT_PERFORM_EMISSIONS_ANALYSIS", "--transport-mode", mode) == 0 : "Must return non error code"; @@ -283,6 +249,56 @@ private void createSinglePersonTestPopulation(Config config, String mode) { new PopulationWriter(population).write(this.inputPath); } + private void createDrtTestPopulation(String inputPath) { + Random random = new Random(1); + Config config = ConfigUtils.createConfig(); + Scenario scenario = ScenarioUtils.loadScenario(config); + Population population = scenario.getPopulation(); + PopulationFactory populationFactory = population.getFactory(); + + for (int i = 0; i < 500; i++) { + Person person = populationFactory.createPerson(Id.createPersonId("dummy_person_" + i)); + PersonUtils.setIncome(person, 1000.); + Plan plan = populationFactory.createPlan(); + // a random location in the Hoyerswerda town center + Activity fromAct = populationFactory.createActivityFromCoord("home_2400", new Coord(863949.91, 5711547.75)); + // a random time between 6:00-9:00 + fromAct.setEndTime(21600 + random.nextInt(10800)); + // set the link to PT, such that agent could find a potential intermodal trip + Leg leg = populationFactory.createLeg(TransportMode.pt); + // a location close to Cottbus Hbf + Activity toAct = populationFactory.createActivityFromCoord("work_2400", new Coord(867341.75, 5746965.87)); + + plan.addActivity(fromAct); + plan.addLeg(leg); + plan.addActivity(toAct); + + person.addPlan(plan); + population.addPerson(person); + } + + Person drtOnly = populationFactory.createPerson(Id.createPersonId("drtOnly")); + PersonUtils.setIncome(drtOnly, 1000.); + Plan plan = populationFactory.createPlan(); + // a random location in the Hoyerswerda town center + Activity fromAct = populationFactory.createActivityFromCoord("home_2400", new Coord(863949.91, 5711547.75)); + // a random time between 6:00-9:00 + fromAct.setEndTime(21600 + random.nextInt(10800)); + Leg leg = populationFactory.createLeg(TransportMode.drt); + // a location in Wittichenau + Activity toAct = populationFactory.createActivityFromCoord("work_2400", new Coord(864808.3,5705774.7)); + + plan.addActivity(fromAct); + plan.addLeg(leg); + plan.addActivity(toAct); + + drtOnly.addPlan(plan); + population.addPerson(drtOnly); + + + new PopulationWriter(population).write(inputPath); + } + private static final class PersonEntersPtVehicleEventHandler implements PersonEntersVehicleEventHandler { static List enterEvents = new ArrayList<>();