Skip to content

Commit

Permalink
Merge pull request #3678 from matsim-org/small-parking-changes
Browse files Browse the repository at this point in the history
small enhancements
  • Loading branch information
paulheinr authored Jan 22, 2025
2 parents 5668f8a + 8dcd8b4 commit 9cd96cb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public PtFareConfigGroup() {
super(MODULE_NAME);
}

public void addPtFareParameterSet(PtFareParams ptFareParams) {
addParameterSet(ptFareParams);
}

@Override
public Map<String, String> getComments() {
Map<String, String> map = super.getComments();
Expand Down Expand Up @@ -60,14 +64,11 @@ public void setUpperBoundFactor(double upperBoundFactor) {

@Override
public ConfigGroup createParameterSet(final String type) {
switch (type) {
case DistanceBasedPtFareParams.SET_TYPE:
return new DistanceBasedPtFareParams();
case FareZoneBasedPtFareParams.SET_TYPE:
return new FareZoneBasedPtFareParams();
default:
throw new IllegalArgumentException(type);
}
return switch (type) {
case DistanceBasedPtFareParams.SET_TYPE -> new DistanceBasedPtFareParams();
case FareZoneBasedPtFareParams.SET_TYPE -> new FareZoneBasedPtFareParams();
default -> throw new IllegalArgumentException(type);
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public abstract class PtFareParams extends ReflectiveConfigGroup {
public static final String DESCRIPTION = "description";

private int order;

//nullable. If null, it will be ignored.
private String fareZoneShp;
private String transactionPartner;
private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ void testChainedPtFareHandler() {
distanceBased2.setTransactionPartner(DISTANCE_BASED_TRANSACTION_PARTNER);
distanceBased2.setMinFare(7.0);

ptFareConfigGroup.addParameterSet(fareZoneBased);
ptFareConfigGroup.addParameterSet(distanceBased);
ptFareConfigGroup.addParameterSet(distanceBased2);
ptFareConfigGroup.addPtFareParameterSet(fareZoneBased);
ptFareConfigGroup.addPtFareParameterSet(distanceBased);
ptFareConfigGroup.addPtFareParameterSet(distanceBased2);

ptFareConfigGroup.setUpperBoundFactor(2.0);

Expand Down Expand Up @@ -145,7 +145,8 @@ public void install() {
// rb17 to Regensburg 2nd home location departs at 16:52 (beyond distance fare 1 zone, distance fare 2 applies, 10230.93m)
work2.setEndTime(16 * 3600. + 40 * 60);
Activity work3 = fac.createActivityFromCoord("work", new Coord(726645.48, 5433383.16));
// rb17 to Kelheim home location departs at 18:46, then transfer to bus 6022 (beyond distance fare 1 zone, distance fare 2 applies, 19871.38m)
// rb17 to Kelheim home location departs at 18:46, then transfer to bus 6022 (beyond distance fare 1 zone, distance fare 2 applies, 19871
// .38m)
work3.setEndTime(18 * 3600. + 40 * 60);
Activity home2 = fac.createActivityFromCoord("home", new Coord(710300.624, 5422165.737));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ void testSamePriority_throws() {
PtFareConfigGroup ptFareConfigGroup = ConfigUtils.addOrGetModule(config, PtFareConfigGroup.class);
FareZoneBasedPtFareParams fareZoneBased = new FareZoneBasedPtFareParams();
fareZoneBased.setOrder(5);
ptFareConfigGroup.addParameterSet(fareZoneBased);
ptFareConfigGroup.addPtFareParameterSet(fareZoneBased);

DistanceBasedPtFareParams distanceBased = new DistanceBasedPtFareParams();
distanceBased.setOrder(5);
ptFareConfigGroup.addParameterSet(distanceBased);
ptFareConfigGroup.addPtFareParameterSet(distanceBased);

Assertions.assertThrows(IllegalArgumentException.class, () -> ptFareConfigGroup.checkConsistency(config));
}
Expand All @@ -34,11 +34,11 @@ void test_ok() {
PtFareConfigGroup ptFareConfigGroup = ConfigUtils.addOrGetModule(config, PtFareConfigGroup.class);
FareZoneBasedPtFareParams fareZoneBased = new FareZoneBasedPtFareParams();
fareZoneBased.setOrder(5);
ptFareConfigGroup.addParameterSet(fareZoneBased);
ptFareConfigGroup.addPtFareParameterSet(fareZoneBased);

DistanceBasedPtFareParams distanceBased = new DistanceBasedPtFareParams();
distanceBased.setOrder(10);
ptFareConfigGroup.addParameterSet(distanceBased);
ptFareConfigGroup.addPtFareParameterSet(distanceBased);

ptFareConfigGroup.checkConsistency(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void setUp() throws Exception {
distanceClassLongFareParams.setFareIntercept(1.0);
distanceClassLongFareParams.setFareSlope(0.01);

fare.addParameterSet(distanceFare);
fare.addPtFareParameterSet(distanceFare);

controler = MATSimApplication.prepare(TestScenario.class, config);
injector = controler.getInjector();
Expand Down

0 comments on commit 9cd96cb

Please sign in to comment.