Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
luchengqi7 committed Feb 26, 2024
1 parent 19ddedf commit 3efb442
Show file tree
Hide file tree
Showing 17 changed files with 156 additions and 418 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public double estimate(EstimatorContext context, String mode, Leg leg, ModeAvail

// By default, waiting time is scored as travel time
return params.constant +
params.marginalUtilityOfDistance_m * est.distance() +
params.marginalUtilityOfTraveling_s * est.travelTime() +
params.marginalUtilityOfDistance_m * est.rideDistance() +
params.marginalUtilityOfTraveling_s * est.rideTime() +
params.marginalUtilityOfTraveling_s * est.waitingTime() +
context.scoring.marginalUtilityOfMoney * params.monetaryDistanceCostRate * est.distance() +
context.scoring.marginalUtilityOfMoney * params.monetaryDistanceCostRate * est.rideDistance() +
context.scoring.marginalUtilityOfMoney * est.fare();

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
package org.matsim.contrib.drt.teleportation;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.population.Leg;
import org.matsim.api.core.v01.population.PlanElement;
import org.matsim.contrib.drt.estimator.DrtEstimator;
import org.matsim.contrib.drt.estimator.DrtEstimatorParams;
import org.matsim.contrib.drt.routing.*;
import org.matsim.contrib.drt.estimator.impl.PessimisticDrtEstimator;
import org.matsim.contrib.drt.fare.DrtFareParams;
import org.matsim.contrib.drt.run.DrtConfigGroup;
import org.matsim.contrib.drt.run.DrtControlerCreator;
import org.matsim.contrib.drt.run.MultiModeDrtConfigGroup;
import org.matsim.contrib.drt.speedup.DrtSpeedUpParams;
import org.matsim.contrib.dvrp.path.VrpPaths;
import org.matsim.contrib.dvrp.run.AbstractDvrpModeModule;
import org.matsim.contrib.dvrp.run.DvrpConfigGroup;
import org.matsim.core.config.Config;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.controler.Controler;
import org.matsim.core.router.*;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelTime;
import org.matsim.core.utils.io.IOUtils;
import org.matsim.examples.ExamplesUtils;
import org.matsim.testcases.MatsimTestUtils;
import org.matsim.vis.otfvis.OTFVisConfigGroup;

import java.net.URL;
import java.util.*;

class Test2 {
class DrtTeleportationTest {

@RegisterExtension
public MatsimTestUtils utils = new MatsimTestUtils();

@org.junit.jupiter.api.Test
void test1() {

@Test
void testPessimisticEstimator() {
URL url = IOUtils.extendUrl(ExamplesUtils.getTestScenarioURL("mielec"), "mielec_drt_config.xml");
Config config = ConfigUtils.loadConfig(url, new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new OTFVisConfigGroup());

config.network().setInputFile("network.xml");
config.plans().setInputFile("plans_only_drt_1.0.xml.gz");

config.controller().setOutputDirectory(utils.getOutputDirectory());
config.controller().setLastIteration(0);
config.controller().setLastIteration(3);

// install the drt routing stuff, but not the mobsim stuff!
Controler controler = DrtControlerCreator.createControler(config, false);
DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config);
drtConfigGroup.maxTravelTimeAlpha = 1.1;
drtConfigGroup.simulationType = DrtConfigGroup.SimulationType.estimateAndTeleport;

// DrtEstimatorParams params = new DrtEstimatorParams();
// drtConfigGroup.addParameterSet(params);

DrtConfigGroup drtConfigGroup = DrtConfigGroup.getSingleModeDrtConfig(config);
DrtFareParams fareParams = new DrtFareParams();
fareParams.baseFare = 1.0;
fareParams.distanceFare_m = 0.001;
drtConfigGroup.addParameterSet(fareParams);

drtConfigGroup.simulationType = DrtConfigGroup.SimulationType.estimateAndTeleport;
controler.addOverridingModule(new AbstractDvrpModeModule(drtConfigGroup.mode) {
@Override
public void install() {
bindModal(DrtEstimator.class).toInstance(new PessimisticDrtEstimator(drtConfigGroup));
}
});

DrtEstimatorParams params = new DrtEstimatorParams();
drtConfigGroup.addParameterSet(params);

System.out.println(config);

Expand Down
Loading

0 comments on commit 3efb442

Please sign in to comment.