Skip to content

Commit

Permalink
review: Apply fixes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
t2gran committed Dec 13, 2024
1 parent a682d98 commit 6dc9a4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,19 @@ private static DurationForEnum<StreetMode> durationForStreetModeOf(Duration defa
}

private static TimeAndCostPenaltyForEnum<StreetMode> createDefaultCarPenalty() {
var penaltyrBuilder = TimeAndCostPenaltyForEnum.of(StreetMode.class);
var penaltyBuilder = TimeAndCostPenaltyForEnum.of(StreetMode.class);

var flexDefaultPenalty = TimeAndCostPenalty.of(TimePenalty.of(ofMinutes(10), 1.3f), 1.3);
penaltyrBuilder.with(StreetMode.FLEXIBLE, flexDefaultPenalty);
penaltyBuilder.with(StreetMode.FLEXIBLE, flexDefaultPenalty);

// Add penalty to all car variants with access and/or egress.
var carPenalty = TimeAndCostPenalty.of(TimePenalty.of(ofMinutes(20), 2f), 1.5);
for (var it : StreetMode.values()) {
if (it.includesDriving() && (it.accessAllowed() || it.egressAllowed())) {
penaltyrBuilder.with(it, carPenalty);
penaltyBuilder.with(it, carPenalty);
}
}

return penaltyrBuilder.build();
return penaltyBuilder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class StreetPreferencesTest {
private static final int ELEVATOR_BOARD_TIME = (int) Duration.ofMinutes(2).toSeconds();
private static final IntersectionTraversalModel INTERSECTION_TRAVERSAL_MODEL =
IntersectionTraversalModel.CONSTANT;
private static final TimeAndCostPenalty CAR_PENALTY = TimeAndCostPenalty.of(
private static final TimeAndCostPenalty CAR_TO_PARK_PENALTY = TimeAndCostPenalty.of(
TimePenalty.of("2m + 1.5t"),
3.5
);
Expand All @@ -34,7 +34,7 @@ class StreetPreferencesTest {
.withTurnReluctance(TURN_RELUCTANCE)
.withElevator(it -> it.withBoardTime(ELEVATOR_BOARD_TIME))
.withIntersectionTraversalModel(INTERSECTION_TRAVERSAL_MODEL)
.withAccessEgress(it -> it.withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_PENALTY)))
.withAccessEgress(it -> it.withPenalty(Map.of(StreetMode.CAR_TO_PARK, CAR_TO_PARK_PENALTY)))
.withAccessEgress(it -> it.withMaxDuration(MAX_ACCESS_EGRESS, Map.of()))
.withMaxDirectDuration(MAX_DIRECT, Map.of())
.withRoutingTimeout(ROUTING_TIMEOUT)
Expand All @@ -56,7 +56,10 @@ void accessEgressPenalty() {
TimeAndCostPenalty.ZERO,
subject.accessEgress().penalty().valueOf(StreetMode.WALK)
);
assertEquals(CAR_PENALTY, subject.accessEgress().penalty().valueOf(StreetMode.CAR_TO_PARK));
assertEquals(
CAR_TO_PARK_PENALTY,
subject.accessEgress().penalty().valueOf(StreetMode.CAR_TO_PARK)
);
}

@Test
Expand Down Expand Up @@ -112,7 +115,7 @@ void testToString() {
"accessEgress: AccessEgressPreferences{penalty: TimeAndCostPenaltyForEnum{" +
"CAR: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " +
"CAR_TO_PARK: " +
CAR_PENALTY +
CAR_TO_PARK_PENALTY +
", " +
"CAR_PICKUP: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " +
"CAR_RENTAL: (timePenalty: 20m + 2.0 t, costFactor: 1.50), " +
Expand Down

0 comments on commit 6dc9a4e

Please sign in to comment.