private void loadGrid() { String gridCSVFile = this.noiseParams.getReceiverPointsCSVFile(); Map<Id<ReceiverPoint>, Coord> gridPoints = null; try { gridPoints = readCSVFile(gridCSVFile, ",", 0, 1, 2); } catch (IOException e) { e.printStackTrace(); } CoordinateTransformation ct = TransformationFactory.getCoordinateTransformation(this.noiseParams.getReceiverPointsCSVFileCoordinateSystem(), this.scenario.getConfig().global().getCoordinateSystem()); for (Id<ReceiverPoint> id : gridPoints.keySet()) { Coord coord = gridPoints.get(id); Coord transformedCoord = ct.transform(coord); ReceiverPoint rp = new ReceiverPoint(id, transformedCoord); receiverPoints.put(id, rp); } log.info("Total number of receiver points: " + receiverPoints.size()); }
public AbstractMultithreadedModule(GlobalConfigGroup globalConfigGroup) { this.numOfThreads = globalConfigGroup.getNumberOfThreads(); }
@Override public void run() { resetRandomNumbers(config.global().getRandomSeed(), iteration); runMobSim(); } });
@Test public void testDefaultModes() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); final ChangeLegMode module = new ChangeLegMode(config.global(), config.changeMode()); final String[] modes = new String[] {TransportMode.car, TransportMode.pt}; runTest(module, modes); }
scenario.getConfig().global().setCoordinateSystem(defaultCRS);
int numThreads = config.global().getNumberOfThreads(); if (commandLine.hasOption("t")) try { System.err.println("Will use the number of threads in config for simulation."); config.global().setNumberOfThreads(numThreads); config.parallelEventHandling().setNumberOfThreads(1); writer.writeInt(config.global().getNumberOfThreads()); writer.flush();
this.global = new GlobalConfigGroup(); this.modules.put(GlobalConfigGroup.GROUP_NAME, this.global);
@Test public void testDefaultModes() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); final ChangeSingleLegMode module = new ChangeSingleLegMode(config.global(), config.changeMode()); final String[] modes = new String[] {TransportMode.car, TransportMode.pt}; runTest(module, modes, 5); }
public void testPolygonLanesShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(1); builder.setFeatureGeneratorPrototype(PolygonFeatureGenerator.class); builder.setWidthCalculatorPrototype(LanesBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileP, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
public AbstractMultithreadedGenericStrategyModule(GlobalConfigGroup globalConfigGroup) { this( globalConfigGroup.getNumberOfThreads() ); }
private void dumpFacilities() { // dump facilities try { final String inputCRS = config.facilities().getInputCRS(); final String internalCRS = config.global().getCoordinateSystem(); new FacilitiesWriter(activityFacilities).write(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_FACILITIES)); } catch ( Exception ee ) { log.error("Exception writing facilities.", ee); } }
public static void playConfig(final String[] args) { Config config = ConfigUtils.loadConfig(args[0]); MatsimRandom.reset(config.global().getRandomSeed()); log.info("Complete config dump:"); StringWriter writer = new StringWriter(); new ConfigWriter(config).writeStream(new PrintWriter(writer)); log.info("\n\n" + writer.getBuffer().toString()); log.info("Complete config dump done."); Scenario scenario = ScenarioUtils.loadScenario(config); playScenario(scenario); }
@Test public void testWithConfig_withoutIgnoreCarAvailability() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "car,pt,walk"); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_IGNORECARAVAILABILITY, "false"); final ChangeSingleLegMode module = new ChangeSingleLegMode(config.global(), config.changeMode()); final String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; module.prepareReplanning(null); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); PersonUtils.setCarAvail(person, "never"); Plan plan = PopulationUtils.createPlan(person); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); Leg leg = PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); HashMap<String, Integer> counter = new HashMap<String, Integer>(); for (String mode : modes) { counter.put(mode, Integer.valueOf(0)); } for (int i = 0; i < 50; i++) { module.handlePlan(plan); Integer count = counter.get(leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } Assert.assertEquals(0, counter.get("car").intValue()); }
public void testLineStringShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileShp = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(1); builder.setFeatureGeneratorPrototype(LineStringBasedFeatureGenerator.class); builder.setWidthCalculatorPrototype(LanesBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileShp, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileShp); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
public FastAStarLandmarksFactory() { // the value of 8 threads was the default that I found here when making this configurable without injection. // This was in the create method, with a comment from kai, nov 17. // Not sure why this is a good default. td, nov 18 this(8); }
private void dumpTransitSchedule() { try { if ( transitSchedule != null ) { final String inputCRS = config.transit().getInputScheduleCRS(); final String internalCRS = config.global().getCoordinateSystem(); new TransitScheduleWriter(transitSchedule).writeFile(controlerIO.getOutputFilename(Controler.OUTPUT_PREFIX + Controler.FILENAME_TRANSIT_SCHEDULE)); } } catch ( Exception ee ) { log.error("Exception writing transit schedule.", ee); } }
Scenario scenario; this.config = ConfigUtils.loadConfig(this.configfile); MatsimRandom.reset(this.config.global().getRandomSeed()); scenario = ScenarioUtils.createScenario(this.config);
@Test public void testWithConfig_withoutIgnoreCarAvailability() { Config config = ConfigUtils.createConfig(); config.global().setNumberOfThreads(0); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_MODES, "car,pt,walk"); config.setParam(ChangeModeConfigGroup.CONFIG_MODULE, ChangeModeConfigGroup.CONFIG_PARAM_IGNORECARAVAILABILITY, "false"); final ChangeLegMode module = new ChangeLegMode(config.global(), config.changeMode()); final String[] modes = new String[] {TransportMode.car, TransportMode.pt, TransportMode.walk}; module.prepareReplanning(null); Person person = PopulationUtils.getFactory().createPerson(Id.create(1, Person.class)); PersonUtils.setCarAvail(person, "never"); Plan plan = PopulationUtils.createPlan(person); PopulationUtils.createAndAddActivityFromCoord(plan, "home", new Coord((double) 0, (double) 0)); Leg leg = PopulationUtils.createAndAddLeg( plan, TransportMode.pt ); PopulationUtils.createAndAddActivityFromCoord(plan, "work", new Coord((double) 0, (double) 0)); HashMap<String, Integer> counter = new HashMap<String, Integer>(); for (String mode : modes) { counter.put(mode, Integer.valueOf(0)); } for (int i = 0; i < 100; i++) { module.handlePlan(plan); Integer count = counter.get(leg.getMode()); counter.put(leg.getMode(), Integer.valueOf(count.intValue() + 1)); } Assert.assertEquals(0, counter.get("car").intValue()); }
public void testPolygonCapacityShape() { String netFileName = "test/scenarios/equil/network.xml"; String outputFileP = getOutputDirectory() + "./network.shp"; Scenario scenario = ScenarioUtils.createScenario(ConfigUtils.createConfig()); scenario.getConfig().global().setCoordinateSystem("DHDN_GK4"); final Network network = scenario.getNetwork(); new MatsimNetworkReader(scenario.getNetwork()).readFile(netFileName); FeatureGeneratorBuilderImpl builder = new FeatureGeneratorBuilderImpl(network, "DHDN_GK4"); CoordinateReferenceSystem crs = MGC.getCRS("DHDN_GK4"); builder.setWidthCoefficient(0.001); builder.setFeatureGeneratorPrototype(PolygonFeatureGenerator.class); builder.setWidthCalculatorPrototype(CapacityBasedWidthCalculator.class); builder.setCoordinateReferenceSystem(crs); new Links2ESRIShape(network,outputFileP, builder).write(); Collection<SimpleFeature> writtenFeatures = ShapeFileReader.getAllFeatures(outputFileP); Assert.assertEquals(network.getLinks().size(), writtenFeatures.size()); }
@Inject public AStarLandmarksFactory(final GlobalConfigGroup globalConfigGroup) { this(globalConfigGroup.getNumberOfThreads()); }