Skip to content

Commit

Permalink
Merge pull request #268 from msmobility/fixCommuteModeChoiceMapping
Browse files Browse the repository at this point in the history
fix CommuteModeChoiceMapping
  • Loading branch information
mergify[bot] authored Dec 4, 2019
2 parents ff62fc3 + 1652b72 commit 0bf442e
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ public CommuteModeChoiceMapping assignCommuteModeChoice(Location from, TravelTim
utilityByMode.put(TransportMode.car, carUtility);
utilityByMode.put(TransportMode.pt, ptUtility);
commuteModesByPerson.put(pp.getId(), utilityByMode);
double probabilityAsKey = carUtility / (carUtility + ptUtility);
while (personByProbability.containsKey(probabilityAsKey)){
double probabilityAsKey;
if(carUtility == 0 && ptUtility == 0) {
probabilityAsKey = 0.5;
} else {
probabilityAsKey = carUtility / (carUtility + ptUtility);
}
while (personByProbability.containsKey(probabilityAsKey)) {
//more than one hh member has exactly the same probability, so it would be replaced in the treemap
probabilityAsKey += random.nextDouble();
}
Expand Down Expand Up @@ -125,8 +130,13 @@ public CommuteModeChoiceMapping assignRegionalCommuteModeChoice(Region region, T
utilityByMode.put(TransportMode.car, carUtility);
utilityByMode.put(TransportMode.pt, ptUtility);
commuteModesByPerson.put(pp.getId(), utilityByMode);
double probabilityAsKey = carUtility / (carUtility + ptUtility);
if (personByProbability.containsKey(probabilityAsKey)){
double probabilityAsKey;
if(carUtility == 0 && ptUtility == 0) {
probabilityAsKey = 0.5;
} else {
probabilityAsKey = carUtility / (carUtility + ptUtility);
}
while (personByProbability.containsKey(probabilityAsKey)) {
//more than one hh member has exactly the same probability, so it would be replaced in the treemap
probabilityAsKey += random.nextDouble();
}
Expand Down

0 comments on commit 0bf442e

Please sign in to comment.