SkimMatrixFreightMultiKey

public class SkimMatrixFreightMultiKey implements SkimMatrixFreight

Skim matrix for storing inter-zonal travel times or costs (for freight vehicles).

Author:Milan Lovric

Constructors

SkimMatrixFreightMultiKey

public SkimMatrixFreightMultiKey()

SkimMatrixFreightMultiKey

public SkimMatrixFreightMultiKey(String fileName)

Constructor that reads freight skim matrix from an input csv file.

Parameters:
  • fileName – Path to the input file.
Throws:
  • IOException – if any.
  • FileNotFoundException – if any.

Methods

getAbsoluteDifference

public double getAbsoluteDifference(SkimMatrixFreight other)

Gets sum of absolute differences between elements of two matrices.

Parameters:
  • other – The other matrix.
Returns:

Sum of absolute differences.

getAverageCost

public double getAverageCost()

Gets average OD cost (ignores empty matrix cells).

Returns:Average cost.

getAverageCost

public double getAverageCost(FreightMatrix flows)

Gets average OD cost weighted by demand.

Parameters:
  • flows – The demand as an origin-destination matrix.
Returns:

Average cost.

getCost

public double getCost(int originZone, int destinationZone, int vehicleType)

Gets cost for a given origin-destination pair and a vehicle type.

Parameters:
  • originZone – Origin zone.
  • destinationZone – Destination zone.
  • vehicleType – Vehicle type.
Returns:

Origin-destination cost.

getKeySet

public Set<MultiKey> getKeySet()

Gets the keyset of the multimap.

Returns:Keyset.

printMatrix

public void printMatrix()

Prints the matrix.

printMatrixFormatted

public void printMatrixFormatted()

Prints the matrix as a formatted table.

printMatrixFormatted

public void printMatrixFormatted(String s)

Prints the matrix as a formatted table, with a print message.

Parameters:
  • s – Print message

saveMatrixFormatted

public void saveMatrixFormatted(String outputFile)

Saves the matrix into a csv file.

Parameters:
  • outputFile – Path to the output file.

setCost

public void setCost(int originZone, int destinationZone, int vehicleType, double cost)

Sets cost for a given origin-destination pair and a vehicle type.

Parameters:
  • originZone – Origin zone.
  • destinationZone – Destination zone.
  • vehicleType – Vehicle type.
  • cost – Origin-destination cost.