Trip

public class Trip

This class stores information about a performed trip.

Author:Milan Lovric

Fields

destination

protected int destination

engine

protected EngineType engine

hour

protected TimeOfDay hour

multiplier

protected int multiplier

origin

protected int origin

route

protected Route route

vehicle

protected VehicleType vehicle

Constructors

Trip

public Trip(VehicleType vehicle, EngineType engine, Route route, TimeOfDay hour, Integer origin, Integer destination)

Constructor for an LAD-based trip. Origin and destination fields are used for freight trips (according to DfT’s BYFM zonal coding). Origin and destination for passenger car/AV trips are 0 as their correct origin and destination LAD zone can be obtained using the first and the last node of the route.

Parameters:
  • vehicle – Vehicle type.
  • engine – Engine type.
  • route – Route.
  • hour – Time of day.
  • origin – Origin zone for freight trips (null for passenger trips).
  • destination – Destination zone for freight trips (null for passenger trips).

Trip

public Trip(VehicleType vehicle, EngineType engine, Route route, TimeOfDay hour, Integer origin, Integer destination, int multiplier)

Constructor for a trip. Origin and destination are used for freight trips (according to DfT’s BYFM zonal coding). Origin and destination for passenger car/AV trips are 0 as their correct origin and destination LAD zone can be obtained using the first and the last node of the route. Multiplier is used to store multiple instances of the same trip (vs creating multiple objects), thus reducing the memory footprint.

Parameters:
  • vehicle – Vehicle type.
  • engine – Engine type.
  • route – Route.
  • hour – Time of day.
  • origin – Origin zone for freight trips (null for passenger trips).
  • destination – Destination zone for freight trips (null for passenger trips).
  • multiplier – Multiplies the same trip.

Methods

getAccessEgressConsumption

protected Map<EnergyType, Double> getAccessEgressConsumption(double[] linkTravelTime, double[] averageAccessEgressMap, double averageAccessEgressSpeed, Map<VehicleType, Map<EngineType, Map<WebTAG, Double>>> energyConsumptionParameters, Map<VehicleType, Map<EngineType, Double>> relativeFuelEfficiency)

Calculate trip consumption only on access and egress.

Parameters:
  • linkTravelTime
  • averageAccessEgressMap
  • averageAccessEgressSpeed
  • energyConsumptions
  • relativeFuelEfficiency
Returns:

Trip consumptions.

getCO2emission

public Double getCO2emission(double[] linkTravelTime, double[] averageAccessEgressMap, double averageAccessEgressSpeed, Map<VehicleType, Map<EngineType, Map<WebTAG, Double>>> energyConsumptionParameters, Map<VehicleType, Map<EngineType, Double>> relativeFuelEfficiency, Map<EnergyType, Double> unitCO2Emissions, boolean flagIncludeAccessEgress)

Calculates total CO2 emission for the trip.

Parameters:
  • linkTravelTime – Link travel time.
  • averageAccessEgressMap – Average access/egress distance to a node for LAD-based trips.
  • averageAccessEgressSpeed – Average accces/egress speed.
  • energyConsumptionParameters – Energy consumption parameters.
  • relativeFuelEfficiency – Relative fuel efficiency.
  • unitCO2Emissions – Unit CO2 emissions.
  • boolean – flagIncludeAccessEgress Whether to include access/egress.
Returns:

CO2 emissions per energy type.

getConsumption

public Map<EnergyType, Double> getConsumption(double[] linkTravelTime, double[] averageAccessEgressMap, double averageAccessEgressSpeed, Map<VehicleType, Map<EngineType, Map<WebTAG, Double>>> energyConsumptionParameters, Map<VehicleType, Map<EngineType, Double>> relativeFuelEfficiency, boolean flagIncludeAccessEgress)

Calculate trip consumption including access and egress.

Parameters:
  • linkTravelTime – Link travel time.
  • averageAccessEgressMap – Average access/egress distance to a node for LAD-based trips.
  • averageAccessEgressSpeed – Average acess/egress speed.
  • energyConsumptionParameters – Energy consumption parameters.
  • relativeFuelEfficiency – Relative fuel efficiency.
  • boolean – flagIncludeAccessEgress Whether to include access/egress.
Returns:

Trip consumptions.

getCost

public double getCost(double[] linkTravelTime, double[] averageAccessEgressMap, double averageAccessEgressSpeed, Map<EnergyType, Double> energyUnitCosts, Map<VehicleType, Map<EngineType, Map<WebTAG, Double>>> energyConsumptionParameters, Map<VehicleType, Map<EngineType, Double>> relativeFuelEfficiency, List<PricingPolicy> congestionCharges, boolean flagIncludeAccessEgress)

Calculate cost of the trip (fuel cost + congestion charge, if any).

Parameters:
  • linkTravelTime – Link travel time.
  • averageAccessEgressMap – Average access/egress distance to a node for LAD-based trips.
  • averageAccessEgressSpeed – Average access/egress speed.
  • energyUnitCosts – Energy unit costs.
  • energyConsumptionParameters – Energy consumption parameters.
  • relativeFuelEfficiency – Relative fuel efficiency.
  • congestionCharges – Congestion charges.
  • boolean – flagIncludeAccessEgress Whether to include access/egress.
Returns:

Total trip cost.

getDestination

public int getDestination()

Gets freight trip destination zone (using DfT BYFM zone coding).

Returns:Freight trip destination zone.

getDestinationLAD

public String getDestinationLAD(Map<Integer, String> nodeToZoneMap)

Gets trip destination zone (LAD).

Parameters:
  • nodeToZoneMap – Mapping from nodes to zones.
Returns:

Trip destination zone.

getDestinationLadID

public int getDestinationLadID()

Gets trip destination LAD zone ID.

Returns:Trip destination zone LAD ID.

getDestinationNode

public DirectedNode getDestinationNode()

Gets the trip destination node.

Returns:Destination node.

getEngine

public EngineType getEngine()

Getter method for engine type.

Returns:Vehicle engine type.

getLength

public double getLength(double[] averageAccessEgressMap)

Get trip length including access/egress.

Parameters:
  • averageAccessEgressMap – Mapping between nodeID and average access/egress for that node.
Returns:

Trip length including access/egress [in km]

getMultiplier

public int getMultiplier()

Getter method for the multiplier.

Returns:Multiplier.

getOrigin

public int getOrigin()

Gets freight trip origin zone (using DfT BYFM zone coding).

Returns:Freight trip origin zone.

getOriginLAD

public String getOriginLAD(Map<Integer, String> nodeToZoneMap)

Gets trip origin zone (LAD).

Parameters:
  • nodeToZoneMap – Mapping from nodes to zones.
Returns:

Trip origin zone.

getOriginLadID

public int getOriginLadID()

Gets trip origin LAD zone ID.

Returns:Origin zone LAD ID.

getOriginNode

public DirectedNode getOriginNode()

Gets the trip origin node.

Returns:Origin node.

getRoute

public Route getRoute()

Getter method for the route.

Returns:Route.

getTimeOfDay

public TimeOfDay getTimeOfDay()

Getter method for the time of day.

Returns:Time of day.

getTravelTime

public double getTravelTime(double[] linkTravelTime, double avgIntersectionDelay, double[] averageAccessEgressMap, double averageAccessEgressSpeed, boolean flagIncludeAccessEgress)

Calculates travel time including access/egress.

Parameters:
  • linkTravelTime – Link-based travel time (should be for the same hour as the trip’s time of day).
  • avgIntersectionDelay – Average intersection delay.
  • averageAccessEgressMap – Mapping between nodeID and average access/egress for that node.
  • averageAccessEgressSpeed – Average access/egress speed.
  • flagIncludeAccessEgress – Whether to include access/egress travel time.
Returns:

Trip travel time including access/egress [in min].

getVehicle

public VehicleType getVehicle()

Getter method for vehicle type.

Returns:Vehicle type.

isTripGoingThroughCongestionChargingZone

public boolean isTripGoingThroughCongestionChargingZone(String policyName, List<PricingPolicy> congestionCharges)

Check whether trip is going through a congestion charging zone for a particular policy.

Parameters:
  • policyName – Policy name.
  • congestionCharges – Congestion charges.
Returns:

True if it is going through the congestion charging zone.

toString

public String toString()