@SuppressWarnings("unchecked") @Deprecated // use PersonAttributes public static TreeSet<String> getTravelcards(Person person) { return (TreeSet<String>) person.getCustomAttributes().get(TRAVELCARDS); }
@Deprecated // yyyy is there a way to use person.getAttributes instead?? kai, nov'16 public static void addTravelcard(Person person, final String type) { if (getTravelcards(person) == null) { person.getCustomAttributes().put(TRAVELCARDS, new TreeSet<String>()); } if (getTravelcards(person).contains(type)) { log.info(person + "[type=" + type + " already exists]"); } else { getTravelcards(person).add(type.intern()); } }
/** * convenience method for often used demographic attribute */ public static void setAge(Person person, final Integer age) { if (age!=null){ person.getCustomAttributes().put(AGE, age); person.getAttributes().putAttribute(AGE,age ) ; } }
/** * convenience method for often used demographic attribute */ public static void setEmployed(Person person, final Boolean employed) { if (employed!=null){ person.getCustomAttributes().put(EMPLOYED, employed); person.getAttributes().putAttribute(EMPLOYED,employed ) ; } }
/** * convenience method for often used demographic attribute */ public static void setLicence(Person person, final String licence) { if (licence!=null){ person.getCustomAttributes().put(HAS_LICENSE, licence); person.getAttributes().putAttribute(HAS_LICENSE, licence ) ; } }
/** * convenience method for often used demographic attribute */ public static void setCarAvail(Person person, final String carAvail) { if (carAvail!=null){ person.getCustomAttributes().put(CAR_AVAIL, carAvail); person.getAttributes().putAttribute(CAR_AVAIL,carAvail ) ; } }
/** * convenience method for often used demographic attribute */ public static void setSex(Person person, final String sex) { if (sex!=null){ person.getCustomAttributes().put(SEX_ATTRIBUTE, sex); person.getAttributes().putAttribute( SEX_ATTRIBUTE, sex ) ; } }
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle) { double normalTravelDisutilityForLink = this.normalTravelDisutility.getLinkTravelDisutility(link, time, person, vehicle); double logNormalRnd = 1. ; // randomize if applicable: if ( sigma != 0. ) { logNormalRnd = (double) person.getCustomAttributes().get("logNormalRnd") ; } // end randomize double tollCost = this.tollCostHandler.getTypicalTollCost(link, time ); return normalTravelDisutilityForLink + tollCost*this.marginalUtilityOfMoney*logNormalRnd ; // sign convention: these are all costs (= disutilities), so they are all normally positive. tollCost is positive, marginalUtilityOfMoney as well. }
person.getCustomAttributes().put("logNormalRnd", logNormalRnd ) ; } else { logNormalRnd = 1. ;
@Override public double getLinkTravelDisutility(Link link, double time, Person person, Vehicle vehicle) { double randomizedTimeDistanceDisutilityForLink = this.randomizedTimeDistanceTravelDisutility.getLinkTravelDisutility(link, time, person, vehicle); double logNormalRnd = 1. ; if ( sigma != 0. ) { logNormalRnd = (double) person.getCustomAttributes().get("logNormalRnd") ; } double linkExpectedTollDisutility = calculateExpectedTollDisutility(link.getId(), time, person.getId()); double randomizedTollDisutility = linkExpectedTollDisutility * logNormalRnd; return randomizedTimeDistanceDisutilityForLink + randomizedTollDisutility; }
@Override public double getLinkTravelDisutility(final Link link, final double time, final Person person, final Vehicle vehicle) { int timeBin = (int) (time / timeBinSize); double timeDistanceTravelDisutilityFromDelegate = this.delegate.getLinkTravelDisutility(link, time, person, vehicle); double logNormalRnd = 1. ; if ( sigma != 0. ) { logNormalRnd = (double) person.getCustomAttributes().get("logNormalRnd") ; } // adjust the travel disutility for the toll double toll = 0.; LinkInfo linkInfo = info.getlinkInfos().get(link.getId()); if (linkInfo != null) { Double linkInfoTimeBinToll = linkInfo.getTime2toll().get(timeBin); if (linkInfoTimeBinToll != null) { toll = linkInfoTimeBinToll; } } double tollAdjustedLinkTravelDisutility = timeDistanceTravelDisutilityFromDelegate + logNormalRnd * marginalUtilityOfMoney * toll; return tollAdjustedLinkTravelDisutility; }
private void writeMaxEps() { for (Person person : this.scenario.getPopulation().getPersons().values()) { for (String flexibleType : this.flexibleTypes) { double maxType = (Double)person.getCustomAttributes().get(flexibleType); this.personsMaxDCScoreUnscaled.putAttribute(person.getId().toString(), flexibleType, maxType); } } ObjectAttributesXmlWriter attributesWriter = new ObjectAttributesXmlWriter(this.personsMaxDCScoreUnscaled); attributesWriter.writeFile(this.config.controler().getOutputDirectory() + maxEpsFile); }
p.getCustomAttributes().put(this.type, maxDCScore);