Java Code Examples for org.matsim.api.core.v01.network.Network

The following examples show how to use org.matsim.api.core.v01.network.Network. 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
public static VirtualNetwork<Link> createVirtualNetwork( //
        Population population, Network network, boolean completeGraph, //
        int divLat, int divLng) {
    /** bounds */
    Tensor bounds = NetworkBounds.of(network);
    Tensor lbounds = bounds.get(0);
    Tensor ubounds = bounds.get(1);
    Tensor xBounds = Tensors.of(lbounds.Get(0), ubounds.Get(0));
    Tensor yBounds = Tensors.of(lbounds.Get(1), ubounds.Get(1));
    System.out.println("Network bounds:  " + xBounds + " , " + yBounds);

    /** u elements to determine neighbors */
    Map<Node, Set<Link>> uElements = NodeAdjacencyMap.of(network);

    @SuppressWarnings("unchecked")
    Collection<Link> elements = (Collection<Link>) network.getLinks().values();
    RectangleGridVirtualNetworkCreator<Link, Node> creator = //
            new RectangleGridVirtualNetworkCreator<>( //
                    elements, TensorLocation::of, NetworkCreatorUtils::linkToID, //
                    divLat, divLng, xBounds, yBounds, //
                    uElements, completeGraph);
    return creator.getVirtualNetwork();
}
 
Example 2
Source Project: pt2matsim   Source File: ScheduleTools.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add mode "pt" to any link of the network that is
 * passed by any transitRoute of the schedule.
 */
public static void addPTModeToNetwork(TransitSchedule schedule, Network network) {
	log.info("... Adding mode \"pt\" to all links with public transit");

	Map<Id<Link>, ? extends Link> networkLinks = network.getLinks();
	Set<Id<Link>> transitLinkIds = new HashSet<>();

	for(TransitLine line : schedule.getTransitLines().values()) {
		for(TransitRoute transitRoute : line.getRoutes().values()) {
			if(transitRoute.getRoute() != null) {
				transitLinkIds.addAll(getTransitRouteLinkIds(transitRoute));
			}
		}
	}

	for(Id<Link> transitLinkId : transitLinkIds) {
		Link transitLink = networkLinks.get(transitLinkId);
		if(!transitLink.getAllowedModes().contains(TransportMode.pt)) {
			Set<String> modes = new HashSet<>(transitLink.getAllowedModes());
			modes.add(TransportMode.pt);
			transitLink.setAllowedModes(modes);
		}
	}
}
 
Example 3
public static void main(String[] args) {
	String mapperOutput = "example/output/";
	String coordinateSystem = "EPSG:2032";

	// new GtfsFeedImpl("input/addisoncounty-vt-us-gtfs.zip"); // unzips the feed, should have happened in PT2MATSimExample
	Map<Id<RouteShape>, RouteShape> shapes = ShapeTools.readShapesFile("example/input/addisoncounty-vt-us-gtfs/shapes.txt", coordinateSystem);

	// analyse
	TransitSchedule schedule = ScheduleTools.readTransitSchedule(mapperOutput + "addison_schedule.xml");
	Network network = NetworkTools.readNetwork(mapperOutput + "addison_multimodalnetwork.xml.gz");

	new File(mapperOutput + "analysis/").mkdirs();
	MappingAnalysis analysis = new MappingAnalysis(schedule, network, shapes);
	analysis.run();
	analysis.writeAllDistancesCsv(mapperOutput + "analysis/DistancesAll.csv");
	analysis.writeQuantileDistancesCsv(mapperOutput + "analysis/DistancesQuantile.csv");
}
 
Example 4
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 5
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 6
/**
 * Possible Commands:
 * - Reroute TransitRoute via new Link
 * ["rerouteViaLink"] [TransitLineId] [TransitRouteId] [oldLinkId] [newLinkId]
 */
@Test
public void rerouteViaLink() {
	TransitSchedule schedule = initSchedule();
	Network network = NetworkToolsTest.initNetwork();

	String[] cmd = new String[]{ScheduleEditor.RR_VIA_LINK, LINE_B.toString(), ROUTE_B.toString(), "CX", "CB"};

	new BasicScheduleEditor(schedule, network).executeCmdLine(cmd);

	List<Id<Link>> linkIds = ScheduleTools.getTransitRouteLinkIds(schedule.getTransitLines().get(LINE_B).getRoutes().get(ROUTE_B));

	List<Id<Link>> linkIdsExpected = new ArrayList<>();
	linkIdsExpected.add(Id.createLinkId("EW"));
	linkIdsExpected.add(Id.createLinkId("WD"));
	linkIdsExpected.add(Id.createLinkId("DC"));
	linkIdsExpected.add(Id.createLinkId("CB"));
	linkIdsExpected.add(Id.createLinkId("BX"));
	linkIdsExpected.add(Id.createLinkId("XA"));
	linkIdsExpected.add(Id.createLinkId("AH"));
	linkIdsExpected.add(Id.createLinkId("HZ"));
	linkIdsExpected.add(Id.createLinkId("ZI"));
	linkIdsExpected.add(Id.createLinkId("IB"));

	Assert.assertEquals(linkIdsExpected, linkIds);
}
 
Example 7
Source Project: pt2matsim   Source File: PlausibilityCheck.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor
 */
public PlausibilityCheck(TransitSchedule schedule, Network network, String coordinateSystem) {
	this.schedule = schedule;
	this.network = network;
	this.coordinateSystem = coordinateSystem;

	this.thresholds = new HashMap<>();
	this.thresholds.put("bus", 0.6667 * PI);
	this.thresholds.put("rail", 0.3333 * PI);
	this.ttRange = 65;

	this.warnings.put(PlausibilityWarning.Type.ArtificialLinkWarning, new HashSet<>());
	this.warnings.put(PlausibilityWarning.Type.DirectionChangeWarning, new HashSet<>());
	this.warnings.put(PlausibilityWarning.Type.LoopWarning, new HashSet<>());
	this.warnings.put(PlausibilityWarning.Type.TravelTimeWarning, new HashSet<>());
}
 
Example 8
Source Project: pt2matsim   Source File: PTMapperTools.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a node and dummy/loop link on the coordinate of the stop facility and
 * adds both to the network. The stop facility is NOT referenced.
 *
 * @return the new link or the existing link if it's already present in the network
 */
public static Link createArtificialStopFacilityLink(TransitStopFacility stopFacility, Network network, String prefix, double freespeed, Set<String> transportModes) {
	Id<Link> dummyLinkId = createArtificialLinkId(stopFacility);

	Link dummyLink = network.getLinks().get(dummyLinkId);
	if(dummyLink != null) {
		return dummyLink;
	} else {
		Node dummyNode = NetworkUtils.createNode(Id.createNodeId(prefix + stopFacility.getId()), stopFacility.getCoord());
		network.addNode(dummyNode);
		dummyLink = NetworkUtils.createLink(dummyLinkId, dummyNode, dummyNode, network, 10, freespeed, 9999, 1);
		dummyLink.setAllowedModes(transportModes);
		network.addLink(dummyLink);

		return dummyLink;
	}
}
 
Example 9
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 10
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 11
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 12
/** Allows to instantiate a configurable bipartite matching algorithm via the av.xml file, there are two options:
 * - 1 (default option): the Hungarian method is used, this is chosen if no specification is given in av.xml or the specification
 * 
 * <dispatcher strategy="GlobalBipartiteMatchingDispatcher">
 * <param name="matchingAlgorithm" value="HUNGARIAN" />
 * 
 * -2: solution of the assignment problem via Integer Linear Program, for this option the av.xml file should look as follows
 * <dispatcher strategy="GlobalBipartiteMatchingDispatcher">
 * <param name="matchingAlgorithm" value="ILP" />
 * <param name="matchingWeight" value="[1.0,1.0,1.0]" />
 * 
 * The values are retrieved via @param safeConfig, other parameters necessary for instantiation are
 * the network @param network, and the distance function @param distanceFunction */
public ConfigurableBipartiteMatcher(Network network, GlobalBipartiteCost cost, SafeConfig safeConfig) {
    super(network);
    String matchingAlg = safeConfig.getString("matchingAlgorithm", "HUNGARIAN");
    switch (matchingAlg) {
    case "HUNGARIAN":
        hungarian = true;
        globalBipartiteMatcher = new GlobalBipartiteMatching(cost);
        break;
    case "ILP":
        hungarian = false;
        globalBipartiteMatcher = new GlobalBipartiteMatchingILP(cost, safeConfig);
        break;
    default:
        // hungarian = null;
        // globalBipartiteMatcher = null;
        throw new RuntimeException("An invalid option for the matching algorithm was chosen. " + matchingAlg);
    }
}
 
Example 13
Source Project: amodeus   Source File: DFRStrategy.java    License: 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 14
/**
 * Load path calculators for all transit routes
 */
private void load() {
	log.info("==============================================");
	log.info("Creating network routers for transit routes...");
	log.info("Initiating network and router for transit routes...");
	LeastCostPathCalculatorFactory factory = new FastAStarLandmarksFactory();
	for(TransitLine transitLine : schedule.getTransitLines().values()) {
		for(TransitRoute transitRoute : transitLine.getRoutes().values()) {
			String scheduleMode = transitRoute.getTransportMode();
			PathCalculator tmpRouter = pathCalculatorsByMode.get(scheduleMode);
			if(tmpRouter == null) {
				log.info("New router for schedule mode " + scheduleMode);
				Set<String> networkTransportModes = transportModeAssignment.get(scheduleMode);

				Network filteredNetwork = NetworkTools.createFilteredNetworkByLinkMode(this.network, networkTransportModes);

				LocalRouter r = new LocalRouter();

				tmpRouter = new PathCalculator(factory.createPathCalculator(filteredNetwork, r, r));

				pathCalculatorsByMode.put(scheduleMode, tmpRouter);
				networksByMode.put(scheduleMode, filteredNetwork);
			}
		}
	}
}
 
Example 15
Source Project: pt2matsim   Source File: CoordTools.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Calculates the extent of the given network.
 * @return Array of Coords with the minimal South-West and the
 * 		   maximal North-East Coordinates
 */
public static Coord[] getExtent(Network network) {
	double maxE = 0;
	double maxN = 0;
	double minS = Double.MAX_VALUE;
	double minW = Double.MAX_VALUE;

	for(Node node : network.getNodes().values()) {
		if(node.getCoord().getX() > maxE) {
			maxE = node.getCoord().getX();
		}
		if(node.getCoord().getY() > maxN) {
			maxN = node.getCoord().getY();
		}
		if(node.getCoord().getX() < minW) {
			minW = node.getCoord().getX();
		}
		if(node.getCoord().getY() < minS) {
			minS = node.getCoord().getY();
		}
	}

	return new Coord[]{new Coord(minW, minS), new Coord(maxE, maxN)};
}
 
Example 16
Source Project: pt2matsim   Source File: ZVVexample.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Maps a schedule using osm pt information of the network
 */
public static void runMappingOsm() {
	TransitSchedule schedule = ScheduleTools.readTransitSchedule(inputScheduleFile);
	Network network = NetworkTools.readNetwork(inputNetworkFile);

	PublicTransitMappingConfigGroup config = PublicTransitMappingConfigGroup.createDefaultConfig();

	// Initiate Router that uses osm data
	ScheduleRoutersFactory routerFactory = new ScheduleRoutersOsmAttributes.Factory(schedule, network, config.getTransportModeAssignment(), PublicTransitMappingConfigGroup.TravelCostType.linkLength, 0.5);

	PTMapper ptMapper = new PTMapper(schedule, network);
	ptMapper.run(config, null, routerFactory);

	NetworkTools.writeNetwork(network, outputNetwork3);
	ScheduleTools.writeTransitSchedule(schedule, outputSchedule3);

	runAnalysis(outputSchedule3, outputNetwork3);
}
 
Example 17
Source Project: pt2matsim   Source File: PseudoRoutingImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds the artificial links to the network.
 *
 * Not thread safe.
 */
@Override
public void addArtificialLinks(Network network) {
	for(ArtificialLink a : necessaryArtificialLinks) {
		if(!network.getLinks().containsKey(a.getId())) {
			network.addLink(a);
		}
	}
}
 
Example 18
@Override
public AmodeusGenerator createGenerator(InstanceGetter inject) {
    AmodeusModeConfig operatorConfig = inject.getModal(AmodeusModeConfig.class);
    Network network = inject.getModal(Network.class);
    int capacity = operatorConfig.getGeneratorConfig().getCapacity();

    return new RandomDensityGenerator(operatorConfig, network, capacity);
}
 
Example 19
/** Assigns to every link in the @param network a capacity equal to:
 * min(@param minCapacityGlobal, link lenghth x @param capacityPerLengthUnit ) */
public ParkingCapacityLinkLength(Network network, double capacityPerLengthUnit, long minCapacityGlobal) {
    for (Link link : network.getLinks().values()) {
        long capacity = (long) Math.max(Math.floor(link.getLength() * capacityPerLengthUnit), minCapacityGlobal);
        capacities.put(link.getId(), capacity);
    }
}
 
Example 20
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 21
Source Project: amodeus   Source File: LinkWaitingTimeData.java    License: GNU General Public License v2.0 5 votes vote down vote up
static public LinkWaitingTimeData create(Network network, String linkAttribute) {
    Map<Id<Link>, Double> waitingTimes = new HashMap<>();

    for (Link link : network.getLinks().values()) {
        Double waitingTime = (Double) link.getAttributes().getAttribute(linkAttribute);

        if (waitingTime != null) {
            waitingTimes.put(link.getId(), waitingTime);
        }
    }

    return new LinkWaitingTimeData(waitingTimes);
}
 
Example 22
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 23
Source Project: amodeus   Source File: Block.java    License: GNU General Public License v2.0 5 votes vote down vote up
/** generates a new {@link Block}.
 * 
 * @param bounds defines the bounds of the Block
 * @param network is used to find the center LInk
 * @param id is the identifier for this Block
 * @param historicalDataTime Time over how long requests are stored. Is used for balance calculation
 * @param predictedTime what is the time for which the future requests are predicted. Normally this value should be in the order of the dispatch period */
Block(Rect bounds, Network network, int id, double historicalDataTime, double predictedTime) {
    this.bounds = bounds;
    this.id = id;
    Coord centerCoord = new Coord(bounds.centerX, bounds.centerY);
    centerLink = NetworkUtils.getNearestLink(network, centerCoord);
    this.predictionFraction = predictedTime / historicalDataTime;
}
 
Example 24
@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 DynamicRideSharingStrategy(network, config, operatorConfig, travelTime, router, eventsManager, db);
}
 
Example 25
public LinkCandidateCreatorStandard(TransitSchedule schedule, Network network, int nLinks, double distanceMultiplier, double maxDistance, Map<String, Set<String>> transportModeAssignments) {
	this.schedule = schedule;
	this.network = network;
	this.nLinks = nLinks;
	this.distanceMultiplier = distanceMultiplier;
	this.maxDistance = maxDistance;
	this.transportModeAssignments = transportModeAssignments;

	load();
}
 
Example 26
private ScheduleRoutersStandard(TransitSchedule schedule, Network network, Map<String, Set<String>> transportModeAssignment, PublicTransitMappingConfigGroup.TravelCostType costType, boolean routingWithCandidateDistance) {
	this.schedule = schedule;
	this.network = network;
	this.transportModeAssignment = transportModeAssignment;
	this.travelCostType = costType;
	this.considerCandidateDist = routingWithCandidateDistance;

	load();
}
 
Example 27
Source Project: amod   Source File: DemoDispatcher.java    License: 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 28
Source Project: pt2matsim   Source File: Schedule2ShapeFile.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void run(String crs, String outputFolder, TransitSchedule schedule, Network network) {
	Schedule2ShapeFile s2s = new Schedule2ShapeFile(crs, schedule, network);

	s2s.routes2Polylines(outputFolder + "transitRoutes.shp", network != null);
	s2s.stopFacilities2Points(outputFolder + "stopFacilities.shp");
	s2s.stopRefLinks2Polylines(outputFolder + "refLinks.shp");
	s2s.convertNetwork(outputFolder);
}
 
Example 29
Source Project: amod   Source File: DemoDispatcherShared.java    License: 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 30
private SBNoExplicitCommunication(Network network, Config config, //
        AmodeusModeConfig operatorConfig, TravelTime travelTime, //
        AmodeusRouter router, EventsManager eventsManager, //
        MatsimAmodeusDatabase db) {
    super(network, config, operatorConfig, travelTime, router, eventsManager, db);
    voronoiPartition = new VoronoiPartition<>(network, this::getRTLocation);
}