org.matsim.api.core.v01.network.Network Java Examples
The following examples show how to use
org.matsim.api.core.v01.network.Network.
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: ScheduleTools.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #2
Source File: BasicScheduleEditorTest.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #3
Source File: ConfigurableBipartiteMatcher.java From amodeus with GNU General Public License v2.0 | 6 votes |
/** 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 #4
Source File: PlausibilityCheck.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #5
Source File: PTMapperTools.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #6
Source File: FirstComeFirstServedStrategy.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: ExtDemandSupplyBeamSharing.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: DynamicRideSharingStrategy.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: DFRStrategy.java From amodeus with GNU General Public License v2.0 | 6 votes |
@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: MappingAnalysisExample.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
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 #11
Source File: ScheduleRoutersStandard.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #12
Source File: ModelFreeAdaptiveRepositioning.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #13
Source File: CoordTools.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #14
Source File: AdaptiveRealTimeRebalancingPolicy.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #15
Source File: ZVVexample.java From pt2matsim with GNU General Public License v2.0 | 6 votes |
/** * 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 #16
Source File: MatsimRectangleVirtualNetworkCreator.java From amodeus with GNU General Public License v2.0 | 6 votes |
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 #17
Source File: ScenarioExecutionTest.java From amodeus with GNU General Public License v2.0 | 5 votes |
@Test public void testA_Preparer() throws Exception { System.out.print("Preparer Test:\t"); // run scenario preparer TestPreparer testPreparer = TestPreparer.run(testServer.getWorkingDirectory()); // creation of files File preparedPopulationFile = new File("preparedPopulation.xml"); assertTrue(preparedPopulationFile.isFile()); File preparedNetworkFile = new File("preparedNetwork.xml"); assertTrue(preparedNetworkFile.isFile()); File config = new File("config.xml"); assertTrue(config.isFile()); // consistency of network (here no cutting) Network originalNetwork = NetworkLoader.fromConfigFile(testServer.getConfigFile()); Network preparedNetwork = testPreparer.getPreparedNetwork(); GlobalAssert.that(Objects.nonNull(originalNetwork)); GlobalAssert.that(Objects.nonNull(preparedNetwork)); assertEquals(preparedNetwork.getNodes().size(), originalNetwork.getNodes().size()); assertEquals(preparedNetwork.getLinks().size(), originalNetwork.getLinks().size()); // consistency of population Population population = testPreparer.getPreparedPopulation(); assertEquals(250, population.getPersons().size()); }
Example #18
Source File: NetworkTools.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
/** * Removes all nodes with no in- or outgoing links from a network */ public static void removeNotUsedNodes(Network network) { for(Node n : new HashSet<>(network.getNodes().values())) { if(n.getInLinks().size() == 0 && n.getOutLinks().size() == 0) { network.removeNode(n.getId()); } } }
Example #19
Source File: SocketPreparer.java From amod with GNU General Public License v2.0 | 5 votes |
/** loads scenario preparer in the {@link File} workingDirectory * * @param workingDirectory * @throws MalformedURLException * @throws Exception */ public SocketPreparer(File workingDirectory) throws MalformedURLException, Exception { Static.setup(); /** amodeus options */ scenOpt = new ScenarioOptions(workingDirectory, ScenarioOptionsBase.getDefault()); /** MATSim config */ // configMatsim = ConfigUtils.loadConfig(scenOpt.getPreparerConfigName()); AmodeusConfigGroup avConfigGroup = new AmodeusConfigGroup(); config = ConfigUtils.loadConfig(scenOpt.getPreparerConfigName(), avConfigGroup); Scenario scenario = ScenarioUtils.loadScenario(config); GeneratorConfig genConfig = avConfigGroup.getModes().values().iterator().next().getGeneratorConfig(); numRt = genConfig.getNumberOfVehicles(); System.out.println("socketPrep NumberOfVehicles=" + numRt); /** adaption of MATSim network, e.g., radius cutting */ Network network = scenario.getNetwork(); this.network = NetworkPreparer.run(network, scenOpt); /** adaption of MATSim population, e.g., radius cutting */ population = scenario.getPopulation(); LocationSpec locationSpec = scenOpt.getLocationSpec(); ReferenceFrame referenceFrame = locationSpec.referenceFrame(); this.db = MatsimAmodeusDatabase.initialize(network, referenceFrame); }
Example #20
Source File: NetworkTools.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
/** * Resets the link length of all links with the given link Mode */ public static void resetLinkLength(Network network, String networkMode) { for(Link link : network.getLinks().values()) { if(link.getAllowedModes().contains(networkMode)) { double l = CoordUtils.calcEuclideanDistance(link.getFromNode().getCoord(), link.getToNode().getCoord()); link.setLength(l > 0 ? l : 1); } } }
Example #21
Source File: AbstractNoExplicitCommunication.java From amodeus with GNU General Public License v2.0 | 5 votes |
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 #22
Source File: VirtualNetworkModeModule.java From amodeus with GNU General Public License v2.0 | 5 votes |
static private VirtualNetwork<Link> provideVirtualNetworkFromScenarioOptions(InstanceGetter getter) { try { AmodeusModeConfig modeConfig = getter.getModal(AmodeusModeConfig.class); ScenarioOptions scenarioOptions = getter.get(ScenarioOptions.class); logger.info(String.format("Loading VirtualNetwork for mode '%s' from ScenarioOptions:", modeConfig.getMode())); logger.info(String.format(" - creator: ", scenarioOptions.getVirtualNetworkCreator().getClass().getSimpleName())); logger.info(String.format(" - name: ", scenarioOptions.getVirtualNetworkName())); Network network = getter.getModal(Network.class); return VirtualNetworkGet.readDefault(network, scenarioOptions); } catch (IOException e) { throw new RuntimeException(e); } }
Example #23
Source File: ExtractDebugSchedule.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
public static void writeRouteAndShapeToShapefile(TransitSchedule schedule, Network network, Map<Id<RouteShape>, RouteShape> shapes, String outputFolder, String debugLineId, String debugRouteId, String coordSys) { ExtractDebugSchedule.run(schedule, debugLineId, debugRouteId); ScheduleCleaner.removeNotUsedStopFacilities(schedule); Schedule2ShapeFile s2s = new Schedule2ShapeFile(coordSys, schedule, network); s2s.routes2Polylines(outputFolder + "transitRoutes.shp", true); s2s.routes2Polylines(outputFolder + "transitRoutesBeeline.shp", false); s2s.stopFacilities2Points(outputFolder + "stopFacilities.shp"); Id<RouteShape> shapeId = ScheduleTools.getShapeId(schedule.getTransitLines().get(Id.create(debugLineId, TransitLine.class)).getRoutes().get(Id.create(debugRouteId, TransitRoute.class))); ShapeTools.writeESRIShapeFile(Collections.singleton(shapes.get(shapeId)), coordSys, outputFolder+"shape.shp"); }
Example #24
Source File: BasicScheduleEditor.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
public BasicScheduleEditor(TransitSchedule schedule, Network network) { this.schedule = schedule; this.network = network; this.scheduleFactory = schedule.getFactory(); this.networkFactory = network.getFactory(); this.parentStops = new ParentStops(); log.info("Guessing routers based on schedule transport modes and used network transport modes."); this.routers = NetworkTools.guessRouters(schedule, network).createInstance(); }
Example #25
Source File: DefaultParallelLeastCostPathCalculator.java From amodeus with GNU General Public License v2.0 | 5 votes |
static public DefaultParallelLeastCostPathCalculator create(int numberOfInstances, LeastCostPathCalculatorFactory factory, Network network, TravelDisutility travelDisutility, TravelTime travelTime) { List<LeastCostPathCalculator> instances = new LinkedList<>(); for (int i = 0; i < numberOfInstances; i++) { instances.add(factory.createPathCalculator(network, travelDisutility, travelTime)); } return new DefaultParallelLeastCostPathCalculator(instances); }
Example #26
Source File: ScheduleTools.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
/** * Adds mode the schedule transport mode to links. Removes all network * modes elsewhere. Adds mode "artificial" to artificial * links. Used for debugging and visualization. */ public static void assignScheduleModesToLinks(TransitSchedule schedule, Network network) { log.info("... Assigning schedule transport mode to network"); Map<Id<Link>, Set<String>> transitLinkNetworkModes = new HashMap<>(); for(TransitLine line : schedule.getTransitLines().values()) { for(TransitRoute route : line.getRoutes().values()) { if(route.getRoute() != null) { for(Id<Link> linkId : getTransitRouteLinkIds(route)) { MapUtils.getSet(linkId, transitLinkNetworkModes).add(route.getTransportMode()); } } } } for(Link link : network.getLinks().values()) { if(transitLinkNetworkModes.containsKey(link.getId())) { Set<String> linkModes = transitLinkNetworkModes.get(link.getId()); linkModes.addAll(link.getAllowedModes()); Set<String> modes = new HashSet<>(linkModes); link.setAllowedModes(modes); } } }
Example #27
Source File: BasicScheduleEditor.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
public BasicScheduleEditor(TransitSchedule schedule, Network network, ScheduleRouters routers) { this.schedule = schedule; this.network = network; this.scheduleFactory = schedule.getFactory(); this.networkFactory = network.getFactory(); this.routers = routers; this.parentStops = new ParentStops(); }
Example #28
Source File: ScheduleRoutersOsmAttributes.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
public Factory(TransitSchedule schedule, Network network, Map<String, Set<String>> transportModeAssignment, PublicTransitMappingConfigGroup.TravelCostType travelCostType, double osmPtLinkTravelCostFactor) { this.schedule = schedule; this.network = network; this.transportModeAssignment = transportModeAssignment; this.travelCostType = travelCostType; this.osmPtLinkTravelCostFactor = osmPtLinkTravelCostFactor; }
Example #29
Source File: ScheduleRoutersStandard.java From pt2matsim with GNU General Public License v2.0 | 5 votes |
@Override public LeastCostPathCalculator.Path calcLeastCostPath(Id<Node> fromNodeId, Id<Node> toNodeId, TransitLine transitLine, TransitRoute transitRoute) { Network n = networksByMode.get(transitRoute.getTransportMode()); if(n == null) return null; Node fromNode = n.getNodes().get(fromNodeId); Node toNode = n.getNodes().get(toNodeId); if(fromNode == null || toNode == null) return null; return pathCalculatorsByMode.get(transitRoute.getTransportMode()).calcPath(fromNode, toNode); }
Example #30
Source File: LinkGroupDefinition.java From amodeus with GNU General Public License v2.0 | 5 votes |
static public LinkGroupDefinition create(Network network, String attribute) { Map<Id<Link>, Integer> indices = new HashMap<>(); int maximumIndex = 0; for (Link link : network.getLinks().values()) { Integer groupIndex = (Integer) link.getAttributes().getAttribute(attribute); if (groupIndex != null) { indices.put(link.getId(), groupIndex); maximumIndex = Math.max(maximumIndex, groupIndex); } } return new LinkGroupDefinition(maximumIndex, indices); }