// TODO: in controller, add income to person
  public double getParkingCostBeta(Person person) {
    Id personId = person.getId();
    if (!parkingCostBetaCache.containsKey(personId)) {
      parkingCostBetaParser.setVariable("income", income.get(personId));
      try {
        parkingCostBetaCache.put(personId, parkingCostBetaParser.parse());
      } catch (SyntaxException e) {
        e.printStackTrace();
        DebugLib.stopSystemAndReportInconsistency();
      }
    }

    return parkingCostBetaCache.get(personId);
  }
  public static void main(String[] args) {
    String basePath = "H:/data/experiments/TRBAug2012/runs/run77/output/";
    String fileName = basePath + "houseHoldIncome.txt";

    DoubleValueHashMap<Id<Person>> income = readIncome(fileName);

    int iterationNumber = 35;

    // String fileNameInputFile = ".walkTimes.txt";
    String fileNameInputFile = ".parkingCostLog.txt";

    String walkTimesFile =
        basePath + "ITERS/it." + iterationNumber + "/" + iterationNumber + fileNameInputFile;

    IntegerValueHashMap<Id> numberOfParkingActs = new IntegerValueHashMap<Id>();
    DoubleValueHashMap<Id> walkTimes = new DoubleValueHashMap<Id>();
    Matrix walkTimesMatrix = GeneralLib.readStringMatrix(walkTimesFile, "\t");

    for (int i = 1; i < walkTimesMatrix.getNumberOfRows(); i++) {
      String parkingIdString = walkTimesMatrix.getString(i, 1);
      if (parkingIdString.contains("gp") || parkingIdString.contains("stp")) {
        Id<Person> personId = Id.create(walkTimesMatrix.getString(i, 0), Person.class);
        double walkTime = walkTimesMatrix.getDouble(i, 2);

        if (walkTime != 0) {
          numberOfParkingActs.increment(personId);
          walkTimes.incrementBy(personId, walkTime);
        }
      }
    }

    for (Id<Person> personId : walkTimes.keySet()) {
      double averageWalkTime = walkTimes.get(personId) / numberOfParkingActs.get(personId);
      walkTimes.put(personId, averageWalkTime);
    }

    IntegerValueHashMap<Integer> categoryFrequency = new IntegerValueHashMap<Integer>();
    DoubleValueHashMap<Integer> categorySum = new DoubleValueHashMap<Integer>();
    for (Id<Person> personId : walkTimes.keySet()) {
      int incomeCategory = getIncomeCategory(income.get(personId));
      categorySum.incrementBy(incomeCategory, walkTimes.get(personId));
      categoryFrequency.increment(incomeCategory);
    }

    for (Integer incomeCategory : categorySum.keySet()) {
      categorySum.put(
          incomeCategory, categorySum.get(incomeCategory) / categoryFrequency.get(incomeCategory));
    }

    categorySum.printToConsole();
  }