Skip to content

Commit

Permalink
Merge pull request #2824 from matsim-org/remove-fast-network-routers
Browse files Browse the repository at this point in the history
Remove fast network routers
  • Loading branch information
mrieser authored Oct 9, 2023
2 parents 4c62468 + 0438fc6 commit af7fc0e
Show file tree
Hide file tree
Showing 63 changed files with 671 additions and 1,564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.matsim.application.options.OutputOptions;
import org.matsim.application.options.ShpOptions;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.router.FastDijkstraFactory;
import org.matsim.core.router.costcalculators.OnlyTimeDependentTravelDisutility;
import org.matsim.core.router.speedy.SpeedyALTFactory;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.scenario.ProjectionUtils;
import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime;
Expand Down Expand Up @@ -156,7 +156,7 @@ public Integer call() throws Exception {

FreeSpeedTravelTime tt = new FreeSpeedTravelTime();
OnlyTimeDependentTravelDisutility util = new OnlyTimeDependentTravelDisutility(tt);
LeastCostPathCalculator router = new FastDijkstraFactory(false).createPathCalculator(network, util, tt);
LeastCostPathCalculator router = new SpeedyALTFactory().createPathCalculator(network, util, tt);

List<Route> routes = sampleRoutes(network, router, rnd);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import org.matsim.application.options.OutputOptions;
import org.matsim.core.api.experimental.events.EventsManager;
import org.matsim.core.events.EventsUtils;
import org.matsim.core.router.FastDijkstraFactory;
import org.matsim.core.router.costcalculators.OnlyTimeDependentTravelDisutility;
import org.matsim.core.router.speedy.SpeedyALTFactory;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelTime;
import org.matsim.core.trafficmonitoring.FreeSpeedTravelTime;
import org.matsim.core.trafficmonitoring.TravelTimeCalculator;
import org.matsim.core.utils.io.IOUtils;
import picocli.CommandLine;
import scala.util.parsing.combinator.testing.Str;
import tech.tablesaw.api.ColumnType;
import tech.tablesaw.api.DoubleColumn;
import tech.tablesaw.api.Row;
Expand Down Expand Up @@ -81,8 +80,8 @@ public Integer call() throws Exception {

OnlyTimeDependentTravelDisutility util = new OnlyTimeDependentTravelDisutility(tt);

LeastCostPathCalculator congestedRouter = new FastDijkstraFactory(false).createPathCalculator(network, util, tt);
LeastCostPathCalculator freeflowRouter = new FastDijkstraFactory(false).createPathCalculator(network, new OnlyTimeDependentTravelDisutility(fs), fs);
LeastCostPathCalculator congestedRouter = new SpeedyALTFactory().createPathCalculator(network, util, tt);
LeastCostPathCalculator freeflowRouter = new SpeedyALTFactory().createPathCalculator(network, new OnlyTimeDependentTravelDisutility(fs), fs);

data.addColumns(
DoubleColumn.create("simulated", data.rowCount()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<param name="outputDirectory" value="test/output/org/matsim/smallScaleCommercialTrafficGeneration/RunGenerateSmallScaleCommercialTrafficTest/testMainRunAndResults/" />
<!-- Possible values: failIfDirectoryExists, overwriteExistingFiles, deleteDirectoryIfExists -->
<param name="overwriteFiles" value="overwriteExistingFiles" />
<!-- The type of routing (least cost path) algorithm used, may have the values: [Dijkstra, AStarLandmarks, FastDijkstra, FastAStarLandmarks, SpeedyALT] -->
<!-- The type of routing (least cost path) algorithm used, may have the values: [Dijkstra, AStarLandmarks, SpeedyALT] -->
<param name="routingAlgorithmType" value="SpeedyALT" />
<!-- An identifier for the current run which is used as prefix for output files and mentioned in output xml files etc. -->
<param name="runId" value="test" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<param name="outputDirectory" value="output/commercialtraffictestrun"/>
<!-- Possible values: failIfDirectoryExists, overwriteExistingFiles, deleteDirectoryIfExists -->
<param name="overwriteFiles" value="deleteDirectoryIfExists"/>
<!-- The type of routing (least cost path) algorithm used, may have the values: Dijkstra, FastDijkstra, AStarLandmarks or FastAStarLandmarks -->
<!-- The type of routing (least cost path) algorithm used, may have the values: Dijkstra, FastDijkstra, SpeedyALT -->
<param name="routingAlgorithmType" value="AStarLandmarks"/>
<!-- An identifier for the current run which is used as prefix for output files and mentioned in output xml files etc. -->
<param name="runId" value="jointDemandUsingDRTExample"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.apache.logging.log4j.Logger;
import org.matsim.api.core.v01.network.Link;
import org.matsim.api.core.v01.network.Network;
import org.matsim.contrib.drt.extension.operations.DrtOperationsParams;
import org.matsim.contrib.drt.extension.operations.shifts.config.ShiftsParams;
import org.matsim.contrib.drt.extension.operations.shifts.fleet.ShiftDvrpVehicle;
import org.matsim.contrib.drt.extension.operations.shifts.schedule.*;
Expand All @@ -26,7 +25,7 @@
import org.matsim.contrib.dvrp.tracker.OnlineDriveTaskTracker;
import org.matsim.contrib.dvrp.util.LinkTimePair;
import org.matsim.core.mobsim.framework.MobsimTimer;
import org.matsim.core.router.FastAStarEuclideanFactory;
import org.matsim.core.router.speedy.SpeedyALTFactory;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelDisutility;
import org.matsim.core.router.util.TravelTime;
Expand Down Expand Up @@ -60,7 +59,7 @@ public ShiftTaskSchedulerImpl(Network network, TravelTime travelTime, TravelDisu
this.taskFactory = taskFactory;
this.network = network;
this.drtShiftParams = drtShiftParams;
this.router = new FastAStarEuclideanFactory().createPathCalculator(network, travelDisutility, travelTime);
this.router = new SpeedyALTFactory().createPathCalculator(network, travelDisutility, travelTime);

ShiftSchedules.initSchedules(operationFacilities, fleet, taskFactory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* *
* *********************************************************************** */

package org.matsim.pt.router;
package org.matsim.contrib.eventsBasedPTRouter;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -28,14 +28,16 @@
import org.matsim.core.router.InitialNode;
import org.matsim.core.router.util.LeastCostPathCalculator.Path;
import org.matsim.core.router.util.TravelTime;
import org.matsim.pt.router.TransitLeastCostPathTree;
import org.matsim.pt.router.TransitTravelDisutility;

public class MultiNodeDijkstra /*extends Dijkstra*/ {

/**
* The network on which we find routes.
*/
protected Network network;

/**
* The cost calculator. Provides the cost for each link and time step.
*/
Expand All @@ -45,7 +47,7 @@ public class MultiNodeDijkstra /*extends Dijkstra*/ {
* The travel time calculator. Provides the travel time for each link and time step.
*/
private final TravelTime timeFunction;

public MultiNodeDijkstra(final Network network, final TransitTravelDisutility costFunction, final TravelTime timeFunction) {
this.network = network;
this.costFunction = costFunction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.matsim.core.router.util.PreProcessDijkstra;
import org.matsim.core.utils.geometry.CoordUtils;
import org.matsim.facilities.Facility;
import org.matsim.pt.router.MultiNodeDijkstra;
import org.matsim.pt.router.TransitRouter;
import org.matsim.pt.router.TransitRouterConfig;
import org.matsim.pt.router.TransitRouterNetworkTravelTimeAndDisutility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* *
* *********************************************************************** */

package org.matsim.pt.router;
package org.matsim.contrib.eventsBasedPTRouter;

import static org.junit.Assert.*;

Expand All @@ -36,6 +36,8 @@
import org.matsim.core.router.InitialNode;
import org.matsim.core.router.util.LeastCostPathCalculator.Path;
import org.matsim.core.router.util.TravelTime;
import org.matsim.pt.router.CustomDataManager;
import org.matsim.pt.router.TransitTravelDisutility;
import org.matsim.vehicles.Vehicle;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.Person;
import org.matsim.contrib.freight.carrier.CarrierVehicle;
import org.matsim.core.router.FastDijkstraFactory;
import org.matsim.core.router.speedy.SpeedyALTFactory;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.LeastCostPathCalculator.Path;
import org.matsim.core.router.util.LeastCostPathCalculatorFactory;
Expand Down Expand Up @@ -369,7 +369,7 @@ public static Builder newInstance(Network network) {

private int timeSliceWidth = Integer.MAX_VALUE;

private LeastCostPathCalculatorFactory leastCostPathCalculatorFactory = (network, travelCosts, travelTimes) -> new FastDijkstraFactory().createPathCalculator(network, travelCosts, travelTime);
private LeastCostPathCalculatorFactory leastCostPathCalculatorFactory = (network, travelCosts, travelTimes) -> new SpeedyALTFactory().createPathCalculator(network, travelCosts, travelTime);

private VehicleTypeDependentRoadPricingCalculator roadPricingCalculator = new VehicleTypeDependentRoadPricingCalculator();

Expand Down Expand Up @@ -455,7 +455,7 @@ public Builder setFIFO(boolean isFIFO) {
* each thread a new LCPA is created with the same LCPA-factory. That is,
* memorizing data in the factory-obj might violate thread-safety.
* <p>
* By default, it use {@link FastDijkstraFactory}
* By default, it use {@link SpeedyALTFactory}
*
* @param {@link {@link LeastCostPathCalculatorFactory}
* @return this builder
Expand Down Expand Up @@ -548,7 +548,7 @@ public void addVehicleTypeSpecificCosts(String typeId, double fix, double perSec
private final VehicleTypeDependentRoadPricingCalculator roadPricingCalc;

/**
* by default sets the {@link FastDijkstraFactory}
* by default sets the {@link SpeedyALTFactory}
*/
private final LeastCostPathCalculatorFactory leastCostPathCalculatorFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.matsim.contrib.freight.controler.FreightUtils;
import org.matsim.core.replanning.GenericPlanStrategyImpl;
import org.matsim.core.replanning.selectors.BestPlanSelector;
import org.matsim.core.router.FastDijkstraFactory;
import org.matsim.core.router.speedy.SpeedyALTFactory;
import org.matsim.core.router.util.LeastCostPathCalculator;
import org.matsim.core.router.util.TravelDisutility;
import org.matsim.core.router.util.TravelTime;
Expand Down Expand Up @@ -57,7 +57,7 @@ private double disutility(double distance, double time) {
@Override
public CarrierStrategyManager get() {

final LeastCostPathCalculator router = new FastDijkstraFactory().createPathCalculator(network, new MyTravelCosts(travelTimes.get(TransportMode.car)), travelTimes.get(TransportMode.car));
final LeastCostPathCalculator router = new SpeedyALTFactory().createPathCalculator(network, new MyTravelCosts(travelTimes.get(TransportMode.car)), travelTimes.get(TransportMode.car));

GenericPlanStrategyImpl<CarrierPlan, Carrier> planStrat_reRoutePlan = new GenericPlanStrategyImpl<>( new BestPlanSelector<>() );
planStrat_reRoutePlan.addStrategyModule(new CarrierReRouteVehicles.Factory(router, network, travelTimes.get(TransportMode.car )).build() );
Expand Down
Loading

0 comments on commit af7fc0e

Please sign in to comment.