Skip to content

Commit

Permalink
update drt area shp + fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tschlenther committed Feb 7, 2024
1 parent d12b0ad commit c24f487
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
Binary file modified input/v1.3/drtServiceArea/leipzig_flexa_service_area_2021.dbf
Binary file not shown.
50 changes: 30 additions & 20 deletions src/test/java/org/matsim/run/RunLeipzigIntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.matsim.run;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.matsim.analysis.ParkingLocation;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.network.Network;
import org.matsim.application.MATSimApplication;
import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.OutputDirectoryHierarchy;
Expand All @@ -21,7 +20,9 @@
public class RunLeipzigIntegrationTest {

private static final String URL = "https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.2/input/";
private static final String exampleShp = "input/v1.3/drtServiceArea/Leipzig_stadt.shp";
private static final String stadtShp = "input/v1.3/drtServiceArea/Leipzig_stadt.shp";
private static final String flexaShp = "input/v1.3/drtServiceArea/leipzig_flexa_service_area_2021.shp";


@Test
public final void runPoint1pctIntegrationTest() {
Expand All @@ -38,8 +39,8 @@ public final void runPoint1pctIntegrationTest() {

ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class).defaultDashboards = SimWrapperConfigGroup.Mode.disabled;

MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--slow-speed-area", exampleShp,
"--slow-speed-relative-change", "0.5","--drt-area", exampleShp, "--post-processing", "disabled"
MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--slow-speed-area", stadtShp,
"--slow-speed-relative-change", "0.5","--drt-area", stadtShp, "--post-processing", "disabled"
);

assertThat(output)
Expand All @@ -63,7 +64,7 @@ public final void runPoint1pctParkingIntegrationTest() {
ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class).defaultDashboards = SimWrapperConfigGroup.Mode.disabled;
config.plans().setInputFile(URL + "leipzig-v1.2-0.1pct.plans-initial.xml.gz");

MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--drt-area", exampleShp, "--post-processing", "disabled",
MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--drt-area", flexaShp, "--post-processing", "disabled",
"--parking-cost-area", "input/v" + RunLeipzigScenario.VERSION + "/parkingCostArea/Bewohnerparken_2020.shp",
"--parking", "--intermodality", "drtAsAccessEgressForPt");

Expand All @@ -73,29 +74,38 @@ public final void runPoint1pctParkingIntegrationTest() {
new ParkingLocation().execute("--directory", output.toString());
}

//drt is included in the parking test, as well...
@Test
@Ignore("Opt Drt is not used right now.")
public final void runOptDrtExamplePopulationTest() {
Config config = ConfigUtils.loadConfig("input/v1.2/leipzig-test.with-drt.config.xml");
public final void runDrtTest() {
Config config = ConfigUtils.loadConfig("input/v1.3/leipzig-v1.3-10pct.config.xml");
Path output = Path.of("output-drt-test/it-1pct");


config.global().setNumberOfThreads(1);
config.qsim().setNumberOfThreads(1);
config.controler().setLastIteration(1);
config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
config.network().setInputFile(URL + "drt-base-case/leipzig-v1.1-network-with-pt-drt.xml.gz");
config.plans().setInputFile(URL + "leipzig-v1.1-0.1pct.plans.xml.gz");
config.transit().setTransitScheduleFile(URL + "leipzig-v1.1-transitSchedule.xml.gz");
config.transit().setVehiclesFile(URL + "leipzig-v1.1-transitVehicles.xml.gz");
config.vehicles().setVehiclesFile(URL + "drt-base-case/leipzig-v1.1-vehicle-types-with-drt-scaledFleet.xml");
config.controler().setOutputDirectory(output.toString());

// config.network().setInputFile(URL + "drt-base-case/leipzig-v1.1-network-with-pt-drt.xml.gz");
config.plans().setInputFile(URL + "leipzig-v1.2-0.1pct.plans-initial.xml.gz");
// config.transit().setTransitScheduleFile(URL + "leipzig-v1.1-transitSchedule.xml.gz");
// config.transit().setVehiclesFile(URL + "leipzig-v1.1-transitVehicles.xml.gz");
// config.vehicles().setVehiclesFile(URL + "drt-base-case/leipzig-v1.1-vehicle-types-with-drt-scaledFleet.xml");

ConfigUtils.addOrGetModule(config, SimWrapperConfigGroup.class).defaultDashboards = SimWrapperConfigGroup.Mode.disabled;

//modes now have to be provided in the drt-area shape file, per 'mode' attribute with
//TODO: fix test by providing service area shape file
MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--drt-area", exampleShp,
"--drt-modes", "drtNorth,drtSoutheast", "--waiting-time-threshold-optDrt", "600", "--post-processing", "disabled");
MATSimApplication.execute(RunLeipzigScenario.class, config, "run", "--1pct", "--drt-area", flexaShp
, "--post-processing", "disabled");

Network network = NetworkUtils.readNetwork(output + "/" + config.controler().getRunId() + ".output_network.xml.gz");
assertTrue(! network.getLinks().get(Id.createLinkId("24232899")).getAllowedModes().contains("drtNorth"));
assertTrue(! network.getLinks().get(Id.createLinkId("24232899")).getAllowedModes().contains("drtSoutheast"));
assertTrue(network.getLinks().get(Id.createLinkId("307899688#1")).getAllowedModes().contains("drtNorth"));
assertTrue(network.getLinks().get(Id.createLinkId("26588307#0")).getAllowedModes().contains("drtSoutheast"));

assertTrue(MultiModeDrtConfigGroup.get(config)!= null);

Assert.assertNotNull(config.getModules().get("multiModeOptDrt"));
Assert.assertNotNull(config.getModules().get("multiModeOptDrt").getParameterSets());
//TODO add more tests, drt trips, etc.
}
}

0 comments on commit c24f487

Please sign in to comment.