Java Code Examples for org.matsim.core.network.NetworkUtils#getBoundingBox()

The following examples show how to use org.matsim.core.network.NetworkUtils#getBoundingBox() . 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: MatsimRingCentroidVirtualNetworkCreator.java    From amodeus with GNU General Public License v2.0 6 votes vote down vote up
private static List<Link> getRingCentroids(Network network, int numVNodes) {
    List<Link> centroids = new ArrayList<>();
    double[] bounds = NetworkUtils.getBoundingBox(network.getNodes().values()); // minX, minY, maxX, maxY
    QuadTree<Link> quadTree = FastQuadTree.of(network);

    // center location
    double centerX = bounds[0] + 0.5 * (bounds[2] - bounds[0]);
    double centerY = bounds[1] + 0.5 * (bounds[3] - bounds[1]);

    double radius = 0.5 * Math.min(bounds[2] - bounds[0], bounds[3] - bounds[1]);
    centroids.add(quadTree.getClosest(centerX, centerY));

    for (int count = 1; count < numVNodes; ++count) {
        double arg = count / (numVNodes - 1.0) * 2 * Math.PI;
        double posX = centerX + radius * Math.cos(arg);
        double posY = centerY + radius * Math.sin(arg);
        Link closest = quadTree.getClosest(posX, posY);
        centroids.add(closest);
    }
    GlobalAssert.that(centroids.size() == numVNodes);
    return centroids;
}
 
Example 2
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 3
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 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: DemandSupplyBalancingDispatcher.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
protected DemandSupplyBalancingDispatcher(Config config, AmodeusModeConfig operatorConfig, //
        TravelTime travelTime, AmodeusRouter router, EventsManager eventsManager, Network network, //
        MatsimAmodeusDatabase db) {
    super(config, operatorConfig, travelTime, router, eventsManager, db);
    DispatcherConfigWrapper dispatcherConfig = DispatcherConfigWrapper.wrap(operatorConfig.getDispatcherConfig());
    dispatchPeriod = dispatcherConfig.getDispatchPeriod(10);
    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    this.requestMaintainer = new TreeMaintainer<>(networkBounds, this::getLocation);
    this.unassignedRoboTaxis = new TreeMaintainer<>(networkBounds, this::getRoboTaxiLoc);
}
 
Example 6
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 7
Source File: InteractionLinkData.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public InteractionLinkData(Collection<Link> links) {
    Set<Node> nodes = new HashSet<>();
    nodes.addAll(links.stream().map(Link::getFromNode).collect(Collectors.toSet()));
    nodes.addAll(links.stream().map(Link::getToNode).collect(Collectors.toSet()));

    double[] bounds = NetworkUtils.getBoundingBox(nodes);
    this.index = new QuadTree<>(bounds[0], bounds[1], bounds[2], bounds[3]);

    links.stream().forEach(l -> index.put(l.getCoord().getX(), l.getCoord().getY(), l));
}
 
Example 8
Source File: MultiODHeuristic.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public MultiODHeuristic(String mode, EventsManager eventsManager, Network network, AggregateRideAppender appender, FactorTravelTimeEstimator estimator,
        double replanningInterval, long numberOfSeats) {
    this.mode = mode;
    this.eventsManager = eventsManager;
    this.appender = appender;
    this.estimator = estimator;
    this.replanningInterval = replanningInterval;
    this.numberOfSeats = numberOfSeats;

    double[] bounds = NetworkUtils.getBoundingBox(network.getNodes().values()); // minx, miny, maxx, maxy

    availableVehiclesTree = new QuadTree<>(bounds[0], bounds[1], bounds[2], bounds[3]);
    pendingRequestsTree = new QuadTree<>(bounds[0], bounds[1], bounds[2], bounds[3]);
}
 
Example 9
Source File: SingleHeuristicDispatcher.java    From amodeus with GNU General Public License v2.0 5 votes vote down vote up
public SingleHeuristicDispatcher(String mode, EventsManager eventsManager, Network network, SingleRideAppender appender, double replanningInterval) {
    this.appender = appender;
    this.mode = mode;
    this.eventsManager = eventsManager;
    this.replanningInterval = replanningInterval;

    double[] bounds = NetworkUtils.getBoundingBox(network.getNodes().values()); // minx, miny, maxx, maxy

    availableVehiclesTree = new QuadTree<>(bounds[0], bounds[1], bounds[2], bounds[3]);
    pendingRequestsTree = new QuadTree<>(bounds[0], bounds[1], bounds[2], bounds[3]);
}
 
Example 10
Source File: SocketPreparer.java    From amod with GNU General Public License v2.0 5 votes vote down vote up
public Tensor getBoundingBox() {
    /** send initial data (bounding box), {{minX, minY}, {maxX, maxY}} */
    double[] bbox = NetworkUtils.getBoundingBox(network.getNodes().values());

    return Tensors.of(TensorCoords.toTensor( //
            scenOpt.getLocationSpec().referenceFrame().coords_toWGS84().transform(new Coord(bbox[0], bbox[1]))), //
            TensorCoords.toTensor( //
                    scenOpt.getLocationSpec().referenceFrame().coords_toWGS84().transform(new Coord(bbox[2], bbox[3]))));
}
 
Example 11
Source File: RoboTaxiHandler.java    From amodeus with GNU General Public License v2.0 4 votes vote down vote up
public RoboTaxiHandler(Network network) {
    maxSpeed = maxSpeed(network);
    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    this.allRoboTaxis = new TreeMaintainer<>(networkBounds, this::getRoboTaxiLoc);
}
 
Example 12
Source File: VoronoiPartition.java    From amodeus with GNU General Public License v2.0 4 votes vote down vote up
public VoronoiPartition(Network network, Function<T, Coord> location) {
    this.network = network;
    this.location = location;
    double[] networkBounds = NetworkUtils.getBoundingBox(network.getNodes().values());
    tree = new QuadTree<>(networkBounds[0], networkBounds[1], networkBounds[2], networkBounds[3]);
}