Skip to content

Commit

Permalink
Merge branch 'drtSpeedup' into removeDrtCase
Browse files Browse the repository at this point in the history
  • Loading branch information
tschlenther committed Feb 7, 2024
2 parents 9f17787 + 95803b9 commit 1270018
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/main/java/org/matsim/run/prepare/DrtCaseSetup.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.matsim.run.prepare;

import cadyts.utilities.misc.DynamicData;
import ch.sbb.matsim.config.SwissRailRaptorConfigGroup;
import ch.sbb.matsim.routing.pt.raptor.RaptorIntermodalAccessEgress;
import com.google.common.collect.ImmutableSet;
Expand All @@ -12,11 +11,8 @@
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Network;
import org.matsim.application.options.ShpOptions;
import org.matsim.contrib.drt.analysis.zonal.DrtZonalSystemParams;
import org.matsim.contrib.drt.fare.DrtFareParams;
import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams;
import org.matsim.contrib.drt.optimizer.rebalancing.RebalancingParams;
import org.matsim.contrib.drt.optimizer.rebalancing.mincostflow.MinCostFlowRebalancingStrategyParams;
import org.matsim.contrib.drt.routing.DrtRoute;
import org.matsim.contrib.drt.routing.DrtRouteFactory;
import org.matsim.contrib.drt.run.*;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/matsim/run/prepare/NetworkOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public class NetworkOptions {

@CommandLine.Option(names = "--drt-area", description = "Path to SHP file specifying where DRT mode is allowed")
private Path drtArea;
@CommandLine.Option(names = "--drt-modes", description = "List of modes to add. Use comma as delimiter", defaultValue = TransportMode.drt)
private String drtModes;
//modes now have to be provided in the drt-area shape file, per 'mode' attribute with
// @CommandLine.Option(names = "--drt-modes", description = "List of modes to add. Use comma as delimiter", defaultValue = TransportMode.drt)
// private String drtModes;
@CommandLine.Option(names = "--car-free-area", description = "Path to SHP file specifying car-free area")
private Path carFreeArea;
@CommandLine.Option(names = "--car-free-modes", description = "List of modes to remove. Use comma as delimiter", defaultValue = TransportMode.car)
Expand Down Expand Up @@ -65,7 +66,7 @@ public void prepare(Network network) {
if (!Files.exists(drtArea)) {
throw new IllegalArgumentException("Path to drt area not found: " + drtArea);
} else {
PrepareNetwork.prepareDRT(network, new ShpOptions(drtArea, null, null), drtModes);
PrepareNetwork.prepareDRT(network, new ShpOptions(drtArea, null, null));
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/matsim/run/prepare/PrepareNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Integer call() throws Exception {
* Adapt network to one or more drt service areas. Therefore, a shape file of the wished service area + a list
* of drt modes are needed.
*/
static void prepareDRT(Network network, ShpOptions shp, String modes) {
static void prepareDRT(Network network, ShpOptions shp) {

List<SimpleFeature> features = shp.readFeatures();
Map<String, Geometry> modeGeoms = new HashMap<>();
Expand All @@ -67,7 +67,7 @@ static void prepareDRT(Network network, ShpOptions shp, String modes) {
if (mode.equals("null")) {
throw new IllegalArgumentException("could not find 'mode' attribute in the given shape file at " + shp.getShapeFile().toString());
}
modeGeoms.compute(mode, (m,geom) -> geom == null ? ((Geometry) feature.getDefaultGeometry()) : geom.union((Geometry) feature.getDefaultGeometry()));
modeGeoms.compute(mode, (m, geom) -> geom == null ? ((Geometry) feature.getDefaultGeometry()) : geom.union((Geometry) feature.getDefaultGeometry()));

}

Expand All @@ -77,7 +77,7 @@ static void prepareDRT(Network network, ShpOptions shp, String modes) {
}

for (Map.Entry<String, Geometry> modeGeometryEntry : modeGeoms.entrySet()) {
if(MGC.coord2Point(link.getFromNode().getCoord()).within(modeGeometryEntry.getValue()) &&
if (MGC.coord2Point(link.getFromNode().getCoord()).within(modeGeometryEntry.getValue()) &&
MGC.coord2Point(link.getToNode().getCoord()).within(modeGeometryEntry.getValue())){
Set<String> allowedModes = new HashSet<>(link.getAllowedModes());
allowedModes.add(modeGeometryEntry.getKey());
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/matsim/run/RunLeipzigIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public final void runOptDrtExamplePopulationTest() {

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");

Expand Down

0 comments on commit 1270018

Please sign in to comment.