Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drt implementation #10

Merged
merged 39 commits into from
Oct 10, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3530b69
Add necessary setup for
luchengqi7 Aug 5, 2024
7acdaa5
upgrade matsim version
luchengqi7 Aug 9, 2024
f0c0d20
try to make first test run
simei94 Aug 29, 2024
dac0136
Add necessary setup for
luchengqi7 Aug 5, 2024
b2e1d90
upgrade matsim version
luchengqi7 Aug 9, 2024
78cbd40
try to make first test run
simei94 Aug 29, 2024
1fbd817
Merge remote-tracking branch 'origin/drt-implementation' into drt-imp…
simei94 Aug 29, 2024
c47677e
add some todos
simei94 Aug 29, 2024
700e9de
towards proper testing
simei94 Sep 2, 2024
7e56092
simplify test setups
simei94 Sep 2, 2024
414e5a3
no drt in smc (for now)
simei94 Sep 2, 2024
e894ee8
re-arrange drt configs
simei94 Sep 3, 2024
ff66b9a
complete drt test
simei94 Sep 3, 2024
cf7467b
merge latest master branch
luchengqi7 Sep 18, 2024
e26c8b1
Add intermodal stuff
luchengqi7 Sep 18, 2024
617d47d
Update DrtOptions.java
luchengqi7 Sep 18, 2024
076f028
Create PrepareIntermodalTestingPlans.java
luchengqi7 Sep 19, 2024
51d36f7
Update intermodal setup
luchengqi7 Sep 19, 2024
c4f1631
re-structure
simei94 Sep 19, 2024
c9a9e35
class to create manual drt agents WIP
simei94 Sep 19, 2024
fadbfa6
Merge branch 'main' into drt-implementation
simei94 Sep 23, 2024
db82714
re-structuring
simei94 Sep 23, 2024
00d0521
max drt walk distance 1km
simei94 Sep 23, 2024
7288adc
add TODOs
simei94 Sep 23, 2024
8c6f4ff
add intermodal area incl spremberg
simei94 Oct 1, 2024
512777d
make drt test runnable
simei94 Oct 2, 2024
cfe5e07
further improvement
simei94 Oct 2, 2024
0c01bd4
analyze waiting event and link leave event
simei94 Oct 2, 2024
e4864c9
Merge branch 'main' into drt-implementation
simei94 Oct 8, 2024
a2c61a7
re-structure
simei94 Oct 8, 2024
f37c47a
add getters, add method to check and adapt service area shp file
simei94 Oct 8, 2024
ead05fb
add test + feinschliff
simei94 Oct 8, 2024
d7baf7e
use drt area getter in all places
simei94 Oct 9, 2024
4a7be7e
make first test work
simei94 Oct 9, 2024
44f1472
only search for act link if no coord available
simei94 Oct 10, 2024
a7bd495
Merge branch 'main' into drt-implementation
simei94 Oct 10, 2024
42b5e2d
disable test
simei94 Oct 10, 2024
7723460
put new drt inputs to correct version dir
simei94 Oct 10, 2024
589925f
checkstyle
simei94 Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add getters, add method to check and adapt service area shp file
simei94 committed Oct 8, 2024
commit f37c47acce3e14e23529bc599eacbf58f62a8b1f
54 changes: 51 additions & 3 deletions src/main/java/org/matsim/run/DrtOptions.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.matsim.run;

import ch.sbb.matsim.config.SwissRailRaptorConfigGroup;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.geotools.api.feature.simple.SimpleFeature;
import org.matsim.api.core.v01.Id;
import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
@@ -18,6 +21,7 @@
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.config.groups.QSimConfigGroup;
import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.utils.gis.GeoFileWriter;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.pt.config.TransitRouterConfigGroup;
import org.matsim.run.prepare.PrepareNetwork;
@@ -28,12 +32,15 @@
import org.matsim.vehicles.VehicleUtils;
import picocli.CommandLine;

import java.util.List;
import java.util.Set;

/**
* This class bundles some run parameter options and functionalities connected to drt-scenarios.
*/
public class DrtOptions {
private static final Logger log = LogManager.getLogger(DrtOptions.class);

@CommandLine.Option(names = "--drt-shp", description = "Path to shp file for adding drt not network links as an allowed mode.", defaultValue = "./drt-area/nord-bautzen-waiting-times_utm32N.shp")
private String drtAreaShp;

@@ -58,11 +65,12 @@ public class DrtOptions {
@CommandLine.Option(names = "--intermodal", defaultValue = "INTERMODALITY_ACTIVE", description = "enable intermodality for DRT service")
private IntermodalityHandling intermodal;


/**
* a helper method, which makes all necessary config changes to simulate drt.
*/
void configureDrtConfig(Config config) {
public void configureDrtConfig(Config config) {
// check if every feature of shp file has attr typ_wt for drt estimation. Add attr with standard value if not present.
checkServiceAreaShapeFile(config);
DvrpConfigGroup dvrpConfigGroup = ConfigUtils.addOrGetModule(config, DvrpConfigGroup.class);
dvrpConfigGroup.networkModes = Set.of(TransportMode.drt);

@@ -141,7 +149,7 @@ void configureDrtConfig(Config config) {
/**
* a helper method, which makes all necessary scenario changes to simulate drt.
*/
void configureDrtScenario(Scenario scenario) {
public void configureDrtScenario(Scenario scenario) {

// drt route factory has to be added as factory for drt routes, as there were no drt routes before.
scenario.getPopulation()
@@ -180,10 +188,50 @@ void configureDrtScenario(Scenario scenario) {
}
}

private void checkServiceAreaShapeFile(Config config) {
ShpOptions shp = new ShpOptions(drtAreaShp, null, null);
List<SimpleFeature> features = shp.readFeatures();
boolean adapted = false;
for (SimpleFeature feature : features) {
if (feature.getAttribute("typ_wt") == null) {
feature.setAttribute("typ_wt", 10 * 60.);
adapted = true;
}
}

if (adapted) {
log.warn("For drt service area shape file {}, at least one feature did not have the obligatory attribute typ_wt. " +
"The attribute is needed for drt estimation. The attribute was added with a standard value of 10min for those features.", drtAreaShp);

GeoFileWriter.writeGeometries(features, IOUtils.extendUrl(config.getContext(), drtAreaShp).toString());
log.warn("Adapted drt service area shp file written to {}.", drtAreaShp);
}
}

public String getDrtAreaShp() {
return drtAreaShp;
}

public double getTypicalWaitTime() {
return typicalWaitTime;
}

public double getWaitTimeStd() {
return waitTimeStd;
}

public double getRideTimeAlpha() {
return rideTimeAlpha;
}

public double getRideTimeBeta() {
return rideTimeBeta;
}

public double getRideTimeStd() {
return rideTimeStd;
}

/**
* Defines if all necessary configs for intermodality between drt and pt should be made.
*/