From 0553601e0b9cb86b0b765c116e7e3f0ec9041bb0 Mon Sep 17 00:00:00 2001 From: Joschka Bischoff Date: Fri, 22 Dec 2023 08:34:29 +0100 Subject: [PATCH 1/2] add mode2mode specific transfer constants to SwissRailRaptor --- .../config/SwissRailRaptorConfigGroup.java | 69 +++++++++++++++---- .../DefaultRaptorTransferCostCalculator.java | 5 +- .../routing/pt/raptor/RaptorStaticConfig.java | 19 ++++- .../raptor/RaptorTransferCostCalculator.java | 2 +- .../matsim/routing/pt/raptor/RaptorUtils.java | 4 ++ .../pt/raptor/SwissRailRaptorCore.java | 4 +- .../SwissRailRaptorConfigGroupTest.java | 20 ++++++ .../pt/raptor/SwissRailRaptorTest.java | 49 ++++++++----- 8 files changed, 134 insertions(+), 38 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java index 2473517c9d1..dc70fa55366 100644 --- a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java +++ b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java @@ -81,6 +81,7 @@ public class SwissRailRaptorConfigGroup extends ReflectiveConfigGroup { private final Map rangeQuerySettingsPerSubpop = new HashMap<>(); private final Map routeSelectorPerSubpop = new HashMap<>(); private final List intermodalAccessEgressSettings = new ArrayList<>(); + private final List modeToModeTransferPenaltyParameterSets = new ArrayList<>(); private final Map modeMappingForPassengersByRouteMode = new HashMap<>(); @@ -243,19 +244,19 @@ public void setTransferPenaltyCostPerTravelTimeHour(double hourlyCost) { this.transferPenaltyHourlyCost = hourlyCost; } - @Override + + @Override public ConfigGroup createParameterSet(String type) { - if (RangeQuerySettingsParameterSet.TYPE.equals(type)) { - return new RangeQuerySettingsParameterSet(); - } else if (RouteSelectorParameterSet.TYPE.equals(type)) { - return new RouteSelectorParameterSet(); - } else if (IntermodalAccessEgressParameterSet.TYPE.equals(type)) { - return new IntermodalAccessEgressParameterSet(); - } else if (ModeMappingForPassengersParameterSet.TYPE.equals(type)) { - return new ModeMappingForPassengersParameterSet(); - } else { - throw new IllegalArgumentException("Unsupported parameterset-type: " + type); - } + return switch (type){ + case RangeQuerySettingsParameterSet.TYPE -> new RangeQuerySettingsParameterSet(); + case RouteSelectorParameterSet.TYPE -> new RouteSelectorParameterSet(); + case IntermodalAccessEgressParameterSet.TYPE -> new IntermodalAccessEgressParameterSet(); + case ModeMappingForPassengersParameterSet.TYPE -> new ModeMappingForPassengersParameterSet(); + case ModeToModeTransferPenalty.TYPE -> new ModeToModeTransferPenalty(); + default -> throw new IllegalArgumentException("Unsupported parameterset-type: " + type); + + }; + } @Override @@ -267,13 +268,25 @@ public void addParameterSet(ConfigGroup set) { } else if (set instanceof IntermodalAccessEgressParameterSet) { addIntermodalAccessEgress((IntermodalAccessEgressParameterSet) set); } else if (set instanceof ModeMappingForPassengersParameterSet) { - addModeMappingForPassengers((ModeMappingForPassengersParameterSet) set); + addModeMappingForPassengers((ModeMappingForPassengersParameterSet) set);} + else if (set instanceof ModeToModeTransferPenalty) { + addModeToModeTransferPenalty((ModeToModeTransferPenalty) set); } else { throw new IllegalArgumentException("Unsupported parameterset: " + set.getClass().getName()); } } - public void addRangeQuerySettings(RangeQuerySettingsParameterSet settings) { + public void addModeToModeTransferPenalty(ModeToModeTransferPenalty set) { + this.modeToModeTransferPenaltyParameterSets.add(set); + super.addParameterSet(set); + + } + + public List getModeToModeTransferPenaltyParameterSets() { + return modeToModeTransferPenaltyParameterSets; + } + + public void addRangeQuerySettings(RangeQuerySettingsParameterSet settings) { Set subpops = settings.getSubpopulations(); if (subpops.isEmpty()) { this.rangeQuerySettingsPerSubpop.put(null, settings); @@ -662,7 +675,33 @@ public void setPassengerMode(String passengerMode) { } } - @Override + public static class ModeToModeTransferPenalty extends ReflectiveConfigGroup{ + private static final String TYPE = "modeToModeTransferPenalty"; + @Parameter + @Comment("from Transfer PT Sub-Mode") + public String fromMode; + @Parameter + @Comment("to Transfer PT Sub-Mode") + public String toMode; + @Parameter + @Comment("Transfer Penalty per Transfer between modes") + public double transferPenalty = 0.0; + + public ModeToModeTransferPenalty() { + super(TYPE); + } + + public ModeToModeTransferPenalty(String fromMode, String toMode, double transferPenalty) { + super(TYPE); + this.fromMode = fromMode; + this.toMode = toMode; + this.transferPenalty = transferPenalty; + } + } + + + + @Override public Map getComments() { Map comments = super.getComments(); comments.put(PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION, PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION_DESC); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java index 5522400f8cb..a6c1d59cebf 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/DefaultRaptorTransferCostCalculator.java @@ -26,13 +26,14 @@ */ public class DefaultRaptorTransferCostCalculator implements RaptorTransferCostCalculator { @Override - public double calcTransferCost(Supplier transfer, RaptorParameters raptorParams, int totalTravelTime, int transferCount, double existingTransferCosts, double currentTime) { + public double calcTransferCost(Supplier transfer, RaptorStaticConfig staticConfig, RaptorParameters raptorParams, int totalTravelTime, int transferCount, double existingTransferCosts, double currentTime) { double transferCostBase = raptorParams.getTransferPenaltyFixCostPerTransfer(); + double transferCostModeToMode = staticConfig.isUseModeToModeTransferPenalty()?staticConfig.getModeToModeTransferPenalty(transfer.get().getFromTransitRoute().getTransportMode(),transfer.get().getToTransitRoute().getTransportMode()):0.0; double transferCostPerHour = raptorParams.getTransferPenaltyPerTravelTimeHour(); double transferCostMin = raptorParams.getTransferPenaltyMinimum(); double transferCostMax = raptorParams.getTransferPenaltyMaximum(); - return (calcSingleTransferCost(transferCostBase, transferCostPerHour, transferCostMin, transferCostMax, totalTravelTime) * transferCount) - existingTransferCosts; + return (calcSingleTransferCost(transferCostBase+transferCostModeToMode, transferCostPerHour, transferCostMin, transferCostMax, totalTravelTime) * transferCount) - existingTransferCosts; } private double calcSingleTransferCost(double costBase, double costPerHour, double costMin, double costMax, double travelTime) { diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java index e80561feea5..cebf66bf2bb 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java @@ -34,7 +34,9 @@ */ public class RaptorStaticConfig { - public enum RaptorOptimization { + + + public enum RaptorOptimization { /** * Use this option if you plan to calculate simple from-to routes * (see {@link SwissRailRaptor#calcRoute(org.matsim.facilities.Facility, org.matsim.facilities.Facility, double, org.matsim.api.core.v01.population.Person)}). @@ -60,6 +62,7 @@ public enum RaptorOptimization { private boolean useModeMappingForPassengers = false; private final Map passengerModeMappings = new HashMap<>(); + private final Map> modeToModeTransferPenalties = new HashMap<>(); private boolean useCapacityConstraints = false; @@ -114,6 +117,20 @@ public boolean isUseModeMappingForPassengers() { public void setUseModeMappingForPassengers(boolean useModeMappingForPassengers) { this.useModeMappingForPassengers = useModeMappingForPassengers; } + public void addModeToModeTransferPenalty(String fromMode, String toMode, double transferPenalty) { + this.modeToModeTransferPenalties.computeIfAbsent(fromMode,s->new HashMap<>()).put(toMode,transferPenalty); + } + public double getModeToModeTransferPenalty(String fromMode, String toMode){ + var fromModeSet = this.modeToModeTransferPenalties.get(fromMode); + if (fromModeSet!=null){ + return fromModeSet.getOrDefault(toMode,0.0); + } + else return 0.0; + } + + public boolean isUseModeToModeTransferPenalty(){ + return !this.modeToModeTransferPenalties.isEmpty(); + } public boolean isUseCapacityConstraints() { return this.useCapacityConstraints; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java index 1a114db0a61..ad3fb6d08ab 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorTransferCostCalculator.java @@ -26,6 +26,6 @@ */ public interface RaptorTransferCostCalculator { - double calcTransferCost(Supplier transfer, RaptorParameters raptorParams, int totalTravelTime, int totalTransferCount, double existingTransferCosts, double currentTime); + double calcTransferCost(Supplier transfer, RaptorStaticConfig staticConfig, RaptorParameters raptorParams, int totalTravelTime, int totalTransferCount, double existingTransferCosts, double currentTime); } diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java index 2fae233bf34..f289b04e486 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorUtils.java @@ -70,6 +70,10 @@ public static RaptorStaticConfig createStaticConfig(Config config) { staticConfig.addModeMappingForPassengers(mapping.getRouteMode(), mapping.getPassengerMode()); } } + + for (SwissRailRaptorConfigGroup.ModeToModeTransferPenalty penalty : srrConfig.getModeToModeTransferPenaltyParameterSets()){ + staticConfig.addModeToModeTransferPenalty(penalty.fromMode,penalty.toMode,penalty.transferPenalty); + } staticConfig.setUseCapacityConstraints(srrConfig.isUseCapacityConstraints()); return staticConfig; diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java index c0cfeb893bc..f68a75bd490 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorCore.java @@ -637,7 +637,7 @@ private void exploreRoutes(RaptorParameters parameters, Person person) { int inVehicleTime = arrivalTime - currentAgentBoardingTime; double inVehicleCost = this.inVehicleCostCalculator.getInVehicleCost(inVehicleTime, marginalUtilityOfTravelTime_utl_s, person, currentVehicle, parameters, routeSegmentIterator); double arrivalTravelCost = currentTravelCostWhenBoarding + inVehicleCost; - double arrivalTransferCost = (boardingPE.firstDepartureTime != TIME_UNDEFINED) ? (currentTransferCostWhenBoarding + this.transferCostCalculator.calcTransferCost(transferProvider, parameters, arrivalTime - firstDepartureTime, boardingPE.transferCount, boardingPE.arrivalTransferCost, boardingPE.arrivalTime)) : 0; + double arrivalTransferCost = (boardingPE.firstDepartureTime != TIME_UNDEFINED) ? (currentTransferCostWhenBoarding + this.transferCostCalculator.calcTransferCost(transferProvider, data.config, parameters, arrivalTime - firstDepartureTime, boardingPE.transferCount, boardingPE.arrivalTransferCost, boardingPE.arrivalTime)) : 0; double previousArrivalCost = this.leastArrivalCostAtRouteStop[toRouteStopIndex]; double totalArrivalCost = arrivalTravelCost + arrivalTransferCost; if (totalArrivalCost <= previousArrivalCost) { @@ -758,7 +758,7 @@ private void handleTransfers(boolean strict, RaptorParameters raptorParams) { transferProvider.reset(transfer); int newArrivalTime = arrivalTime + transfer.transferTime; double newArrivalTravelCost = arrivalTravelCost - transfer.transferTime * margUtilityTransitWalk; - double newArrivalTransferCost = (fromPE.firstDepartureTime != TIME_UNDEFINED) ? (arrivalTransferCost + this.transferCostCalculator.calcTransferCost(transferProvider, raptorParams, newArrivalTime - fromPE.firstDepartureTime, fromPE.transferCount + 1, arrivalTransferCost, arrivalTime)) : 0; + double newArrivalTransferCost = (fromPE.firstDepartureTime != TIME_UNDEFINED) ? (arrivalTransferCost + this.transferCostCalculator.calcTransferCost(transferProvider, data.config, raptorParams, newArrivalTime - fromPE.firstDepartureTime, fromPE.transferCount + 1, arrivalTransferCost, arrivalTime)) : 0; double newTotalArrivalCost = newArrivalTravelCost + newArrivalTransferCost; double prevLeastArrivalCost = this.leastArrivalCostAtRouteStop[toRouteStopIndex]; if (newTotalArrivalCost < prevLeastArrivalCost || (!strict && newTotalArrivalCost <= prevLeastArrivalCost)) { diff --git a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java index d206be9f32b..c4ae84b43ac 100644 --- a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java @@ -33,6 +33,7 @@ import org.matsim.core.config.ConfigReader; import org.matsim.core.config.ConfigUtils; import org.matsim.core.config.ConfigWriter; +import org.matsim.testcases.MatsimTestUtils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -261,6 +262,25 @@ void testConfigIO_modeMappings() { Assertions.assertNull(config2.getModeMappingForPassengersParameterSet("road")); Assertions.assertNull(config2.getModeMappingForPassengersParameterSet("ship")); } + @Test + void testConfigIO_ModeToModePenalties() { + SwissRailRaptorConfigGroup config1 = new SwissRailRaptorConfigGroup(); + + { // prepare config1 + config1.setUseModeMappingForPassengers(true); + SwissRailRaptorConfigGroup.ModeToModeTransferPenalty penalty = new SwissRailRaptorConfigGroup.ModeToModeTransferPenalty(TransportMode.airplane,TransportMode.ship,100); + config1.addParameterSet(penalty); + } + + SwissRailRaptorConfigGroup config2 = writeRead(config1); + + // do checks + + SwissRailRaptorConfigGroup.ModeToModeTransferPenalty penalty = config2.getModeToModeTransferPenaltyParameterSets().get(0); + Assertions.assertEquals(penalty.transferPenalty,100.0, MatsimTestUtils.EPSILON); + Assertions.assertEquals(penalty.fromMode,TransportMode.airplane); + Assertions.assertEquals(penalty.toMode,TransportMode.ship); + } private SwissRailRaptorConfigGroup writeRead(SwissRailRaptorConfigGroup config) { Config fullConfig1 = ConfigUtils.createConfig(config); diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index 559a2970bf2..f39f64426b9 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -68,8 +68,7 @@ import java.util.List; import java.util.function.Supplier; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * Most of these tests were copied from org.matsim.pt.router.TransitRouterImplTest @@ -343,6 +342,25 @@ void testLineChange() { CoordUtils.calcEuclideanDistance(f.schedule.getFacilities().get(Id.create("19", TransitStopFacility.class)).getCoord(), toCoord) / raptorParams.getBeelineWalkSpeed(); assertEquals(Math.ceil(expectedTravelTime), actualTravelTime, MatsimTestUtils.EPSILON); } + @Test + void testLineChangeWithDifferentUtils() { + Fixture f = new Fixture(); + f.init(); + f.blueLine.getRoutes().values().forEach(transitRoute -> transitRoute.setTransportMode(TransportMode.ship)); + SwissRailRaptorConfigGroup swissRailRaptorConfigGroup = ConfigUtils.addOrGetModule(f.config, SwissRailRaptorConfigGroup.class); + SwissRailRaptorConfigGroup.ModeToModeTransferPenalty trainToShip = new SwissRailRaptorConfigGroup.ModeToModeTransferPenalty("train",TransportMode.ship,1000000.0); + SwissRailRaptorConfigGroup.ModeToModeTransferPenalty shipToTrain = new SwissRailRaptorConfigGroup.ModeToModeTransferPenalty(TransportMode.ship,"train",1000000.0); + swissRailRaptorConfigGroup.addModeToModeTransferPenalty(trainToShip); + swissRailRaptorConfigGroup.addModeToModeTransferPenalty(shipToTrain); + swissRailRaptorConfigGroup.setTransferWalkMargin(0); + RaptorParameters raptorParams = RaptorUtils.createParameters(f.config); + TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); + Coord fromCoord = new Coord(3800, 5100); + Coord toCoord = new Coord(16100, 10050); + List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(fromCoord), new FakeFacility(toCoord), 6.0*3600, null)); + //changing from train to ship is so expensive that direct walk is cheaper + assertNull(legs); + } @Test void testFasterAlternative() { @@ -868,21 +886,18 @@ void testCustomTransferCostCalculator() { int[] transferCount = new int[] { 0 }; SwissRailRaptorData data = SwissRailRaptorData.create(f.schedule, null, RaptorUtils.createStaticConfig(f.config), f.scenario.getNetwork(), null); - SwissRailRaptor router = new Builder(data, f.config).with(new RaptorTransferCostCalculator() { - @Override - public double calcTransferCost(Supplier transfer, RaptorParameters raptorParams, int totalTravelTime, int totalTransferCount, double existingTransferCosts, double now) { - transferCount[0]++; - Transfer t = transfer.get(); - - assertEquals(f.stop1, t.getFromStop()); - assertEquals(f.stop2, t.getToStop()); - assertEquals(Id.create("0to1", TransitLine.class), t.getFromTransitLine().getId()); - assertEquals(Id.create("2to3", TransitLine.class), t.getToTransitLine().getId()); - assertEquals(Id.create("0to1", TransitRoute.class), t.getFromTransitRoute().getId()); - assertEquals(Id.create("2to3", TransitRoute.class), t.getToTransitRoute().getId()); - - return 0.5; - } + SwissRailRaptor router = new Builder(data, f.config).with((transfer, staticConfig, raptorParams, totalTravelTime, totalTransferCount, existingTransferCosts, now) -> { + transferCount[0]++; + Transfer t = transfer.get(); + + assertEquals(f.stop1, t.getFromStop()); + assertEquals(f.stop2, t.getToStop()); + assertEquals(Id.create("0to1", TransitLine.class), t.getFromTransitLine().getId()); + assertEquals(Id.create("2to3", TransitLine.class), t.getToTransitLine().getId()); + assertEquals(Id.create("0to1", TransitRoute.class), t.getFromTransitRoute().getId()); + assertEquals(Id.create("2to3", TransitRoute.class), t.getToTransitRoute().getId()); + + return 0.5; }).build(); Coord fromCoord = f.fromFacility.getCoord(); From 2432321f9749c0af0a8bf9d7962bc5d7ba60211f Mon Sep 17 00:00:00 2001 From: Joschka Bischoff Date: Fri, 22 Dec 2023 08:45:13 +0100 Subject: [PATCH 2/2] add mode2mode specific transfer constants to SwissRailRaptor --- .../matsim/config/SwissRailRaptorConfigGroup.java | 4 ++-- .../routing/pt/raptor/RaptorStaticConfig.java | 8 ++++++-- .../config/SwissRailRaptorConfigGroupTest.java | 4 +--- .../routing/pt/raptor/SwissRailRaptorTest.java | 13 +++---------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java index dc70fa55366..3c8040a92fb 100644 --- a/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java +++ b/matsim/src/main/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroup.java @@ -40,7 +40,6 @@ */ public class SwissRailRaptorConfigGroup extends ReflectiveConfigGroup { - private static final Logger log = LogManager.getLogger(SwissRailRaptorConfigGroup.class); public static final String GROUP = "swissRailRaptor"; private static final String PARAM_USE_RANGE_QUERY = "useRangeQuery"; @@ -707,6 +706,7 @@ public Map getComments() { comments.put(PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION, PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION_DESC); comments.put(PARAM_USE_CAPACITY_CONSTRAINTS, PARAM_USE_CAPACITY_CONSTRAINTS_DESC); comments.put(PARAM_TRANSFER_WALK_MARGIN, PARAM_TRANSFER_WALK_MARGIN_DESC); + comments.put(PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION,PARAM_INTERMODAL_ACCESS_EGRESS_MODE_SELECTION_DESC); return comments; } @@ -718,7 +718,7 @@ protected void checkConsistency(Config config) { Verify.verify(config.plans().getHandlingOfPlansWithoutRoutingMode().equals(HandlingOfPlansWithoutRoutingMode.reject), "Using intermodal access and egress in " + "combination with plans without a routing mode is not supported."); - Verify.verify(intermodalAccessEgressSettings.size() >= 1, "Using intermodal routing, but there are no access/egress " + Verify.verify(!intermodalAccessEgressSettings.isEmpty(), "Using intermodal routing, but there are no access/egress " + "modes defined. Add at least one parameterset with an access/egress mode and ensure " + "SwissRailRaptorConfigGroup is loaded correctly."); diff --git a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java index cebf66bf2bb..20b94216349 100644 --- a/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java +++ b/matsim/src/main/java/ch/sbb/matsim/routing/pt/raptor/RaptorStaticConfig.java @@ -20,6 +20,10 @@ package ch.sbb.matsim.routing.pt.raptor; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup; +import org.matsim.api.core.v01.population.Person; +import org.matsim.facilities.Facility; +import org.matsim.pt.transitSchedule.api.TransitStopFacility; +import org.matsim.utils.objectattributes.attributable.Attributes; import java.util.HashMap; import java.util.Map; @@ -39,12 +43,12 @@ public class RaptorStaticConfig { public enum RaptorOptimization { /** * Use this option if you plan to calculate simple from-to routes - * (see {@link SwissRailRaptor#calcRoute(org.matsim.facilities.Facility, org.matsim.facilities.Facility, double, org.matsim.api.core.v01.population.Person)}). + * (see {@link SwissRailRaptor#calcRoute(Facility, Facility, double, double, double, Person, Attributes, RaptorRouteSelector)} */ OneToOneRouting, /** * Use this option if you plan to calculate one-to-all least-cost-path-trees - * (see {@link SwissRailRaptor#calcTree(org.matsim.pt.transitSchedule.api.TransitStopFacility, double, RaptorParameters)}). + * (see {@link SwissRailRaptor#calcTree(TransitStopFacility, double, RaptorParameters, Person)} ). */ OneToAllRouting } diff --git a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java index c4ae84b43ac..4d503c65362 100644 --- a/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/config/SwissRailRaptorConfigGroupTest.java @@ -23,10 +23,8 @@ import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.ModeMappingForPassengersParameterSet; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.RangeQuerySettingsParameterSet; import ch.sbb.matsim.config.SwissRailRaptorConfigGroup.RouteSelectorParameterSet; -import ch.sbb.matsim.routing.pt.raptor.RaptorStopFinder.Direction; - -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.matsim.api.core.v01.TransportMode; import org.matsim.core.config.Config; diff --git a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java index f39f64426b9..3c4c98419cf 100644 --- a/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java +++ b/matsim/src/test/java/ch/sbb/matsim/routing/pt/raptor/SwissRailRaptorTest.java @@ -36,8 +36,8 @@ import org.matsim.api.core.v01.population.PlanElement; import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; -import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.config.groups.RoutingConfigGroup; +import org.matsim.core.config.groups.ScoringConfigGroup.ModeParams; import org.matsim.core.population.routes.NetworkRoute; import org.matsim.core.population.routes.RouteUtils; import org.matsim.core.router.DefaultRoutingModules; @@ -53,20 +53,13 @@ import org.matsim.pt.router.TransitRouter; import org.matsim.pt.routes.TransitPassengerRoute; import org.matsim.pt.transitSchedule.TransitScheduleUtils; -import org.matsim.pt.transitSchedule.api.Departure; -import org.matsim.pt.transitSchedule.api.TransitLine; -import org.matsim.pt.transitSchedule.api.TransitRoute; -import org.matsim.pt.transitSchedule.api.TransitRouteStop; -import org.matsim.pt.transitSchedule.api.TransitSchedule; -import org.matsim.pt.transitSchedule.api.TransitScheduleFactory; -import org.matsim.pt.transitSchedule.api.TransitStopFacility; +import org.matsim.pt.transitSchedule.api.*; import org.matsim.testcases.MatsimTestUtils; import org.matsim.utils.objectattributes.attributable.AttributesImpl; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.function.Supplier; import static org.junit.jupiter.api.Assertions.*; @@ -499,7 +492,7 @@ void testCoordFarAway() { Fixture f = new Fixture(); f.init(); TransitRouter router = createTransitRouter(f.schedule, f.config, f.network); - double x = +42000; + double x = 42000; double x1 = -2000; List legs = router.calcRoute(DefaultRoutingRequest.withoutAttributes(new FakeFacility(new Coord(x1, 0)), new FakeFacility(new Coord(x, 0)), 5.5*3600, null)); // should map to stops A and I assertEquals(3, legs.size());