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; }
@Override public void run(final Person p) { PersonImpl person = (PersonImpl) p; String carAvail = person.getCarAvail(); int age = person.getAge(); String license = person.getLicense(); boolean isEmployed = person.isEmployed(); if (carAvail != null) { if (carAvail.equals("always")) { if (person.getSex().equals("m")) { male_al++; } else { female_al++; } if (age < 30) { ageA_al++; } else if (age >= 30 && age < 50) { ageB_al++; } else if (age >= 50 && age < 70) { ageC_al++; } else { ageD_al++; } if (license.equals("yes")) { withLicense_al++; } else { withoutLicense_al++; } if (isEmployed) { isEmployed_al++; } else { notEmployed_al++; } } else if (carAvail.equals("sometimes")) { if (person.getSex().equals("m")) { male_so++; } else { female_so++; } if (age < 30) { ageA_so++; } else if (age >= 30 && age < 50) { ageB_so++; } else if (age >= 50 && age < 70) { ageC_so++; } else { ageD_so++; } if (license.equals("yes")) { withLicense_so++; } else { withoutLicense_so++; } if (isEmployed) { isEmployed_so++; } else { notEmployed_so++; } } else if (carAvail.equals("never")) { if (person.getSex().equals("m")) { male_ne++; } else { female_ne++; } if (age < 30) { ageA_ne++; } else if (age >= 30 && age < 50) { ageB_ne++; } else if (age >= 50 && age < 70) { ageC_ne++; } else { ageD_ne++; } if (license.equals("yes")) { withLicense_ne++; } else { withoutLicense_ne++; } if (isEmployed) { isEmployed_ne++; } else { notEmployed_ne++; } } } }