Skip to content

Commit

Permalink
read penalty from attribute and make it a whole number
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Kohl committed Oct 26, 2023
1 parent 4441437 commit 2cb98ce
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ public void notifyBeforeMobsim(BeforeMobsimEvent event) {
* by that time (calling this method twice, first with {@code false}, then with {@code true} should yield the original plans)
*/
private void changeEgressTimesByGridcell(Collection<? extends Person> population, boolean reverse) {
int sign = reverse ? -1 : 1;
for (Person p : population) {
for (LegActPair walkActPair : this.egressFinder.findEgressWalks(p.getSelectedPlan())) {
double penalty = sign * this.observer.getPenaltyCalculator().getPenalty(walkActPair.leg.getDepartureTime().seconds(), walkActPair.act.getCoord());
setTimes(walkActPair, penalty);
if (reverse) {
double penalty = (double) walkActPair.leg.getAttributes().getAttribute(PENALTY_ATTRIBUTE);
setTimes(walkActPair, -penalty);
walkActPair.leg.getAttributes().removeAttribute(PENALTY_ATTRIBUTE);
} else {
double penalty = Math.round(this.observer.getPenaltyCalculator().getPenalty(walkActPair.leg.getDepartureTime().seconds(), walkActPair.act.getCoord()));
setTimes(walkActPair, penalty);
walkActPair.leg.getAttributes().putAttribute(PENALTY_ATTRIBUTE, penalty);
}
}
Expand Down

0 comments on commit 2cb98ce

Please sign in to comment.