RouteSetGenerator

public class RouteSetGenerator

RouteSetGenerator can generate, save and read route sets for the route choice.

Author:Milan Lovric

Fields

INITIAL_ROUTE_CAPACITY

public static final int INITIAL_ROUTE_CAPACITY

INITIAL_ROUTE_SET_CAPACITY

public static final int INITIAL_ROUTE_SET_CAPACITY

Constructors

RouteSetGenerator

public RouteSetGenerator(RoadNetwork roadNetwork, Properties props)

Constructor for the route set generator.

Parameters:
  • roadNetwork – Road network.
  • props – Parameters from the config file.

Methods

addRoute

public void addRoute(Route route)

Adds a route to the route set.

Parameters:
  • route – Route to be added.

addRouteWithoutValidityCheck

public void addRouteWithoutValidityCheck(Route route)

Adds a route to the route set.

Parameters:
  • route – Route to be added.

calculateAllPathsizes

public void calculateAllPathsizes()

Calculates all pathsizes for all the route sets (expensive operation).

clearRoutes

public void clearRoutes()

Clears all stored routes.

generateRouteSetBetweenFreightZones

public void generateRouteSetBetweenFreightZones(int originFreightZone, int destinationFreightZone)

Generates routes between two freight zones. A freight zone can be either an LAD (<= 1032) or a point. Zone ID ranges from the BYFM DfT model:

  • England: 1 - 867
  • Wales: 901 - 922
  • Scotland: 1001 - 1032
  • Freight airports: 1111 - 1115
  • Major distribution centres: 1201 - 1256
  • Freight ports: 1301 - 1388
Parameters:
  • originFreightZone – Origin freight zone.
  • destinationFreightZone – Destination freight zone.

generateRouteSetBetweenFreightZones

public void generateRouteSetBetweenFreightZones(int originFreightZone, int destinationFreightZone, int topNodes)

Generates routes between two freight zones. A freight zone can be either an LAD (<= 1032) or a point. Zone ID ranges from the BYFM DfT model:

  • England: 1 - 867
  • Wales: 901 - 922
  • Scotland: 1001 - 1032
  • Freight airports: 1111 - 1115
  • Major distribution centres: 1201 - 1256
  • Freight ports: 1301 - 1388
Parameters:
  • originFreightZone – Origin freight zone.
  • destinationFreightZone – Destination freight zone.
  • topNodes – Number of topNodes to consider for inter-zonal routes.

generateRouteSetForFreightMatrix

public void generateRouteSetForFreightMatrix(FreightMatrix freightMatrix, int topNodes)

Generates routes for all non-zero OD flows in the freight OD matrix. Zone ID ranges from the BYFM DfT model:

Parameters:
  • freightMatrix – Freight matrix.
  • topNodes – Number of topNodes to consider for inter-zonal routes.

generateRouteSetForFreightMatrix

public void generateRouteSetForFreightMatrix(FreightMatrix freightMatrix, int sliceIndex, int sliceNumber)

Generates routes for a slice of the OD matrix (useful for cluster computing), for topNodes only. There might still be some overlap between the slices as some nodes (to which point freight zones are assigned appear again in LAD freight zones).

Parameters:
  • freightMatrix – Freight matrix.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).

generateRouteSetForFreightMatrix

public void generateRouteSetForFreightMatrix(FreightMatrix freightMatrix, int sliceIndex, int sliceNumber, int topNodes)

Generates routes for a slice of the OD matrix (useful for cluster computing), for topNodes only. There might still be some overlap between the slices as some nodes (to which point freight zones are assigned appear again in LAD freight zones).

Parameters:
  • freightMatrix – Freight matrix.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).
  • topNodes – Number of topNodes to consider for inter-zonal routes.

generateRouteSetForODMatrix

public void generateRouteSetForODMatrix(ODMatrixMultiKey matrix, int topNodes)

Generates routes for all non-zero OD flows in the OD matrix. For inter-zonal flows generates routes only between top N nodes.

Parameters:
  • matrix – Origin-destination matrix.
  • topNodes – Number of topNodes to consider for inter-zonal routes.

generateRouteSetForODMatrix

public void generateRouteSetForODMatrix(ODMatrixMultiKey matrix)

Generates routes for all non-zero OD flows in the OD matrix.

Parameters:
  • matrix – Origin-destination matrix.

generateRouteSetForODMatrix

public void generateRouteSetForODMatrix(ODMatrixMultiKey matrix, int sliceIndex, int sliceNumber, int topNodes)

Generates routes for a slice of the OD matrix (useful for cluster computing), for topNodes only

Parameters:
  • matrix – Origin-destination matrix.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).
  • topNodes – Number of topNodes to consider for inter-zonal routes.

generateRouteSetForODMatrix

public void generateRouteSetForODMatrix(ODMatrixMultiKey matrix, int sliceIndex, int sliceNumber)

Generates routes for a slice of the Tempro OD matrix (useful for cluster computing).

Parameters:
  • matrix – Origin-destination matrix.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).

generateRouteSetForODMatrixTempro

public void generateRouteSetForODMatrixTempro(ODMatrixMultiKey matrix, Zoning zoning)

Generates routes for all non-zero OD flows in the OD matrix.

Parameters:
  • matrix – Origin-destination matrix.
  • zoning – Tempro zoning system.

generateRouteSetForODMatrixTempro

public void generateRouteSetForODMatrixTempro(RealODMatrixTempro matrix, Zoning zoning, int sliceIndex, int sliceNumber)

Generates routes for a slice of the OD matrix (useful for cluster computing).

Parameters:
  • matrix – Origin-destination matrix.
  • zoning – Tempro zoning system.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).

generateRouteSetForODMatrixTemproDistanceBased

public void generateRouteSetForODMatrixTemproDistanceBased(RealODMatrixTempro matrix, Zoning zoning, int sliceIndex, int sliceNumber)

Generates routes for a slice of the OD matrix (useful for cluster computing). The number of routes increases the smaller the distance between two Tempro zones.

Parameters:
  • matrix – Origin-destination matrix.
  • zoning – Tempro zoning system.
  • sliceIndex – Index of the OD matrix slice for which to generate routes [1..N].
  • sliceNumber – Number of slices to divide matrix into (N).

generateRouteSetNodeToNode

public void generateRouteSetNodeToNode(int origin, int destination)

Generates a route set between two nodes (if it does not already exist in the route set).

Parameters:
  • origin – Origin node ID.
  • destination – Destination node ID.

generateRouteSetWithLinkElimination

public void generateRouteSetWithLinkElimination(int origin, int destination)

Generates a route set between two nodes using the link elimination method - It first finds the fastest path and then blocks each of its links and tries to find an alternative path.

Parameters:
  • origin – Origin node ID.
  • destination – Destination node ID.

generateRouteSetWithRandomLinkEliminationRestricted

public void generateRouteSetWithRandomLinkEliminationRestricted(int origin, int destination)

Generates a route set between two nodes using the random link elimination method - It first finds the fastest path and then blocks random links within the fastest path and tries to find an alternative path. The search is limited by the total number of path finding calls and the required number of generated paths.

Parameters:
  • origin – Origin node ID.
  • destination – Destination node ID.

generateRouteSetWithRandomLinkEliminationRestricted

public void generateRouteSetWithRandomLinkEliminationRestricted(int origin, int destination, int routeLimit, int generationLimit)

Generates a route set between two nodes using the random link elimination method - It first finds the fastest path and then blocks random links within the fastest path and tries to find an alternative path. The search is limited by the total number of path finding calls and the required number of generated paths.

Parameters:
  • origin – Origin node ID.
  • destination – Destination node ID.
  • routeLimit – Maximum allowed number of generated routes.
  • generationLimit – Number of generation trials to get a potentially new route.

generateRouteSetZoneToZone

public void generateRouteSetZoneToZone(String originLAD, String destinationLAD)

Generates routes between all combinations of nodes from two LAD zones

Parameters:
  • originLAD – Origin LAD.
  • destinationLAD – Destination LAD.

generateRouteSetZoneToZone

public void generateRouteSetZoneToZone(String originLAD, String destinationLAD, int topNodes)

Generates routes between top N nodes (sorted by gravitating population) from two LAD zones. If origin and destination LAD are the same (i.e., intra-zonal), then use all the nodes

Parameters:
  • originLAD – Origin LAD.
  • destinationLAD – Destination LAD.
  • topNodes – Number of top nodes within LAD to consider.

generateRouteSetZoneToZoneTempro

public void generateRouteSetZoneToZoneTempro(String originZone, String destinationZone, Zoning zoning)

Generates routes between the nearest nodes of two Tempro zones.

Parameters:
  • originZone – Origin Tempro zone.
  • destinationZone – Destination Tempro zone.
  • zoning – Tempro zoning system.

generateRouteSetZoneToZoneTemproDistanceBased

public void generateRouteSetZoneToZoneTemproDistanceBased(String originZone, String destinationZone, Zoning zoning)

Generates routes between the nearest nodes of two Tempro zones.

Parameters:
  • originZone – Origin Tempro zone.
  • destinationZone – Destination Tempro zone.
  • zoning – Tempro zoning system.

generateSingleNodeRoutes

public void generateSingleNodeRoutes()

Generates single nodes routes.

getNumberOfRouteSets

public int getNumberOfRouteSets()

Gets the numbers of route sets (OD pairs).

Returns:Number of route sets.

getNumberOfRoutes

public int getNumberOfRoutes()

Gets the total number of routes.

Returns:Number of routes.

getRoadNetwork

public RoadNetwork getRoadNetwork()

Getter method for the road network.

Returns:Road network.

getRouteSet

public RouteSet getRouteSet(int origin, int destination)

Getter method for a route set between a specific origin and a destination.

Parameters:
  • origin – Origin node ID.
  • destination – Destination node ID.
Returns:

Route set.

getStatistics

public String getStatistics()

Gets route set statistics in a string.

Returns:Route set statistics.

printChoiceSets

public void printChoiceSets()

Prints all route sets.

printStatistics

public void printStatistics()

Prints all route set statistics.

readRoutes

public void readRoutes(String fileName)

Reads route sets from a text file.

Parameters:
  • fileName – File name.

readRoutesBinary

public void readRoutesBinary(String fileName)

Reads route sets from a text file.

Parameters:
  • fileName – File name.

readRoutesBinaryGZIPpedWithoutValidityCheck

public void readRoutesBinaryGZIPpedWithoutValidityCheck(String fileName)

Reads route sets from a text file.

Parameters:
  • fileName – File name.

readRoutesBinaryShortWithoutValidityCheck

public void readRoutesBinaryShortWithoutValidityCheck(String fileName)

Reads route sets from a text file.

Parameters:
  • fileName – File name.

readRoutesBinaryWithoutValidityCheck

public void readRoutesBinaryWithoutValidityCheck(String fileName)

Reads route sets from a text file.

Parameters:
  • fileName – File name.

readRoutesWithoutValidityCheck

public void readRoutesWithoutValidityCheck(String fileName)

Reads route sets from a text file without checking whether the routes are valid.

Parameters:
  • fileName – File name.

removeRoutesWithEdge

public void removeRoutesWithEdge(int edgeID)

Removes all the routes that contain a given edge (used for disruption).

Parameters:
  • edgeID – Edge ID.

removeRoutesWithEdge

public void removeRoutesWithEdge(int edgeID, List<Route> removedRoutes)

Removes all the routes that contain a given edge and store in the list.

Parameters:
  • edgeID – Edge ID.
  • removedRoutes – List of removed routes.

saveRoutes

public void saveRoutes(String fileName, boolean append)

Saves all route sets into a text file.

Parameters:
  • fileName – File name.
  • append – Whether to append to an existing file.

saveRoutesBinary

public void saveRoutesBinary(String fileName, boolean append)

Saves all route sets into a binary file.

Parameters:
  • fileName – File name.
  • append – Whether to append to an existing file.

saveRoutesBinaryGZIPped

public void saveRoutesBinaryGZIPped(String fileName, boolean append)

Saves all route sets into a binary file.

Parameters:
  • fileName – File name.
  • append – Whether to append to an existing file.

saveRoutesBinaryShort

public void saveRoutesBinaryShort(String fileName, boolean append)

Saves all route sets into a binary file. It also uses unsigned short (2 Bytes, which has a max. value of 65535).

Parameters:
  • fileName – File name.
  • append – Whether to append to an existing file.