/** 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 void initializeTimeClasses() {
    int endOfTimeClass = 0;
    int classCounter = 0;
    double minTime = Collections.min(allDurDiffs);
    double maxTime = Collections.max(allDurDiffs);

    timeClasses.add(endOfTimeClass);

    while (endOfTimeClass <= maxTime) {
      endOfTimeClass = 100 * (int) Math.pow(2, classCounter);
      classCounter++;
      timeClasses.add(endOfTimeClass);
    }

    endOfTimeClass = 0;
    classCounter = 0;
    while (endOfTimeClass <= -minTime) {
      endOfTimeClass = 100 * (int) Math.pow(2, classCounter);
      classCounter++;
      timeClasses.add(-endOfTimeClass);
    }
    Collections.sort(timeClasses);
    ActivityType2DurationHandler.LOG.info(
        "Following activity duration classes are defined: " + timeClasses.toString());
  }
  private void writeResults(final String runCase) {
    String fileName =
        outputDir
            + "/analysis/"
            + runCase
            + userGroup
            + "_actTyp2ActDur_Diff_DistributionDuration.txt";
    BufferedWriter writer = IOUtils.getBufferedWriter(fileName);
    try {
      writer.write("timeIndex \t ");
      for (String actType : actType2ActDurationDiff2LegCount.keySet()) {
        writer.write(actType + "\t");
      }
      writer.newLine();

      for (int i : timeClasses) {
        writer.write(i + "\t");
        for (String actType : actType2ActDurationDiff2LegCount.keySet()) {
          writer.write(actType2ActDurationDiff2LegCount.get(actType).get(i) + "\t");
        }
        writer.newLine();
      }
      writer.close();
    } catch (Exception e) {
      throw new RuntimeException("Data is not written. Reason - " + e);
    }
    ActivityType2DurationHandler.LOG.info("Data is written to file " + fileName);
  }
 /**
  * @param outputDir
  * @param bau business as usual scenario name or run number for baseCaseCtd
  * @param userGroup for which distribution is required
  */
 public ActDurationDiffDistribution(
     final String outputDir, final String bau, final UserGroup userGroup) {
   this.outputDir = outputDir;
   this.bau = bau;
   this.sortPersons = true;
   this.userGroup = userGroup.toString();
   ActivityType2DurationHandler.LOG.warn(
       "Result will consider persons from " + this.userGroup + " sub population group.");
 }