Skip to content

Commit

Permalink
Add necessary setup for
Browse files Browse the repository at this point in the history
DRT estimate and teleportation
  • Loading branch information
luchengqi7 committed Aug 5, 2024
1 parent 1cfcd79 commit 3530b69
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/main/java/org/matsim/run/RunLausitzDrtScenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.matsim.api.core.v01.network.Link;
import org.matsim.application.MATSimApplication;
import org.matsim.application.options.ShpOptions;
import org.matsim.contrib.drt.estimator.DrtEstimatorModule;
import org.matsim.contrib.drt.optimizer.constraints.DefaultDrtOptimizationConstraintsSet;
import org.matsim.contrib.drt.optimizer.constraints.DrtOptimizationConstraintsParams;
import org.matsim.contrib.drt.optimizer.insertion.extensive.ExtensiveInsertionSearchParams;
Expand All @@ -24,6 +25,7 @@
import org.matsim.core.config.groups.QSimConfigGroup;
import org.matsim.core.config.groups.ScoringConfigGroup;
import org.matsim.core.config.groups.SubtourModeChoiceConfigGroup;
import org.matsim.core.controler.AbstractModule;
import org.matsim.core.controler.Controler;
import org.matsim.core.network.algorithms.MultimodalNetworkCleaner;
import org.matsim.core.utils.geometry.geotools.MGC;
Expand Down Expand Up @@ -98,6 +100,11 @@ protected Config prepareConfig(Config config) {
multiModeDrtConfigGroup.addParameterSet(drtConfigGroup);
}

// set to drt estimate and teleport
for (DrtConfigGroup drtConfigGroup : multiModeDrtConfigGroup.getModalElements()) {
drtConfigGroup.simulationType = DrtConfigGroup.SimulationType.estimateAndTeleport;
}

// this is needed for DynAgents for DVRP
config.qsim().setSimStarttimeInterpretation(QSimConfigGroup.StarttimeInterpretation.onlyUseStarttime);

Expand Down Expand Up @@ -174,6 +181,7 @@ protected void prepareScenario(Scenario scenario) {

//TODO: is the following if clause needed when using the DRT Estimator?!
// TODO: @CL where does the estimator draw its vehicles from? Are vehicle types even needed?
// --> No vehicle file is needed if DRT estimator is used. But the vehicle file can be specified as usual.
// if there are no vehicles of above type: add some
if (scenario.getVehicles().getVehicles().values().stream().filter(v -> v.getType().getId().equals(drtTypeId)).toList().isEmpty()) {

Expand All @@ -195,6 +203,8 @@ protected void prepareScenario(Scenario scenario) {
protected void prepareControler(Controler controler) {
// TODO

Config config = controler.getConfig();

// apply all controller changes from base scenario class
baseScenario.prepareControler(controler);

Expand All @@ -206,7 +216,23 @@ protected void prepareControler(Controler controler) {
// this is necessary for drt / dvrp to work!
controler.configureQSimComponents(DvrpQSimComponents.activateAllModes(ConfigUtils.addOrGetModule(controler.getConfig(), MultiModeDrtConfigGroup.class)));


MultiModeDrtConfigGroup multiModeDrtConfigGroup = MultiModeDrtConfigGroup.get(config);
for (DrtConfigGroup drtConfigGroup : multiModeDrtConfigGroup.getModalElements()) {
// TODO uncomment theses after the new estimator is merged to the matsim-lib master branch
// controler.addOverridingModule(new AbstractModule() {
// @Override
// public void install() {
// DrtEstimatorModule.bindEstimator(binder(), drtConfigGroup.mode).toInstance(
// new DirectTripBasedDrtEstimator.Builder()
// .setWaitingTimeEstimator(new ConstantWaitingTimeEstimator(meanWaitTime))
// .setWaitingTimeDistributionGenerator(new NormalDistributionGenerator(1, waitTimeStd))
// .setRideDurationEstimator(new ConstantRideDurationEstimator(rideTimeAlpha, rideTimeBeta))
// .setRideDurationDistributionGenerator(new NormalDistributionGenerator(2, rideTimeStd))
// .build()
// );
// }
// });
}

}
}

0 comments on commit 3530b69

Please sign in to comment.