Ejemplo n.º 1
0
  public double getParkingWalkBeta(Person person, double activityDurationInSeconds) {
    Id personId = person.getId();
    Parser parser = null;
    if (!parkingWalkBetaCache.containsKey(personId)) {
      Parser pTmp = new Parser(parkingWalkBeta);
      PersonImpl persImpl = (PersonImpl) person;

      int isMale = 1;
      if (persImpl.getSex() != null) {
        isMale = !persImpl.getSex().contains("f") ? 1 : 0;
      }

      pTmp.setVariable("isMale", isMale);

      int age = persImpl.getAge();

      pTmp.setVariable("ageInYears", age);
      parkingWalkBetaCache.put(personId, pTmp);
    }
    parser = parkingWalkBetaCache.get(personId);

    parser.setVariable("activityDurationInSeconds", activityDurationInSeconds);

    double result = 0;

    try {
      result = parser.parse();
    } catch (SyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return result;
  }
Ejemplo n.º 2
0
  // 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);
  }