org.matsim.core.router.util.TravelTime Java Examples

The following examples show how to use org.matsim.core.router.util.TravelTime. 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: 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 #2
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 #3
Source File: ModelFreeAdaptiveRepositioning.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
private ModelFreeAdaptiveRepositioning(Network network, Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    this.network = network;
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    rebalancingPeriod = dispatcherConfig.getRebalancingPeriod(900);
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig);
    assignmentMatcher = new ConfigurableBipartiteMatcher(network, EuclideanDistanceCost.INSTANCE, safeConfig);
    String rebWeight = safeConfig.getString("matchingReb", "HUNGARIAN");
    if (rebWeight.equals("HUNGARIAN")) {
        rebalanceMatcher = new GlobalBipartiteMatching(EuclideanDistanceCost.INSTANCE);
    } else {
        Tensor weights = Tensors.fromString(rebWeight);
        rebalanceMatcher = new GlobalBipartiteMatchingILP(EuclideanDistanceCost.INSTANCE, weights);
    }
    long numRT = operatorConfig.getGeneratorConfig().getNumberOfVehicles();
    lastRebLoc = new FIFOFixedQueue<>((int) numRT);

    System.out.println("dispatchPeriod:  " + dispatchPeriod);
    System.out.println("rebalancePeriod: " + rebalancingPeriod);
}
 
Example #4
Source File: SQMDispatcher.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 SQMDispatcher(config, operatorConfig, travelTime, router, eventsManager, network, //
            virtualNetwork, db);
}
 
Example #5
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 #6
Source File: AdaptiveRealTimeRebalancingPolicy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
public AdaptiveRealTimeRebalancingPolicy( //
        Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, //
        Network network, VirtualNetwork<Link> virtualNetwork, //
        AbstractVirtualNodeDest abstractVirtualNodeDest, //
        AbstractRoboTaxiDestMatcher abstractVehicleDestMatcher, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, virtualNetwork, db);
    virtualNodeDest = abstractVirtualNodeDest;
    vehicleDestMatcher = abstractVehicleDestMatcher;
    numRobotaxi = operatorConfig.getGeneratorConfig().getNumberOfVehicles();
    lpMinFlow = new LPMinFlow(virtualNetwork);
    lpMinFlow.initiateLP();
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(30);
    rebalancingPeriod = dispatcherConfig.getRebalancingPeriod(300);
    this.network = network;
    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()));
}
 
Example #7
Source File: AmodeusDrtModule.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void install() {
    bindModal(AmodeusModeConfig.class).toInstance(config);

    bindModal(TravelTime.class).to(Key.get(TravelTime.class, Names.named(DvrpTravelTimeModule.DVRP_ESTIMATED)));

    bindModal(RouterShutdownListener.class).toProvider(modalProvider(getter -> {
        return new RouterShutdownListener(getter.getModal(AmodeusRouter.class));
    })).in(Singleton.class);
    addControlerListenerBinding().to(modalKey(RouterShutdownListener.class));

    bindModal(AmodeusRouter.class).toProvider(modalProvider(getter -> {
        AmodeusModeConfig operatorConfig = getter.getModal(AmodeusModeConfig.class);
        String routerName = operatorConfig.getRouterConfig().getType();

        AmodeusRouter.Factory factory = getter.get(RouterRegistry.class).get(routerName);
        return factory.createRouter(getter);
    })).in(Singleton.class);
}
 
Example #8
Source File: MultiODHeuristic.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
@Override
public AmodeusDispatcher createDispatcher(InstanceGetter inject) {
    EventsManager eventsManager = inject.get(EventsManager.class);
    TravelTime travelTime = inject.getModal(TravelTime.class);
    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    AmodeusRouter parallelRouter = inject.getModal(AmodeusRouter.class);

    DispatcherConfig dispatcherConfig = operatorConfig.getDispatcherConfig();

    double replanningInterval = Double.parseDouble(dispatcherConfig.getParams().getOrDefault("replanningInterval", "10.0"));
    double threshold = Double.parseDouble(dispatcherConfig.getParams().getOrDefault("maximumTimeRadius", "600.0"));
    long numberOfSeats = operatorConfig.getGeneratorConfig().getCapacity();

    FactorTravelTimeEstimator estimator = new FactorTravelTimeEstimator(threshold);

    return new MultiODHeuristic(operatorConfig.getMode(), eventsManager, network,
            new ParallelAggregateRideAppender(operatorConfig.getTimingConfig(), parallelRouter, travelTime, estimator), estimator, replanningInterval, numberOfSeats);
}
 
Example #9
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 #10
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 #11
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 #12
Source File: AmodeusRoutingModule.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
public AmodeusRoutingModule(AmodeusRouteFactory routeFactory, AmodeusInteractionFinder interactionFinder, WaitingTime waitingTime, PopulationFactory populationFactory,
        RoutingModule walkRoutingModule, boolean useAccessEgress, boolean predictRoute, LeastCostPathCalculator router, PriceModel priceCalculator, Network network,
        TravelTime travelTime, String mode) {
    this.routeFactory = routeFactory;
    this.interactionFinder = interactionFinder;
    this.waitingTime = waitingTime;
    this.walkRoutingModule = walkRoutingModule;
    this.populationFactory = populationFactory;
    this.useAccessEgress = useAccessEgress;
    this.predictRoute = predictRoute;
    this.router = router;
    this.priceCalculator = priceCalculator;
    this.mode = mode;
    this.network = network;
    this.travelTime = travelTime;
}
 
Example #13
Source File: HighCapacityDispatcher.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
public HighCapacityDispatcher(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); // if want to change value, change in av file, here only for backup
    rebalancePeriod = dispatcherConfig.getRebalancingPeriod(60); // same as above
    capacityOfTaxi = operatorConfig.getGeneratorConfig().getCapacity();

    links = new ArrayList<>(network.getLinks().values());
    Collections.shuffle(links, randGen);

    FastAStarLandmarksFactory factory = new FastAStarLandmarksFactory(Runtime.getRuntime().availableProcessors());
    LeastCostPathCalculator lcpc = EasyMinTimePathCalculator.prepPathCalculator(network, factory);
    ttc = new TravelTimeComputation(lcpc, sizeLimitOfCache);
    rtvGG = new AdvancedRTVGenerator(capacityOfTaxi, pickupDurationPerStop, dropoffDurationPerStop);
    rvGenerator = new AdvanceTVRVGenerator(pickupDurationPerStop, dropoffDurationPerStop);
    checkingUpdateMenuOrNot = new CheckingUpdateMenuOrNot();
}
 
Example #14
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 #15
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 #16
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 #17
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 #18
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 #19
Source File: DynamicRideSharingStrategy.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
protected DynamicRideSharingStrategy(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(300);

    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    double maxWaitTime = safeConfig.getInteger(MAXWAITTIMEID, 300); // normal is 300
    double maxDriveTimeIncrease = safeConfig.getDouble(MAXDRIVETIMEINCREASEID, 1.2); // normal is 1.2
    double maxRemainingTimeIncrease = safeConfig.getDouble(MAXREMAININGTIMEINCREASEID, 1.4); // normal is 1.4
    double newTravelTimeIncreaseAllowed = safeConfig.getInteger(MAXABSOLUTETRAVELTIMEINCREASEID, 180); // normal is 180 (=3min);

    roboTaxiHandler = new RoboTaxiHandler(network);

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

    rebalancing = new BlockRebalancing(network, timeDb, MINNUMBERROBOTAXISINBLOCKTOREBALANCE, BINSIZETRAVELDEMAND, dispatchPeriod, REBALANCINGGRIDDISTANCE);

    routeValidation = new RouteValidation(maxWaitTime, maxDriveTimeIncrease, maxRemainingTimeIncrease, //
            dropoffDurationPerStop, pickupDurationPerStop, newTravelTimeIncreaseAllowed);
}
 
Example #20
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 #21
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 #22
Source File: RestrictedLinkCapacityDispatcher.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);
    EventsManager eventsManager = inject.get(EventsManager.class);
    MatsimAmodeusDatabase db = inject.get(MatsimAmodeusDatabase.class);

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

    // TODO: Eventually, if parking should be configurable per mode, this should be made modal.
    ParkingStrategy parkingStrategy = inject.get(ParkingStrategy.class);
    ParkingCapacity avSpatialCapacityAmodeus = inject.get(ParkingCapacity.class);

    return new RestrictedLinkCapacityDispatcher(network, config, operatorConfig, travelTime, router, eventsManager, db, Objects.requireNonNull(parkingStrategy),
            Objects.requireNonNull(avSpatialCapacityAmodeus));
}
 
Example #23
Source File: DemoDispatcher.java    From amod with GNU General Public License v2.0 5 votes vote down vote up
private DemoDispatcher(Config config, AmodeusModeConfig operatorConfig, TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, Network network, MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    links = new ArrayList<>(network.getLinks().values());
    SafeConfig safeConfig = SafeConfig.wrap(operatorConfig.getDispatcherConfig());
    rebalancingPeriod = safeConfig.getInteger("rebalancingPeriod", 120);
}
 
Example #24
Source File: DefaultAStarLMRouter.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AmodeusRouter createRouter(InstanceGetter inject) {
    TravelTime travelTime = inject.getModal(TravelTime.class);
    GlobalConfigGroup config = inject.get(GlobalConfigGroup.class);
    Network network = inject.getModal(Network.class);

    return new DefaultAStarLMRouter(DefaultParallelLeastCostPathCalculator.//
            create(config.getNumberOfThreads(), new FastAStarLandmarksFactory(config), network, //
                    new OnlyTimeDependentTravelDisutilityFixed(travelTime), travelTime));
}
 
Example #25
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);
}
 
Example #26
Source File: TaxiTravelTimeRouter.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
@Override
public AmodeusRouter createRouter(InstanceGetter inject) {
    GlobalConfigGroup config = inject.get(GlobalConfigGroup.class);
    Network network = inject.getModal(Network.class);

    TravelTime travelTime = new LSDataTravelTime(lsData);

    return new TaxiTravelTimeRouter(DefaultParallelLeastCostPathCalculator.create(config.getNumberOfThreads(), //
            new DijkstraFactory(), network, new OnlyTimeDependentTravelDisutility(travelTime), travelTime));
}
 
Example #27
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 #28
Source File: FuturePathContainer.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
private static VrpPathWithTravelData getRouteBlocking(Link startLink, Link destLink, double startTime, Future<Path> leastCostPathFuture, TravelTime travelTime) {
    try {
        VrpPathWithTravelData vrpPathWithTravelData = VrpPaths.createPath(startLink, destLink, startTime, leastCostPathFuture.get(), travelTime);
        GlobalAssert.that(VrpPathUtils.isConsistent(vrpPathWithTravelData));
        return vrpPathWithTravelData;
    } catch (InterruptedException | ExecutionException e) {
        throw new RuntimeException(e);
    }
}
 
Example #29
Source File: FuturePathContainer.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
FuturePathContainer(Link startLink, Link destLink, double startTime, Future<Path> leastCostPathFuture, TravelTime travelTime) {
    this.startLink = startLink;
    this.destLink = destLink;
    this.startTime = startTime;
    this.leastCostPathFuture = leastCostPathFuture;
    this.travelTime = travelTime;
}
 
Example #30
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);
}