Java Code Examples for org.matsim.api.core.v01.Scenario

The following examples show how to use org.matsim.api.core.v01.Scenario. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void run() {

		Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
		new MatsimNetworkReader(scenario.getNetwork()).readFile(networkFile.toString());
		final int[] i = {0};
		Stream<DvrpVehicleSpecification> vehicleSpecificationStream = scenario.getNetwork().getLinks().entrySet().stream()
				.filter(entry -> entry.getValue().getAllowedModes().contains(TransportMode.car)) // drt can only start on links with Transport mode 'car'
				.sorted((e1, e2) -> (random.nextInt(2) - 1)) // shuffle links
				.limit(numberOfVehicles) // select the first *numberOfVehicles* links
				.map(entry -> ImmutableDvrpVehicleSpecification.newBuilder()
						.id(Id.create("drt_" + i[0]++, DvrpVehicle.class))
						.startLinkId(entry.getKey())
						.capacity(seatsPerVehicle)
						.serviceBeginTime(operationStartTime)
						.serviceEndTime(operationEndTime)
						.build());

		new FleetWriter(vehicleSpecificationStream).write(outputFile.toString());
	}
 
Example 2
Source Project: amodeus   Source File: Preparer.java    License: GNU General Public License v2.0 6 votes vote down vote up
public Preparer(File workingDirectory) throws IOException {
    // Static.setup();

    /** amodeus options */
    scenOpt = new ScenarioOptions(workingDirectory, ScenarioOptionsBase.getDefault());

    /** MATSim config */
    config = ConfigUtils.loadConfig(scenOpt.getPreparerConfigName());
    Scenario scenario = ScenarioUtils.loadScenario(config);

    /** adaption of MATSim network, e.g., radius cutting */
    Network network = scenario.getNetwork();
    this.network = NetworkPreparer.run(network, scenOpt);

    /** adaption of MATSim population, e.g., radius cutting */
    this.population = scenario.getPopulation();
}
 
Example 3
@BeforeClass
public static void setup() throws IOException {

    /* input data */
    File scenarioDirectory = new File(Locate.repoFolder(KMeansVirtualNetworkCreatorTest.class, "amodeus"), "resources/testScenario");
    ScenarioOptions scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());

    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    int endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    Network network = scenario.getNetwork();
    Population population = scenario.getPopulation();
    numVNodes = scenarioOptions.getNumVirtualNodes();
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();

    /* generate nCreations networks */
    for (int i = 0; i < nCreations; ++i)
        virtualNetworks.add(virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime));
}
 
Example 4
static public Scenario generate(Config config) {
    config.controler().setOutputDirectory(outputDir + "/output");

    config.controler().setLastIteration(0);
    config.controler().setOverwriteFileSetting(OutputDirectoryHierarchy.OverwriteFileSetting.deleteDirectoryIfExists);
    config.controler().setWriteEventsInterval(-1);
    config.controler().setWritePlansInterval(-1);
    config.controler().setWriteSnapshotsInterval(-1);
    config.controler().setCreateGraphs(false);
    config.controler().setDumpDataAtEnd(false);
    config.qsim().setEndTime(duration * 2);
    config.planCalcScore().getOrCreateScoringParameters(null).getOrCreateActivityParams("activity").setScoringThisActivityAtAll(false);
    config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);

    Random random = new Random(randomSeed);
    Scenario scenario = ScenarioUtils.createScenario(config);

    generateNetwork(scenario.getNetwork());
    generatePopulation(scenario.getPopulation(), scenario.getNetwork(), random);

    return scenario;
}
 
Example 5
Source Project: amodeus   Source File: WaitingTimeTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
static Controler createController(AmodeusConfigGroup avConfigGroup) {
    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE);
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    return controler;
}
 
Example 6
Source Project: amodeus   Source File: TestScenario.java    License: GNU General Public License v2.0 6 votes vote down vote up
static public Controler createController(Scenario scenario, EventHandler handler, int vehicleCapacity) {
    Controler controller = new Controler(scenario);

    controller.addOverridingModule(new DvrpModule());
    controller.addOverridingModule(new DvrpTravelTimeModule());
    controller.addOverridingModule(new AmodeusModule());

    controller.addOverridingModule(new AbstractModule() {
        @Override
        public void install() {
            AmodeusUtils.registerGeneratorFactory(binder(), "Single", SingleVehicleGeneratorFactory.class);
            addEventHandlerBinding().toInstance(handler);
        }

        @Provides
        public SingleVehicleGeneratorFactory provideFactory() {
            return new SingleVehicleGeneratorFactory(vehicleCapacity, Id.createLinkId("link1"));
        }
    });

    controller.addOverridingQSimModule(new AmodeusQSimModule());

    controller.configureQSimComponents(AmodeusQSimModule.activateModes(scenario.getConfig()));

    return controller;
}
 
Example 7
Source Project: amodeus   Source File: TrafficDataModule.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Provides
@Singleton
public QNetworkFactory provideCustomConfigurableQNetworkFactory(EventsManager events, Scenario scenario, //
        TaxiTrafficData trafficData) {
    ConfigurableQNetworkFactory factory = new ConfigurableQNetworkFactory(events, scenario);
    LinkSpeedCalculator linkSpeedCalculator = new AmodeusLinkSpeedCalculator(trafficData);
    factory.setLinkSpeedCalculator(linkSpeedCalculator);
    return factory;
}
 
Example 8
Source Project: amodeus   Source File: RequestTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException {

    /* input data */
    File scenarioDirectory = new File(Locate.repoFolder(RequestTest.class, "amodeus"), "resources/testScenario");
    ScenarioOptions scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath());
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();

    link0 = (Link) network.getLinks().values().toArray()[0];
    link1 = (Link) network.getLinks().values().toArray()[1];
    link2 = (Link) network.getLinks().values().toArray()[2];
}
 
Example 9
Source Project: amodeus   Source File: LPTimeInvariantTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws IOException {
    System.out.println(LPTimeInvariant.class.getName());
    // copy scenario data into main directory
    File scenarioDirectory = new File(Locate.repoFolder(LPTimeInvariantTest.class, "amodeus"), "resources/testScenario");
    System.out.println("scenarioDirectory: " + scenarioDirectory);
    File workingDirectory = MultiFileTools.getDefaultWorkingDirectory();
    GlobalAssert.that(workingDirectory.isDirectory());
    TestFileHandling.copyScnearioToMainDirectory(scenarioDirectory.getAbsolutePath(), workingDirectory.getAbsolutePath());

    /* input data */
    scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    System.out.println("configFile: " + configFile.getAbsolutePath());
    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();
    population = scenario.getPopulation();

    // create 2 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "2");
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork2 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    // create 3 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "3");
    virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork3 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);
}
 
Example 10
Source Project: amodeus   Source File: LPEmptyTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws IOException {
    System.out.println(LPTimeInvariant.class.getName());
    // copy scenario data into main directory
    File scenarioDirectory = new File(Locate.repoFolder(LPEmptyTest.class, "amodeus"), "resources/testScenario");
    System.out.println("scenarioDirectory: " + scenarioDirectory);
    File workingDirectory = MultiFileTools.getDefaultWorkingDirectory();
    GlobalAssert.that(workingDirectory.isDirectory());
    TestFileHandling.copyScnearioToMainDirectory(scenarioDirectory.getAbsolutePath(), workingDirectory.getAbsolutePath());

    /* input data */
    scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    System.out.println("configFile: " + configFile.getAbsolutePath());
    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();
    population = scenario.getPopulation();

    // create 2 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "2");
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork2 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    // create 3 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "3");
    virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork3 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);
}
 
Example 11
Source Project: amodeus   Source File: LPMinFlowTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
public static void setup() throws IOException {
    System.out.println(LPTimeInvariant.class.getName());
    /** input data */
    File scenarioDirectory = new File(Locate.repoFolder(LPMinFlowTest.class, "amodeus"), "resources/testScenario");
    System.out.println("scenarioDirectory: " + scenarioDirectory.getAbsolutePath());
    scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    System.out.println("configFile: " + configFile.getAbsolutePath());
    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    int endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();
    population = scenario.getPopulation();

    // create 2 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "2");
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork2 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    // create 3 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "3");
    virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork3 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    // create 3 node virtual network incomplete
    scenarioOptions.setProperty(ScenarioOptionsBase.COMPLETEGRAPHIDENTIFIER, "false");
    virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork3incomplete = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);
}
 
Example 12
@BeforeClass
public static void setup() throws IOException {
    // copy scenario data into main directory
    File scenarioDirectory = new File(Locate.repoFolder(PopulationToolsTestVN2.class, "amodeus"), "resources/testScenario");
    File workingDirectory = MultiFileTools.getDefaultWorkingDirectory();
    GlobalAssert.that(workingDirectory.exists());
    TestFileHandling.copyScnearioToMainDirectory(scenarioDirectory.getAbsolutePath(), workingDirectory.getAbsolutePath());

    /* input data */
    scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();
    population = scenario.getPopulation();

    // create 2 node virtual network
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "2");
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork2 = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    Link node0 = (Link) virtualNetwork2.getVirtualNode(0).getLinks().toArray()[0];
    Link node1 = (Link) virtualNetwork2.getVirtualNode(1).getLinks().toArray()[0];

    requestsSingle3.add(new Request(10, node0, node1));
    requests3.add(new Request(0, node0, node1));
    requests3.add(new Request(3600, node1, node0));
    requests3.add(new Request(30 * 3600 - 1, node1, node0));
    requests3.add(new Request(3600, node0, node0));
}
 
Example 13
@BeforeClass
public static void setup() throws IOException {

    /** input data */
    File scenarioDirectory = new File(Locate.repoFolder(VehicleToVSGenerator.class, "amodeus"), "resources/testScenario");
    scenarioOptions = new ScenarioOptions(scenarioDirectory, ScenarioOptionsBase.getDefault());
    File configFile = new File(scenarioOptions.getPreparerConfigName());
    AmodeusConfigGroup avCg = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avCg);
    GeneratorConfig genConfig = avCg.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = genConfig.getNumberOfVehicles();
    int endTime = (int) config.qsim().getEndTime().seconds();
    Scenario scenario = ScenarioUtils.loadScenario(config);
    network = scenario.getNetwork();
    population = scenario.getPopulation();
    scenarioOptions.setProperty(ScenarioOptionsBase.NUMVNODESIDENTIFIER, "3");
    VirtualNetworkCreator virtualNetworkCreator = scenarioOptions.getVirtualNetworkCreator();
    virtualNetwork = virtualNetworkCreator.create(network, population, scenarioOptions, numRt, endTime);

    /** creating dummy config with 10 vehicles */
    operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);

    GeneratorConfig avGeneratorConfig = operatorConfig.getGeneratorConfig();
    avGeneratorConfig.setType("strategy");
    avGeneratorConfig.setNumberOfVehicles(10);

    travelData000 = new StaticTravelData(virtualNetwork.getvNetworkID(), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Array.zeros(3), "", endTime);
    travelData123 = new StaticTravelData(virtualNetwork.getvNetworkID(), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Tensors.vector(1, 2, 3), "",
            endTime);
    travelData334 = new StaticTravelData(virtualNetwork.getvNetworkID(), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Array.zeros(3, 3, 3), Tensors.vector(3, 3, 4), "",
            endTime);
}
 
Example 14
Source Project: amodeus   Source File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testStuckScoring() {
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    operatorConfig.getGeneratorConfig().setNumberOfVehicles(0);
    avConfigGroup.addMode(operatorConfig);

    AmodeusScoringConfig scoringParams = operatorConfig.getScoringParameters(null);
    scoringParams.setMarginalUtilityOfWaitingTime(-0.84);

    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);
    config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE); // Refactor av

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    controler.run();

    for (Person person : scenario.getPopulation().getPersons().values()) {
        Assert.assertEquals(-1000.0, person.getSelectedPlan().getScore(), 1e-6);
    }
}
 
Example 15
Source Project: amodeus   Source File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testMultiOD() {
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    operatorConfig.getDispatcherConfig().setType(MultiODHeuristic.TYPE);
    operatorConfig.getGeneratorConfig().setNumberOfVehicles(100);
    operatorConfig.getPricingConfig().setPricePerKm(0.48);
    operatorConfig.getPricingConfig().setSpatialBillingInterval(1000.0);
    avConfigGroup.addMode(operatorConfig);

    AmodeusScoringConfig scoringParams = operatorConfig.getScoringParameters(null);
    scoringParams.setMarginalUtilityOfWaitingTime(-0.84);

    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE); // Refactor av
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    TestScenarioAnalyzer analyzer = new TestScenarioAnalyzer();
    controler.addOverridingModule(analyzer);

    controler.run();

    Assert.assertEquals(0, analyzer.numberOfDepartures - analyzer.numberOfArrivals);
}
 
Example 16
Source Project: amodeus   Source File: RunTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testBasicSetup() {
    // CONFIG PART

    Config config = ConfigUtils.createConfig(new DvrpConfigGroup(), new AmodeusConfigGroup());

    // Add Amodeus mode
    AmodeusModeConfig modeConfig = new AmodeusModeConfig("av");
    modeConfig.getDispatcherConfig().setType("GlobalBipartiteMatchingDispatcher");
    AmodeusConfigGroup.get(config).addMode(modeConfig);

    config.planCalcScore().getOrCreateModeParams("av");

    // DVRP adjustments
    config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);

    // SCENARIO PART

    // Generates a scenario with "av" legs
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    // CONTROLLER PART
    Controler controller = new Controler(scenario);

    controller.addOverridingModule(new DvrpModule());
    controller.addOverridingModule(new AmodeusModule());

    controller.addOverridingQSimModule(new AmodeusQSimModule());
    controller.configureQSimComponents(AmodeusQSimModule.activateModes(AmodeusConfigGroup.get(controller.getConfig())));

    // Some analysis listener for testing
    TestScenarioAnalyzer analyzer = new TestScenarioAnalyzer();
    controller.addOverridingModule(analyzer);

    controller.run();

    Assert.assertEquals(0, analyzer.numberOfDepartures - analyzer.numberOfArrivals);
    Assert.assertEquals(100, analyzer.numberOfDepartures);
}
 
Example 17
static public Scenario generateWithAVLegs(Config config) {
    Scenario scenario = generate(config);

    scenario.getPopulation().getPersons().values().forEach(person -> {
        person.getSelectedPlan().getPlanElements().stream().filter(Leg.class::isInstance).forEach(leg -> ((Leg) leg).setMode(AmodeusModeConfig.DEFAULT_MODE)); // Refactor av
    });

    return scenario;
}
 
Example 18
Source Project: amodeus   Source File: AVPickupDropoffTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testWaitEmptyForPerson() {
    AmodeusConfigGroup config = TestScenario.createConfig();
    Scenario scenario = TestScenario.createScenario(config, Arrays.asList(new TestRequest(0.0, 100.0)));

    TestScenario.ArrivalListener listener = new TestScenario.ArrivalListener();
    Controler controller = TestScenario.createController(scenario, listener, 1);
    controller.run();

    Assert.assertEquals(1, listener.times.size());
    Assert.assertEquals(1014.0 + 100.0, listener.times.get(0), 1e-3);
}
 
Example 19
Source Project: amodeus   Source File: RunDrtTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAmodeusDrt() {
    Config config = ConfigUtils.createConfig(new MultiModeDrtConfigGroup(), new DvrpConfigGroup(), new AmodeusConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);
    run(config, scenario, true);

    // Currently, Amodeus does not know where to put the auto-generated ScenarioOptions file.
    // We can make this a config option for AmodeusConfigGroup.
    FileUtils.deleteQuietly(new File("AmodeusOptions.properties"));
}
 
Example 20
Source Project: amod   Source File: SocketPreparer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** loads scenario preparer in the {@link File} workingDirectory
 * 
 * @param workingDirectory
 * @throws MalformedURLException
 * @throws Exception */
public SocketPreparer(File workingDirectory) throws MalformedURLException, Exception {
    Static.setup();

    /** amodeus options */
    scenOpt = new ScenarioOptions(workingDirectory, ScenarioOptionsBase.getDefault());

    /** MATSim config */
    // configMatsim = ConfigUtils.loadConfig(scenOpt.getPreparerConfigName());
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();
    config = ConfigUtils.loadConfig(scenOpt.getPreparerConfigName(), avConfigGroup);

    Scenario scenario = ScenarioUtils.loadScenario(config);
    GeneratorConfig genConfig = avConfigGroup.getModes().values().iterator().next().getGeneratorConfig();
    numRt = genConfig.getNumberOfVehicles();
    System.out.println("socketPrep NumberOfVehicles=" + numRt);

    /** adaption of MATSim network, e.g., radius cutting */
    Network network = scenario.getNetwork();
    this.network = NetworkPreparer.run(network, scenOpt);

    /** adaption of MATSim population, e.g., radius cutting */
    population = scenario.getPopulation();

    LocationSpec locationSpec = scenOpt.getLocationSpec();
    ReferenceFrame referenceFrame = locationSpec.referenceFrame();
    this.db = MatsimAmodeusDatabase.initialize(network, referenceFrame);
}
 
Example 21
Source Project: pt2matsim   Source File: ScheduleTools.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Transforms a MATSim Transit Schedule file. Overwrites the file.
 */
public static void transformScheduleFile(String scheduleFile, String fromCoordinateSystem, String toCoordinateSystem) {
	log.info("... Transformig schedule from " + fromCoordinateSystem + " to " + toCoordinateSystem);
	final Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig());
	new TransitScheduleReader(fromCoordinateSystem, toCoordinateSystem, scenario).readFile(scheduleFile);
	TransitSchedule schedule = scenario.getTransitSchedule();
	new TransitScheduleWriter(schedule).writeFile(scheduleFile);
}
 
Example 22
Source Project: amodeus   Source File: ScenarioParameters.java    License: GNU General Public License v2.0 4 votes vote down vote up
public ScenarioParameters(ScenarioOptions scenOptions) {
    System.out.println("scenOptions.getSimulationConfigName: " + scenOptions.getSimulationConfigName());

    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(scenOptions.getSimulationConfigName(), avConfigGroup);

    // TODO: This assumes that there is only one mode registered for Amodeus. There are two ways to go
    // forward. Either we need to put in a check somewhere that when Amodeus is used with ScenarioOptions
    // that there is really only one mode registered. Alternatives are to make he ScenarioOptions multimodal
    // or to put all ScenarioOptions into the AmodeusModeConfig. This will happen anyways (for the MATSim
    // users, but I would keep a fallback to the ScenarioOptions file anyways).
    AmodeusModeConfig operatorConfig = avConfigGroup.getModes().values().iterator().next();
    DispatcherConfig dispatcherConfig = operatorConfig.getDispatcherConfig();
    SafeConfig safeConfig = SafeConfig.wrap(dispatcherConfig);
    GeneratorConfig generatorConfig = operatorConfig.getGeneratorConfig();

    redispatchPeriod = safeConfig.getInteger(DISPATCHPERIODSTRING, UNDEFINED_INT);
    rebalancingPeriod = safeConfig.getInteger(REBALANCINGPERIODSTRING, UNDEFINED_INT);
    dispatcher = dispatcherConfig.getType();
    vehicleGenerator = generatorConfig.getType();
    Scenario scenario = ScenarioUtils.loadScenario(config);

    distanceHeuristic = safeConfig.getString(DISTANCEHEURISTICSTRING, UNDEFINED_STRING);
    populationSize = scenario.getPopulation().getPersons().values().size();
    virtualNetworkCreator = scenOptions.getString(ScenarioOptionsBase.VIRTUALNETWORKCREATORIDENTIFIER);

    Network network = scenario.getNetwork();
    if (Objects.isNull(network.getName()))
        networkName = "no network name found in network.xml";
    else
        networkName = network.getName();

    VirtualNetwork<Link> virtualNetwork = null;
    try {
        virtualNetwork = VirtualNetworkGet.readDefault(network, scenOptions);
    } catch (IOException e) {
        System.err.println("INFO not able to load virtual network for report");
        e.printStackTrace();
    }

    virtualNodesCount = Objects.isNull(virtualNetwork) //
            ? UNDEFINED_INT
            : virtualNetwork.getvNodesCount();

    iterations = config.controler().getLastIteration();

}
 
Example 23
Source Project: amodeus   Source File: AmodeusConfigurator.java    License: GNU General Public License v2.0 4 votes vote down vote up
/** Configures a MATSim scenario for use with AMoDeus */
static public void configureScenario(Scenario scenario) {
    scenario.getPopulation().getFactory().getRouteFactories().setRouteFactory(AmodeusRoute.class, new AmodeusRouteFactory());
}
 
Example 24
private static Controler prepare() throws IOException {
    File scenarioDirectory = new File(Locate.repoFolder(StandardMATSimScenarioTest.class, "amodeus"), "resources/testScenario");
    File workingDirectory = MultiFileTools.getDefaultWorkingDirectory();
    GlobalAssert.that(workingDirectory.isDirectory());
    TestFileHandling.copyScnearioToMainDirectory(scenarioDirectory.getAbsolutePath(), workingDirectory.getAbsolutePath());

    StaticHelper.setup();
    MatsimRandom.reset();

    // Set up
    Config config = ConfigUtils.createConfig(new AmodeusConfigGroup(), new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    ScenarioOptions simOptions = new ScenarioOptions(workingDirectory, ScenarioOptionsBase.getDefault());
    LocationSpec locationSpec = simOptions.getLocationSpec();
    ReferenceFrame referenceFrame = locationSpec.referenceFrame();
    MatsimAmodeusDatabase db = MatsimAmodeusDatabase.initialize(scenario.getNetwork(), referenceFrame);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE);
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    // Config

    AmodeusConfigGroup avConfig = AmodeusConfigGroup.get(config);

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    avConfig.addMode(operatorConfig);

    GeneratorConfig generatorConfig = operatorConfig.getGeneratorConfig();
    generatorConfig.setType("VehicleToVSGenerator");
    generatorConfig.setNumberOfVehicles(100);

    // Choose a dispatcher
    DispatcherConfig dispatcherConfig = operatorConfig.getDispatcherConfig();
    dispatcherConfig.addParam("infoLinePeriod", "3600");
    dispatcherConfig.setType("FeedforwardFluidicRebalancingPolicy");

    // Make sure that we do not need the SimulationObjectCompiler
    dispatcherConfig.addParam("publishPeriod", "-1");

    // Set up stuff for TravelData (but we'll generate it on the fly)
    LPOptions lpOptions = new LPOptions(simOptions.getWorkingDirectory(), LPOptionsBase.getDefault());
    lpOptions.setProperty(LPOptionsBase.LPSOLVER, "timeInvariant");
    lpOptions.saveAndOverwriteLPOptions();

    // Set up paths
    operatorConfig.getDispatcherConfig().setVirtualNetworkPath("generatedVirtualNetwork");
    operatorConfig.getDispatcherConfig().setTravelDataPath("generatedTravelData");

    // Controller
    Controler controller = new Controler(scenario);
    AmodeusConfigurator.configureController(controller, db, simOptions);

    // Run
    return controller;
}
 
Example 25
private static void makeMultimodal(Scenario scenario) {
    // Add pt-links to the network to test a multimodal network as it appears in standard MATSim use cases

    Network network = scenario.getNetwork();
    NetworkFactory factory = network.getFactory();

    // Let's build a fast track through the scenario
    for (int i = 0; i < 9; i++) {
        Id<Link> ptFowardLinkId = Id.createLinkId(String.format("pt_fwd_%d:%d", i, i));
        Id<Link> ptBackwardLinkId = Id.createLinkId(String.format("pt_bck_%d:%d", i, i));
        Id<Node> fromNodeId = Id.createNodeId(String.format("%d:%d", i, i));
        Id<Node> toNodeId = Id.createNodeId(String.format("%d:%d", i + 1, i + 1));

        Link ptFowardLink = factory.createLink(ptFowardLinkId, network.getNodes().get(fromNodeId), network.getNodes().get(toNodeId));
        ptFowardLink.setFreespeed(100.0 * 1000.0 / 3600.0);
        ptFowardLink.setLength(1000.0);
        ptFowardLink.setAllowedModes(Collections.singleton("pt"));
        network.addLink(ptFowardLink);

        Link ptBackwardLink = factory.createLink(ptBackwardLinkId, network.getNodes().get(toNodeId), network.getNodes().get(fromNodeId));
        ptBackwardLink.setFreespeed(100.0 * 1000.0 / 3600.0);
        ptBackwardLink.setLength(1000.0);
        ptBackwardLink.setAllowedModes(Collections.singleton("pt"));
        network.addLink(ptBackwardLink);
    }

    // Also, a routed population may have "pt interaction" activities, which take place at links that are not part of the road network. Amodeus must be able
    // to
    // handle these cases.

    /* for (Person person : scenario.getPopulation().getPersons().values())
     * for (Plan plan : person.getPlans()) {
     * Activity trickyActivity = PopulationUtils.createActivityFromCoordAndLinkId("pt interaction", new Coord(5500.0, 5500.0), Id.createLinkId("pt_fwd_5:5"));
     * 
     * plan.getPlanElements().add(PopulationUtils.createLeg("walk"));
     * plan.getPlanElements().add(trickyActivity);
     * } */

    // TODO @sebhoerl Difficult to keep this in as handling of "interaction" activities become much smarter in MATSim now. We would need to
    // set up a much more realistic test scenario. There is one in the AV package, so we can use that one!

    for (Link link : network.getLinks().values()) {
        if (link.getAllowedModes().contains("car")) {
            link.setAllowedModes(new HashSet<>(Arrays.asList("car", AmodeusModeConfig.DEFAULT_MODE)));
        }
    }
}
 
Example 26
Source Project: amodeus   Source File: TestPreparer.java    License: GNU General Public License v2.0 4 votes vote down vote up
private TestPreparer(File workingDirectory) throws Exception {
    System.out.println("working directory: " + workingDirectory);

    // run preparer in simulation working directory
    ScenarioOptions scenarioOptions = new ScenarioOptions(workingDirectory, ScenarioOptionsBase.getDefault());

    // load Settings from IDSC Options
    File configFile = new File(scenarioOptions.getPreparerConfigName());

    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();
    Config config = ConfigUtils.loadConfig(configFile.getAbsolutePath(), avConfigGroup);
    Scenario scenario = ScenarioUtils.loadScenario(config);
    GeneratorConfig avGeneratorConfig = //
            avConfigGroup.getModes().values().iterator().next().getGeneratorConfig();
    int numRt = avGeneratorConfig.getNumberOfVehicles();
    int endTime = (int) config.qsim().getEndTime().seconds();

    // 1) cut network (and reduce population to new network)
    networkPrepared = scenario.getNetwork();        
    NetworkPreparer.run(networkPrepared, scenarioOptions);

    // 2) adapt the population to new network
    populationPrepared = scenario.getPopulation();

    // To make Test input data consistent (e.g. avoid people departing fom "tram" links)
    SnapToClosestNetworkLink.run(populationPrepared, networkPrepared, TransportMode.car);

    PopulationPreparer.run(networkPrepared, populationPrepared, scenarioOptions, config, 10);

    // 3) create virtual Network
    
    // Amodeus uses internally a mode-filtered network (default is the car network). The provided
    // VirtualNetwork needs to be consistent with this node-filtered network.
    Network roadNetwork = NetworkUtils.createNetwork();
    new TransportModeNetworkFilter(networkPrepared).filter(roadNetwork, Collections.singleton("car"));
    new NetworkCleaner().run(roadNetwork);
    
    VirtualNetworkPreparer virtualNetworkPreparer = VirtualNetworkPreparer.INSTANCE;
    VirtualNetwork<Link> virtualNetwork = //
            virtualNetworkPreparer.create(roadNetwork, populationPrepared, scenarioOptions, numRt, endTime);

    // 4) create TravelData
    /** reading the customer requests */
    StaticTravelData travelData = StaticTravelDataCreator.create( //
            scenarioOptions.getWorkingDirectory(), //
            virtualNetwork, roadNetwork, populationPrepared, //
            scenarioOptions.getdtTravelData(), numRt, endTime);
    File travelDataFile = new File(scenarioOptions.getVirtualNetworkDirectoryName(), scenarioOptions.getTravelDataName());
    TravelDataIO.writeStatic(travelDataFile, travelData);

    // 5) save a simulation config file
    // IncludeActTypeOf.BaselineCH(config); // Only needed in Some Scenarios
    ConfigCreator.createSimulationConfigFile(config, scenarioOptions);
}
 
Example 27
Source Project: amodeus   Source File: TestServer.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void simulate() throws Exception {
    boolean waitForClients = scenarioOptions.getBoolean("waitForClients");
    StaticHelper.setup();

    LocationSpec locationSpec = scenarioOptions.getLocationSpec();

    ReferenceFrame referenceFrame = locationSpec.referenceFrame();

    // open server port for clients to connect to
    SimulationServer.INSTANCE.startAcceptingNonBlocking();
    SimulationServer.INSTANCE.setWaitForClients(waitForClients);

    // load MATSim configs - including av.xml where dispatcher is selected.
    System.out.println("loading config file " + configFile.getAbsoluteFile());

    GlobalAssert.that(configFile.exists()); // Test whether the config file
    // directory exists

    DvrpConfigGroup dvrpConfigGroup = new DvrpConfigGroup();
    dvrpConfigGroup.setTravelTimeEstimationAlpha(0.05);
    Config config = ConfigUtils.loadConfig(configFile.toString(), new AmodeusConfigGroup(), dvrpConfigGroup);
    config.planCalcScore().addActivityParams(new PlanCalcScoreConfigGroup.ActivityParams("activity"));

    config.qsim().setStartTime(0.0);
    config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);

    for (ActivityParams activityParams : config.planCalcScore().getActivityParams())
        // TODO @sebhoerl fix this to meaningful values, remove, or add comment
        // this was added because there are sometimes problems, is there a more elegant option?
        activityParams.setTypicalDuration(3600.0);

    String outputdirectory = config.controler().getOutputDirectory();
    System.out.println("outputdirectory = " + outputdirectory);

    // load scenario for simulation
    Scenario scenario = ScenarioUtils.loadScenario(config);
    Network network = scenario.getNetwork();
    Population population = scenario.getPopulation();
    GlobalAssert.that(Objects.nonNull(network) && Objects.nonNull(population));

    MatsimAmodeusDatabase db = MatsimAmodeusDatabase.initialize(network, referenceFrame);
    Controler controller = new Controler(scenario);
    AmodeusConfigurator.configureController(controller, db, scenarioOptions);

    // run simulation
    controller.run();

    // close port for visualization
    SimulationServer.INSTANCE.stopAccepting();

    Analysis analysis = Analysis.setup(scenarioOptions, new File(workingDirectory, "output/001"), network, db);
    analysis.addAnalysisExport(ate);
    analysis.addAnalysisExport(new RoboTaxiHistoriesExportFromEvents(network, config));
    analysis.addAnalysisExport(new RequestHistoriesExportFromEvents(network, config));
    analysis.run();
}
 
Example 28
Source Project: amodeus   Source File: PreroutingTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testPreRouting() {
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    operatorConfig.setPredictRouteTravelTime(true);
    operatorConfig.getGeneratorConfig().setNumberOfVehicles(100);
    avConfigGroup.addMode(operatorConfig);

    AmodeusScoringConfig scoringParams = operatorConfig.getScoringParameters(null);
    scoringParams.setMarginalUtilityOfWaitingTime(-0.84);

    operatorConfig.getPricingConfig().setPricePerKm(1.0);

    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    config.plansCalcRoute().setRoutingRandomness(0.0);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE);
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    StrategySettings strategySettings = new StrategySettings();
    strategySettings.setStrategyName("KeepLastSelected");
    strategySettings.setWeight(1.0);
    config.strategy().addStrategySettings(strategySettings);

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    controler.run();

    for (Person person : scenario.getPopulation().getPersons().values()) {
        Plan plan = person.getSelectedPlan();

        for (PlanElement element : plan.getPlanElements()) {
            if (element instanceof Leg) {
                Leg leg = (Leg) element;
                AmodeusRoute route = (AmodeusRoute) leg.getRoute();

                Assert.assertTrue(route.getTravelTime().isDefined() && Double.isFinite(route.getTravelTime().seconds()));
                Assert.assertTrue(route.getExpectedDistance().isPresent());
                Assert.assertTrue(route.getWaitingTime().isDefined());
                Assert.assertTrue(route.getPrice().isPresent());
                Assert.assertTrue(route.getPrice().get() > 0.0);
            }
        }
    }
}
 
Example 29
Source Project: amodeus   Source File: RunTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testAVExampleWithAccessEgress() {
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    operatorConfig.getGeneratorConfig().setNumberOfVehicles(100);
    operatorConfig.getPricingConfig().setPricePerKm(0.48);
    operatorConfig.getPricingConfig().setSpatialBillingInterval(1000.0);
    avConfigGroup.addMode(operatorConfig);

    AmodeusScoringConfig scoringParams = operatorConfig.getScoringParameters(null);
    scoringParams.setMarginalUtilityOfWaitingTime(-0.84);

    operatorConfig.setUseAccessAgress(true);

    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    Iterator<? extends Person> iterator = scenario.getPopulation().getPersons().values().iterator();
    for (int i = 0; i < 3; i++) {
        Person person = iterator.next();

        for (PlanElement element : person.getSelectedPlan().getPlanElements()) {
            if (element instanceof Activity) {
                Activity activity = (Activity) element;
                activity.setCoord(CoordUtils.plus(activity.getCoord(), new Coord(5.0, 5.0)));
            }
        }
    }

    ActivityParams activityParams = new ActivityParams("amodeus interaction");
    activityParams.setTypicalDuration(1.0);
    config.planCalcScore().addActivityParams(activityParams);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE); // Refactor av
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    TestScenarioAnalyzer analyzer = new TestScenarioAnalyzer();
    controler.addOverridingModule(analyzer);

    controler.run();

    Assert.assertEquals(0, analyzer.numberOfDepartures - analyzer.numberOfArrivals);
    Assert.assertEquals(6, analyzer.numberOfInteractionActivities);
}
 
Example 30
Source Project: amodeus   Source File: RunTest.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testAVExampleWithAccessEgressAttribute() {
    AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup();

    AmodeusModeConfig operatorConfig = new AmodeusModeConfig(AmodeusModeConfig.DEFAULT_MODE);
    operatorConfig.getGeneratorConfig().setNumberOfVehicles(100);
    operatorConfig.getPricingConfig().setPricePerKm(0.48);
    operatorConfig.getPricingConfig().setSpatialBillingInterval(1000.0);
    operatorConfig.getInteractionFinderConfig().setType(LinkAttributeInteractionFinder.TYPE);
    operatorConfig.getInteractionFinderConfig().getParams().put("allowedLinkAttribute", "avflag");
    avConfigGroup.addMode(operatorConfig);

    AmodeusScoringConfig scoringParams = operatorConfig.getScoringParameters(null);
    scoringParams.setMarginalUtilityOfWaitingTime(-0.84);

    operatorConfig.setUseAccessAgress(true);

    Config config = ConfigUtils.createConfig(avConfigGroup, new DvrpConfigGroup());
    Scenario scenario = TestScenarioGenerator.generateWithAVLegs(config);

    for (Link link : scenario.getNetwork().getLinks().values()) {
        if (link.getFromNode().getCoord().getX() == 5000.0) {
            link.getAttributes().putAttribute("avflag", true);
        }
    }

    ActivityParams activityParams = new ActivityParams("amodeus interaction");
    activityParams.setTypicalDuration(1.0);
    config.planCalcScore().addActivityParams(activityParams);

    PlanCalcScoreConfigGroup.ModeParams modeParams = config.planCalcScore().getOrCreateModeParams(AmodeusModeConfig.DEFAULT_MODE); // Refactor av
    modeParams.setMonetaryDistanceRate(0.0);
    modeParams.setMarginalUtilityOfTraveling(8.86);
    modeParams.setConstant(0.0);

    config.qsim().setEndTime(40.0 * 3600.0);
    config.qsim().setSimStarttimeInterpretation(StarttimeInterpretation.onlyUseStarttime);

    Controler controler = new Controler(scenario);
    controler.addOverridingModule(new DvrpModule());
    controler.addOverridingModule(new AmodeusModule());
    controler.addOverridingQSimModule(new AmodeusQSimModule());

    controler.configureQSimComponents(AmodeusQSimModule.activateModes(avConfigGroup));

    TestScenarioAnalyzer analyzer = new TestScenarioAnalyzer();
    controler.addOverridingModule(analyzer);

    controler.run();

    Assert.assertEquals(0, analyzer.numberOfDepartures - analyzer.numberOfArrivals);
    Assert.assertEquals(163, analyzer.numberOfInteractionActivities);
}