/** writes activity type to typical activity duration to file. */
  private void writeTypicalAndMinimumActivityDurations(final String configFile) {

    Config config = new Config();
    config.addCoreModules();
    ConfigReader reader = new ConfigReader(config);
    reader.readFile(configFile);

    SortedMap<String, Double> act2TypDur = new TreeMap<>();
    SortedMap<String, Double> act2MinDur = new TreeMap<>();

    for (String actTyp : config.planCalcScore().getActivityTypes()) {
      act2TypDur.put(actTyp, config.planCalcScore().getActivityParams(actTyp).getTypicalDuration());
      act2MinDur.put(actTyp, config.planCalcScore().getActivityParams(actTyp).getMinimalDuration());
    }

    String fileName = outputDir + "/analysis/actTyp2TypicalAndMinimumActDurations.txt";
    BufferedWriter writer = IOUtils.getBufferedWriter(fileName);
    try {
      writer.write("actType \t typicalActDuration \t minimumActDuration \n");
      for (String actTyp : act2MinDur.keySet()) {
        writer.write(actTyp + "\t" + act2TypDur.get(actTyp) + "\t" + act2MinDur.get(actTyp) + "\n");
      }
      writer.close();
    } catch (Exception e) {
      throw new RuntimeException("Data is not written. Reason - " + e);
    }
    ActivityType2DurationHandler.LOG.info("Data is written to file " + fileName);
  }
 private static int getLastIteration() {
   Config config = new Config();
   config.addCoreModules();
   ConfigReader configReader = new ConfigReader(config);
   configReader.readFile(RunEmissionToolOfflineExample.configFile);
   return config.controler().getLastIteration();
 }
Ejemplo n.º 3
0
 public static Config loadConfig(String file) {
   Config config = new Config();
   config.addCoreModules();
   ConfigReader reader = new ConfigReader(config);
   reader.readFile(file);
   return config;
 }
Ejemplo n.º 4
0
 public KmlPlansVisualizer(final String config, final List<Tuple<String, String>> linkTuples) {
   Config conf = new Config();
   ConfigReader reader = new ConfigReader(conf);
   reader.readFile(config);
   scenario = (ScenarioImpl) ScenarioUtils.createScenario(conf);
   new ScenarioLoaderImpl(conf).loadScenario();
   this.linkTuples = linkTuples;
 }
 private Double getEndTime(String configfile) {
   Config config = ConfigUtils.createConfig();
   ConfigReader configReader = new ConfigReader(config);
   configReader.readFile(configfile);
   Double endTime = config.qsim().getEndTime();
   logger.info("Simulation end time is: " + endTime / 3600 + " hours.");
   logger.info(
       "Aggregating emissions for " + (int) (endTime / 3600 / noOfTimeBins) + " hour time bins.");
   return endTime;
 }
Ejemplo n.º 6
0
  void moveInitDemandToDifferentNetwork(final String[] args) {

    // read ivtch demand
    MutableScenario scenario =
        (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig());
    Config config = scenario.getConfig();
    MeisterkConfigGroup meisterkConfigGroup = new MeisterkConfigGroup();
    config.addModule(meisterkConfigGroup);
    ConfigReader reader = new ConfigReader(config);
    reader.readFile(args[0]);
    MatsimRandom.reset(config.global().getRandomSeed());

    ScenarioUtils.loadScenario(scenario);

    Population population = scenario.getPopulation();
    Network network = scenario.getNetwork();

    // remove links and routes
    PersonRemoveLinkAndRoute personRemoveLinkAndRoute = new PersonRemoveLinkAndRoute();
    personRemoveLinkAndRoute.run(population);

    // switch to new network in scenario

    // this is what I found ...
    //		ScenarioImpl scenario2 = (ScenarioImpl)
    // ScenarioUtils.createScenario(ConfigUtils.createConfig());
    //		new MatsimNetworkReader(scenario2).parse(config.getParam(MeisterkConfigGroup.GROUP_NAME,
    // "inputSecondNetworkFile"));
    //		scenario.setNetwork(scenario2.getNetwork());

    // ... but I think we can just give the existing scenario to the reader, so I am changing this.
    // There is so much commented out in this
    // code that it is probably no longer used anyways. kai, sep'15
    new MatsimNetworkReader(scenario)
        .parse(config.getParam(MeisterkConfigGroup.GROUP_NAME, "inputSecondNetworkFile"));

    // run XY2Links
    XY2Links xY2Links = new XY2Links();

    // write out new initial demand
    // new PopulationWriter(population,
    // network).write(null);//scenario.getConfig().plans().getOutputFile());

  }
Ejemplo n.º 7
0
  void ktiPtRoutesPerformanceTest(final String[] args) {

    MutableScenario scenario =
        (MutableScenario) ScenarioUtils.createScenario(ConfigUtils.createConfig());
    Config config = scenario.getConfig();
    KtiConfigGroup ktiConfigGroup = new KtiConfigGroup();
    config.addModule(ktiConfigGroup);
    ConfigReader reader = new ConfigReader(config);
    reader.readFile(args[0]);

    Network network = scenario.getNetwork();

    NodeImpl node = null;

    node = new NodeImpl(Id.create(1, Node.class));
    final double x = -824635.0;
    final double y = -799519.0;
    node.setCoord(new Coord(x, y));
    network.addNode(node);

    node = new NodeImpl(Id.create(2, Node.class));
    node.setCoord(new Coord(2732681.5, 2625289.25));
    network.addNode(node);

    PlansCalcRouteKtiInfo plansCalcRouteKtiInfo = new PlansCalcRouteKtiInfo(ktiConfigGroup);
    plansCalcRouteKtiInfo.prepare(network);

    int skip = 1;
    int max = 100000;
    for (int i = 0; i < max; i++) {
      String expectedRouteDescription = "kti=300614=6616=456.78=4258=8500301";
      KtiPtRoute testee = new KtiPtRoute(null, null, plansCalcRouteKtiInfo);
      testee.setRouteDescription(expectedRouteDescription);
      if (i == skip) {
        logger.info("Constructed " + i + " KtiPtRoute objects with processing route descriptions.");
        skip += max / 10;
      }
    }
    logger.info("Constructed " + max + " KtiPtRoute objects with processing route descriptions.");
  }