private void loadNetwork() { Config config = ConfigUtils.createConfig(); config.network().setInputFile(networkFile); this.network = ScenarioUtils.loadScenario(config).getNetwork(); }
/** * Loads the network into the scenario of this class */ private void loadNetwork() { if ((this.config.network() != null) && (this.config.network().getInputFile() != null)) { URL networkUrl = this.config.network().getInputFileURL(this.config.getContext()); log.info("loading network from " + networkUrl); String inputCRS = config.network().getInputCRS(); MatsimNetworkReader reader = new MatsimNetworkReader( inputCRS, config.global().getCoordinateSystem(), this.scenario.getNetwork()); reader.putAttributeConverters( attributeConverters ); reader.parse(networkUrl); if ((this.config.network().getChangeEventsInputFile()!= null) && this.config.network().isTimeVariantNetwork()) { log.info("loading network change events from " + this.config.network().getChangeEventsInputFileUrl(this.config.getContext()).getFile()); Network network = this.scenario.getNetwork(); List<NetworkChangeEvent> changeEvents = new ArrayList<>() ; NetworkChangeEventsParser parser = new NetworkChangeEventsParser(network,changeEvents); parser.parse(this.config.network().getChangeEventsInputFileUrl(config.getContext())); NetworkUtils.setNetworkChangeEvents(network,changeEvents); } } }
public static void calculateMissingCapacitiesForLanes20(String networkInputFilename, String lanes20InputFilename, String lanes20OutputFilename){ Config config = ConfigUtils.createConfig(); config.network().setInputFile(networkInputFilename); config.qsim().setUseLanes(true); config.network().setLaneDefinitionsFile(lanes20InputFilename); Scenario scenario = ScenarioUtils.loadScenario(config); Network network = scenario.getNetwork(); Lanes lanes = scenario.getLanes(); for (LanesToLinkAssignment l2l : lanes.getLanesToLinkAssignments().values()){ Link link = network.getLinks().get(l2l.getLinkId()); for (Lane lane : l2l.getLanes().values()){ if (lane.getToLaneIds() == null || lane.getToLaneIds().isEmpty()){ calculateAndSetCapacity(lane, true, link, network); } else { calculateAndSetCapacity(lane, false, link, network); } } } LanesWriter writerDelegate = new LanesWriter(lanes); writerDelegate.write(lanes20OutputFilename); }
@Override public void checkConsistency(Config config) { new DvrpConfigConsistencyChecker().checkConsistency(config); if (config.network().isTimeVariantNetwork() && config.network().getChangeEventsInputFile() == null) { log.warn("No change events provided for the time variant network"); } if (!config.network().isTimeVariantNetwork() && config.network().getChangeEventsInputFile() != null) { log.warn("Change events ignored, because the network is not time variant"); } if (config.qsim().getFlowCapFactor() < 100) { log.warn("FlowCapFactor should be large enough (e.g. 100) to obtain deterministic (fixed) travel times"); } if (config.qsim().getStorageCapFactor() < 100) { log.warn("StorageCapFactor should be large enough (e.g. 100) to obtain deterministic (fixed) travel times"); } if (config.network().isTimeVariantNetwork() && DvrpConfigGroup.get(config).getNetworkMode() != null) { throw new RuntimeException("The current version of RunTaxiBenchmark does not support this case: " + "@Named(DvrpModule.DVRP_ROUTING) Network would consist of links having " + "VariableIntervalTimeVariantAttributes instead of FixedIntervalTimeVariantAttributes."); } } }
config.network().setInputFile(INPUT_DIR + "network.xml.gz"); config.plans().setInputFile(INPUT_DIR + "population.xml.gz"); config.network().setLaneDefinitionsFile(outputDir + "lane_definitions_v2.0.xml"); signalSystemsConfigGroup.setSignalSystemFile(outputDir + "signal_systems.xml"); signalSystemsConfigGroup.setSignalGroupsFile(outputDir + "signal_groups.xml"); writerDelegate.write(config.network().getLaneDefinitionsFile());
config.network().setInputCRS( INITIAL_CRS ); config.plans().setInputCRS( INITIAL_CRS ); config.global().setCoordinateSystem( TARGET_CRS ); config.network().setInputFile( NET_FILE ); config.plans().setInputFile( BASE_FILE );
config.network().setInputFile(getAbsolutePath(prefix, config.network().getInputFile())); config.plans().setInputFile(getAbsolutePath(prefix, config.plans().getInputFile())); config.facilities().setInputFile(getAbsolutePath(prefix, config.facilities().getInputFile()));
@Test public void testModifyPaths_withSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.newUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assert.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim/"); Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); }
new MatsimNetworkReader(scenario.getNetwork()).parse(config.network().getInputFileURL(config.getContext()));
private void loadLanes() { String filename = this.config.network().getLaneDefinitionsFile(); if (filename != null){ LanesReader reader = new LanesReader(this.scenario); reader.readURL( ConfigGroup.getInputFileURL(this.config.getContext(), filename ) ); } else { log.info("no lanes file set in config, not loading any lanes"); } }
config.network().setInputFile( networkFile ); config.network().setInputCRS( INITIAL_CRS );
@Test public void testModifyPaths_missingSeparator() throws IOException { Config config = ConfigUtils.loadConfig(IOUtils.newUrl(ExamplesUtils.getTestScenarioURL("equil"), "config.xml")); Assert.assertEquals("network.xml", config.network().getInputFile()); ConfigUtils.modifyFilePaths(config, "/home/username/matsim"); Assert.assertThat(config.network().getInputFile(), anyOf(is("/home/username/matsim/network.xml"),is("/home/username/matsim\\network.xml"))); }
@Test public void testCarDoesntTeleportFromHome() { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(config.network().getInputFileURL(config.getContext())); testCarDoesntTeleport(network, TransportMode.car, TransportMode.pt); testCarDoesntTeleport(network, TransportMode.pt, TransportMode.car); }
@Inject public LinkSensorManager(Scenario scenario, EventsManager events){ this.network = scenario.getNetwork(); if (scenario.getConfig().network().getLaneDefinitionsFile() != null || scenario.getConfig().qsim().isUseLanes()) { laneDefinitions = scenario.getLanes(); } events.addHandler(this); }
public static final void setUpScenarioConfig(final Config config) { config.network().setInputFile(studyfolder + "network.xml"); config.facilities().setInputFile(studyfolder + "facilities.xml"); }
String configFilename = testUtils.getClassInputDirectory() + "config.xml"; Config config = ConfigUtils.loadConfig(configFilename); config.network().setInputFile("network.xml"); config.network().setLaneDefinitionsFile("testLaneDefinitions_v2.0.xml"); config.plans().setInputFile("population.xml"); config.controler().setOutputDirectory(testUtils.getOutputDirectory() + "output");
new MatsimNetworkReader(scenario.getNetwork()).readFile(this.config.network().getInputFile()); prepare();
@Test public void testSubTourMutationNetworkBased() { Config config = utils.loadConfig(CONFIGFILE); Scenario scenario = ScenarioUtils.createScenario(config); Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).parse(config.network().getInputFileURL(config.getContext())); this.testSubTourMutationToCar(network); this.testSubTourMutationToPt(network); this.testUnknownModeDoesntMutate(network); }
@Override public Map<Id<Link>, List<TurnInfo>> createAllowedTurnInfos(){ Map<Id<Link>, List<TurnInfo>> allowedInLinkTurnInfoMap = new HashMap<>(); createAndAddTurnInfo(TransportMode.car, allowedInLinkTurnInfoMap); if ( scenario.getConfig().network().getLaneDefinitionsFile()!=null || // scenario.getConfig().qsim().isUseLanes()) { Lanes ld = scenario.getLanes(); Map<Id<Link>, List<TurnInfo>> lanesTurnInfoMap = createTurnInfos(ld); mergeTurnInfoMaps(allowedInLinkTurnInfoMap, lanesTurnInfoMap); } return allowedInLinkTurnInfoMap; }
public static void main(String[] args) { Config config; if (args.length == 1) { LOG.info("A user-specified config.xml file was provided. Using it..."); config = ConfigUtils.loadConfig(args[0], new BicycleConfigGroup()); fillConfigWithBicycleStandardValues(config); } else if (args.length == 0) { LOG.info("No config.xml file was provided. Using 'standard' example files given in this contrib's resources folder."); // Setting the context like this works when the data is stored under "/matsim/contribs/bicycle/src/main/resources/bicycle_example" config = ConfigUtils.createConfig("bicycle_example/"); config.addModule(new BicycleConfigGroup()); fillConfigWithBicycleStandardValues(config); config.network().setInputFile("network_lane.xml"); // Modify this config.plans().setInputFile("population_1200.xml"); } else { throw new RuntimeException("More than one argument was provided. There is no procedure for this situation. Thus aborting!" + " Provide either (1) only a suitable config file or (2) no argument at all to run example with given example of resources folder."); } config.controler().setLastIteration(100); // Modify if motorized interaction is used boolean considerMotorizedInteraction = false; new RunBicycleExample().run(config, considerMotorizedInteraction); }