Skip to content

Commit

Permalink
reduce threads to make runnable
Browse files Browse the repository at this point in the history
  • Loading branch information
simei94 committed Oct 10, 2024
1 parent 23a87c8 commit 22e3f93
Showing 1 changed file with 70 additions and 54 deletions.
124 changes: 70 additions & 54 deletions src/test/java/org/matsim/run/RunIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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));
Expand All @@ -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());
Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -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<PersonEntersVehicleEvent> enterEvents = new ArrayList<>();

Expand Down

0 comments on commit 22e3f93

Please sign in to comment.