org.matsim.core.config.Config Java Examples

The following examples show how to use org.matsim.core.config.Config. 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
Source File: WaitingTimeTest.java    From amodeus with 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 #2
Source File: SocketDispatcherHost.java    From amod with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    // TODO: Probably worth configuring this in some other way (not binding String and int)
    int numReqTot = inject.get(int.class);
    StringSocket stringSocket = inject.get(StringSocket.class);

    return new SocketDispatcherHost(network, config, operatorConfig, travelTime, router, eventsManager, //
            stringSocket, numReqTot, db);
}
 
Example #3
Source File: GlobalBipartiteMatchingDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected GlobalBipartiteMatchingDispatcher(Network network, Config config, //
        AmodeusModeConfig operatorConfig, TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    DistanceHeuristics distanceHeuristics = //
            dispatcherConfig.getDistanceHeuristics(DistanceHeuristics.EUCLIDEAN);
    System.out.println("Using DistanceHeuristics: " + distanceHeuristics.name());
    distanceFunction = distanceHeuristics.getDistanceFunction(network);
    this.network = network;
    /** matching algorithm - standard is a solution to the assignment problem with the Hungarian method */
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    bipartiteMatcher = new ConfigurableBipartiteMatcher(network, new DistanceCost(distanceFunction), //
            safeConfig);
}
 
Example #4
Source File: RestrictedLinkCapacityDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected RestrictedLinkCapacityDispatcher(Network network, //
        Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db, ParkingStrategy parkingStrategy, //
        ParkingCapacity avSpatialCapacityAmodeus) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(60);
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    sharingPeriod = safeConfig.getInteger("sharingPeriod", 10); // makes sense to choose this value similar to the pickup duration
    double rMax = safeConfig.getDouble("rMax", 1000.0);
    double phiMax = Pi.in(100).multiply(RealScalar.of(safeConfig.getDouble("phiMaxDeg", 5.0) / 180.0)).number().doubleValue();
    beamExtensionForSharing = new BeamExtensionForSharing(rMax, phiMax);
    this.networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    this.requestMaintainer = new TreeMaintainer<>(networkBounds, this::getLocation);

    /** PARKING EXTENSION */
    this.parkingStrategy = parkingStrategy;
    DistanceHeuristics distanceHeuristics = //
            dispatcherConfig.getDistanceHeuristics(DistanceHeuristics.ASTARLANDMARKS);
    this.parkingStrategy.setRuntimeParameters(avSpatialCapacityAmodeus, network, distanceHeuristics.getDistanceFunction(network));
    /** PARKING EXTENSION */
}
 
Example #5
Source File: FeedforwardFluidicRebalancingPolicy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    VirtualNetwork<Link> virtualNetwork = inject.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
    });

    TravelData travelData = inject.getModal(TravelData.class);

    AbstractVirtualNodeDest abstractVirtualNodeDest = new RandomVirtualNodeDest();
    AbstractRoboTaxiDestMatcher abstractVehicleDestMatcher = new GlobalBipartiteMatching(EuclideanDistanceCost.INSTANCE);
    return new FeedforwardFluidicRebalancingPolicy(config, operatorConfig, travelTime, router, eventsManager, network, virtualNetwork, //
            abstractVirtualNodeDest, abstractVehicleDestMatcher, travelData, db);
}
 
Example #6
Source File: ParkHighCapacityDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    // TODO: Eventually, if this should be individual for multiple Amodeus modes, this needs to become modal!
    ParkingStrategy parkingStrategy = inject.get(ParkingStrategy.class);
    ParkingCapacity avSpatialCapacityAmodeus = inject.get(ParkingCapacity.class);

    return new ParkHighCapacityDispatcher(network, config, operatorConfig, travelTime, router, eventsManager, db, Objects.requireNonNull(parkingStrategy),
            Objects.requireNonNull(avSpatialCapacityAmodeus));
}
 
Example #7
Source File: AdaptiveRealTimeRebalancingPolicy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    VirtualNetwork<Link> virtualNetwork = inject.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
    });

    AbstractVirtualNodeDest abstractVirtualNodeDest = new RandomVirtualNodeDest();
    AbstractRoboTaxiDestMatcher abstractVehicleDestMatcher = new GlobalBipartiteMatching(EuclideanDistanceCost.INSTANCE);
    return new AdaptiveRealTimeRebalancingPolicy( //
            config, operatorConfig, travelTime, //
            router, eventsManager, network, virtualNetwork, //
            abstractVirtualNodeDest, abstractVehicleDestMatcher, db);
}
 
Example #8
Source File: FeedforwardFluidicTimeVaryingRebalancingPolicy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    VirtualNetwork<Link> virtualNetwork = inject.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
    });

    TravelData travelData = inject.getModal(TravelData.class);

    AbstractVirtualNodeDest abstractVirtualNodeDest = new RandomVirtualNodeDest();
    AbstractRoboTaxiDestMatcher abstractVehicleDestMatcher = new GlobalBipartiteMatching(EuclideanDistanceCost.INSTANCE);
    return new FeedforwardFluidicTimeVaryingRebalancingPolicy(config, operatorConfig, travelTime, router, eventsManager, network, virtualNetwork, abstractVirtualNodeDest,
            abstractVehicleDestMatcher, travelData, db);
}
 
Example #9
Source File: DFRStrategy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    VirtualNetwork<Link> virtualNetwork = inject.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
    });

    TravelData travelData = inject.getModal(TravelData.class);

    return new DFRStrategy(network, virtualNetwork, config, operatorConfig, travelTime, router, //
            eventsManager, travelData, db);
}
 
Example #10
Source File: SharedPartitionedDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected SharedPartitionedDispatcher( //
        Config config, //
        AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, //
        ParallelLeastCostPathCalculator router, //
        EventsManager eventsManager, //
        VirtualNetwork<Link> virtualNetwork, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);

    if (virtualNetwork == null)
        throw new IllegalStateException(
                "The VirtualNetwork is not set. Make sure you active DefaultVirtualNetworkModule in the ScenarioServer, OR provide a custom VirtualNetwork via injection.");

    this.virtualNetwork = Objects.requireNonNull(virtualNetwork);
}
 
Example #11
Source File: FirstComeFirstServedStrategy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected FirstComeFirstServedStrategy(Network network, //
        Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);

    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    this.unassignedRoboTaxis = new TreeMaintainer<>(networkBounds, this::getRoboTaxiLoc);
    this.unassignedRequests = new TreeMultipleItems<>(PassengerRequest::getSubmissionTime);
    this.requestsLastHour = new TreeMultipleItems<>(PassengerRequest::getSubmissionTime);

    FastAStarLandmarksFactory factory = new FastAStarLandmarksFactory(Runtime.getRuntime().availableProcessors());
    LeastCostPathCalculator calculator = EasyMinTimePathCalculator.prepPathCalculator(network, factory);
    timeDb = new CachedNetworkTimeDistance(calculator, MAXLAGTRAVELTIMECALCULATION, TimeDistanceProperty.INSTANCE);

    this.kockelmanRebalancing = new BlockRebalancing(network, timeDb, MINNUMBERROBOTAXISINBLOCKTOREBALANCE, BINSIZETRAVELDEMAND, dispatchPeriod, REBALANCINGGRIDDISTANCE);
}
 
Example #12
Source File: PartitionedDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected PartitionedDispatcher( //
        Config config, //
        AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, //
        ParallelLeastCostPathCalculator router, //
        EventsManager eventsManager, //
        VirtualNetwork<Link> virtualNetwork, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);

    if (Objects.isNull(virtualNetwork))
        throw new IllegalStateException(
                "The VirtualNetwork is not set. Make sure you active DefaultVirtualNetworkModule in the ScenarioServer, OR provide a custom VirtualNetwork via injection.");

    this.virtualNetwork = Objects.requireNonNull(virtualNetwork);
}
 
Example #13
Source File: TShareDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    VirtualNetwork<Link> virtualNetwork = inject.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
    });

    return new TShareDispatcher(network, config, operatorConfig, travelTime, router, eventsManager, //
            db, virtualNetwork);
}
 
Example #14
Source File: ExtDemandSupplyBeamSharing.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected ExtDemandSupplyBeamSharing(Network network, //
        Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(60);
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    sharingPeriod = safeConfig.getInteger("sharingPeriod", 10); // makes sense to choose this value similar to the pickup duration
    double rMax = safeConfig.getDouble("rMax", 1000.0);
    double phiMax = Pi.in(100).multiply(RealScalar.of(safeConfig.getDouble("phiMaxDeg", 5.0) / 180.0)).number().doubleValue();
    beamExtensionForSharing = new BeamExtensionForSharing(rMax, phiMax);
    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    this.requestMaintainer = new TreeMaintainer<>(networkBounds, this::getLocation);
    this.unassignedRoboTaxis = new TreeMaintainer<>(networkBounds, this::getRoboTaxiLoc);
}
 
Example #15
Source File: RunTest.java    From amodeus with 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 #16
Source File: AmodeusConfigGroup.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
static public AmodeusConfigGroup get(Config config) {
    AmodeusConfigGroup amodeusConfig = (AmodeusConfigGroup) config.getModules().get(AmodeusConfigGroup.GROUP_NAME);

    if (amodeusConfig == null) {
        amodeusConfig = new AmodeusConfigGroup();
        config.addModule(amodeusConfig);
    }

    return amodeusConfig;
}
 
Example #17
Source File: AbstractNoExplicitCommunication.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
protected AbstractNoExplicitCommunication(Network network, Config config, //
        AmodeusModeConfig operatorConfig, TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    this.network = network;
    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    requestMaintainer = new TreeMaintainer<>(networkBounds, TensorLocation::of);
}
 
Example #18
Source File: VirtualNetworkModeModule.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
static private TravelData provideTravelDataFromConfig(InstanceGetter getter) {
    try {
        AmodeusModeConfig modeConfig = getter.getModal(AmodeusModeConfig.class);
        DispatcherConfig dispatcherConfig = modeConfig.getDispatcherConfig();

        VirtualNetwork<Link> virtualNetwork = getter.getModal(new TypeLiteral<VirtualNetwork<Link>>() {
        });
        Network network = getter.getModal(Network.class);
        Config config = getter.get(Config.class);
        ScenarioOptions scenarioOptions = getter.get(ScenarioOptions.class);
        Population population = getter.get(Population.class);

        URL travelDataUrl = ConfigGroup.getInputFileURL(config.getContext(), dispatcherConfig.getTravelDataPath());
        File travelDataFile = new File(travelDataUrl.getPath());

        if (!travelDataFile.exists() || dispatcherConfig.getRegenerateTravelData()) {
            logger.info(String.format("Regenerating TravelData for mode '%s' at '%s'", modeConfig.getMode(), travelDataFile));
            logger.info("Currently we use information from ScenarioOptions for that. Later on this should be moved to a specific config module.");
            logger.info("Using StaticTravelDataCreator");

            File workingDirectory = new File(config.getContext().getPath()).getParentFile();
            int numberOfVehicles = modeConfig.getGeneratorConfig().getNumberOfVehicles();
            int interval = scenarioOptions.getdtTravelData();

            StaticTravelData travelData = StaticTravelDataCreator.create(workingDirectory, virtualNetwork, network, population, interval, numberOfVehicles, //
                    (int) config.qsim().getEndTime().seconds());
            TravelDataIO.writeStatic(travelDataFile, travelData);
        }

        logger.info(String.format("Loading TravelData for mode '%s' from '%s'", modeConfig.getMode(), travelDataFile));
        return TravelDataGet.readFile(virtualNetwork, travelDataFile);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #19
Source File: RequestTest.java    From amodeus with 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 #20
Source File: DemoDispatcher.java    From amod with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    return new DemoDispatcher(config, operatorConfig, travelTime, router, eventsManager, network, db);
}
 
Example #21
Source File: ArtificialSharedScenarioCreator.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public ArtificialSharedScenarioCreator(Config config) {

        LinkTimePair divertableLinkTime = new LinkTimePair(linkDepotOut, 0.0);

        Id<DvrpVehicle> idAv1 = Id.create("av1", DvrpVehicle.class);
        vehicle1 = new DvrpVehicleImpl(ImmutableDvrpVehicleSpecification.newBuilder() //
                .id(idAv1) //
                .serviceBeginTime(0.0) //
                .serviceEndTime(Double.POSITIVE_INFINITY) //
                .capacity(3) //
                .startLinkId(linkDepotOut.getId()) //
                .build(), linkDepotOut);
        roboTaxi1 = new RoboTaxi(vehicle1, divertableLinkTime, linkDepotOut, RoboTaxiUsageType.SHARED);
        setFirstStayTask(vehicle1);

        Id<DvrpVehicle> idAv2 = Id.create("av2", DvrpVehicle.class);
        vehicle2 = new DvrpVehicleImpl(ImmutableDvrpVehicleSpecification.newBuilder() //
                .id(idAv2) //
                .serviceBeginTime(0.0) //
                .serviceEndTime(Double.POSITIVE_INFINITY) //
                .capacity(3) //
                .startLinkId(linkDepotOut.getId()) //
                .build(), linkDepotOut);
        roboTaxi2 = new RoboTaxi(vehicle2, divertableLinkTime, linkDepotOut, RoboTaxiUsageType.SHARED);
        setFirstStayTask(vehicle2);
        System.out.println("ArtificialScenario Created");
    }
 
Example #22
Source File: BasicUniversalDispatcher.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public BasicUniversalDispatcher(EventsManager eventsManager, Config config, //
        AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, ParallelLeastCostPathCalculator parallelLeastCostPathCalculator, //
        MatsimAmodeusDatabase db) {
    super(eventsManager, config, operatorConfig);
    this.db = db;
    futurePathFactory = new FuturePathFactory(parallelLeastCostPathCalculator, travelTime);
    pickupDurationPerStop = operatorConfig.getTimingConfig().getMinimumPickupDurationPerStop();
    dropoffDurationPerStop = operatorConfig.getTimingConfig().getMinimumDropoffDurationPerStop();
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    publishPeriod = operatorConfig.getDispatcherConfig().getPublishPeriod();
    dispatcherMode = operatorConfig.getMode();
}
 
Example #23
Source File: DemoDispatcherShared.java    From amod with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    return new DemoDispatcherShared(network, config, operatorConfig, travelTime, router, eventsManager, db);
}
 
Example #24
Source File: DFRStrategy.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
private DFRStrategy(Network network, VirtualNetwork<Link> virtualNetwork, Config config, //
        AmodeusModeConfig operatorConfig, TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, TravelData travelData, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, virtualNetwork, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    rebalancingPeriod = dispatcherConfig.getRebalancingPeriod(300);
    DistanceHeuristics distanceHeuristics = //
            dispatcherConfig.getDistanceHeuristics(DistanceHeuristics.EUCLIDEAN);
    System.out.println("Using DistanceHeuristics: " + distanceHeuristics.name());
    distanceFunction = distanceHeuristics.getDistanceFunction(network);
    this.network = network;
    this.travelData = travelData;
    this.neighboring = new Neighboring(virtualNetwork, network);
    this.ownedRoboTaxis = new OwnedRoboTaxis(virtualNetwork);
    this.rounder = new Rounder(virtualNetwork);
    this.metropolisHastings = new MetropolisHastings(virtualNetwork, neighboring).getAll();
    this.vehicleDestMatcher = new GlobalBipartiteMatching(EuclideanDistanceCost.INSTANCE);
    this.virtualNodeDest = new RandomVirtualNodeDest();
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig);
    bipartiteMatchingUtils = new ConfigurableBipartiteMatcher(network, new DistanceCost(distanceFunction), safeConfig);
    this.doDFR = dispatcherConfig.getBoolStrict("DFR");
    this.config = config;
    System.out.println("DFR is set to: " + doDFR);
    System.out.println("travelData: " + travelData.getLPName());
}
 
Example #25
Source File: LPMinFlowTest.java    From amodeus with 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 #26
Source File: RunTest.java    From amodeus with 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 #27
Source File: ModelFreeAdaptiveRepositioning.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    Config config = inject.get(Config.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);
    EventsManager eventsManager = inject.get(EventsManager.class);

    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter router = inject.getModal(AmodeusRouter.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);

    return new ModelFreeAdaptiveRepositioning( //
            network, config, operatorConfig, travelTime, router, eventsManager, db);
}
 
Example #28
Source File: PopulationToolsTestVN2.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
@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 #29
Source File: FeedforwardFluidicRebalancingPolicy.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public FeedforwardFluidicRebalancingPolicy( //
        Config config, //
        AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, //
        AmodeusRouter router, //
        EventsManager eventsManager, //
        Network network, //
        VirtualNetwork<Link> virtualNetwork, //
        AbstractVirtualNodeDest abstractVirtualNodeDest, //
        AbstractRoboTaxiDestMatcher abstractVehicleDestMatcher, //
        TravelData travelData, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, virtualNetwork, db);
    virtualNodeDest = abstractVirtualNodeDest;
    vehicleDestMatcher = abstractVehicleDestMatcher;

    this.network = network;
    nVNodes = virtualNetwork.getvNodesCount();
    nVLinks = virtualNetwork.getvLinksCount();
    rebalanceCount = Array.zeros(nVNodes, nVNodes);
    rebalanceCountInteger = Array.zeros(nVNodes, nVNodes);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    rebalancingPeriod = dispatcherConfig.getRebalancingPeriod(30);
    distanceHeuristics = dispatcherConfig.getDistanceHeuristics(DistanceHeuristics.EUCLIDEAN);
    System.out.println("Using DistanceHeuristics: " + distanceHeuristics.name());
    this.distanceFunction = distanceHeuristics.getDistanceFunction(network);
    this.bipartiteMatcher = new ConfigurableBipartiteMatcher(network, new DistanceCost(distanceFunction), //
            SafeConfig.wrap(operatorConfig.getDispatcherConfig()));
    this.travelData = travelData;
    System.out.println(travelData.getLPName());
    System.out.println(LPTimeInvariant.class.getSimpleName());
    if (!travelData.getLPName().equals(LPTimeInvariant.class.getSimpleName())) {
        System.err.println("Running the " + this.getClass().getSimpleName() + " requires precomputed data that must be\n"
                + "computed in the ScenarioPreparer. Currently the file LPOptions.properties is set to compute the feedforward\n" + "rebalancing data with: ");
        System.err.println(travelData.getLPName());
        System.err.println("The correct setting in LPOptions.properties to run this dispatcher is:  " + LPCreator.TIMEINVARIANT.name());
        throw new RuntimeException();
    }
}
 
Example #30
Source File: DemoDispatcherShared.java    From amod with GNU General Public License v2.0 5 votes vote down vote up
protected DemoDispatcherShared(Network network, //
        Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    this.cityNorthPole = getNorthPole(network);
    this.equatorLinks = getEquator(network);
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = safeConfig.getInteger("dispatchPeriod", 30);
    rebalancePeriod = safeConfig.getInteger("rebalancingPeriod", 1800);
    Collections.shuffle(new ArrayList<>(network.getLinks().values()), randGen);
}