Package org.planit.cost.physical
Class BPRLinkTravelTimeCost
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.planit.assignment.TrafficAssignmentComponent<AbstractPhysicalCost>
-
- org.planit.cost.physical.AbstractPhysicalCost
-
- org.planit.cost.physical.BPRLinkTravelTimeCost
-
- All Implemented Interfaces:
Serializable,Comparable<Idable>,org.djutils.event.EventProducerInterface,Cost<MacroscopicLinkSegment>,PhysicalCost,InteractorAccessor,LinkVolumeAccessor,Idable
public class BPRLinkTravelTimeCost extends AbstractPhysicalCost implements LinkVolumeAccessor
Well known BPR link performance function to compute travel time cost on link segment based on flow and configuration parameters. An instance of this class is compatible with a single macroscopic physical network (layer)- Author:
- markr
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBPRLinkTravelTimeCost.BPRParametersInner class to store Map of alpha and beta parameters used in BPR function for each mode
-
Field Summary
Fields Modifier and Type Field Description protected BPRLinkTravelTimeCost.BPRParameters[]bprParametersPerLinkSegmentArray to store BPRParameters objects for each link segment to be used in calculateSegmentCost()static doubleDEFAULT_ALPHADefault alpha BPR parameter if not other information is availablestatic doubleDEFAULT_BETADefault beta BPR parameter if not other information is availableprotected Pair<Double,Double>defaultParametersDefault alpha and beta values for all linksprotected Map<MacroscopicLinkSegmentType,BPRLinkTravelTimeCost.BPRParameters>defaultParametersPerLinkSegmentTypeAndModeMap to store default alpha and beta values for each link type and modeprotected BPRLinkTravelTimeCost.BPRParametersdefaultParametersPerModeMap to store default alpha and beta values for each modeprotected double[][]freeFlowTravelTimePerLinkSegment2d Array to store free flow travel time for each [mode][link segment] to be used in calculateSegmentCost()protected LinkVolumeAccesseelinkVolumeAccesseeLink volume accessee object for this cost functionprotected MacroscopicPhysicalNetworknetworkLayerthe network layer the BPR is applied toprotected Map<MacroscopicLinkSegment,BPRLinkTravelTimeCost.BPRParameters>parametersPerLinkSegmentAndModeMap to store default alpha and beta values for a specific link segment-
Fields inherited from class org.planit.assignment.TrafficAssignmentComponent
id, tokenId, trafficComponentType
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
Fields inherited from interface org.planit.cost.physical.PhysicalCost
BPR
-
-
Constructor Summary
Constructors Constructor Description BPRLinkTravelTimeCost(IdGroupingToken groupId)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doublecomputeCostInHours(MacroscopicLinkSegment linkSegment, Mode mode, double flowPcuPerHour)BPR function computation fordoublegetSegmentCost(Mode mode, MacroscopicLinkSegment linkSegment)Return the travel time for the current link for a given mode If the input data are invalid, this method returns a negative value.voidinitialiseBeforeSimulation(InfrastructureNetwork network)Register the BPR cost parameter values on the PhysicalNetwork Call this method after all the calls to set the cost parameters have been madevoidpopulateWithCost(Mode mode, double[] costToFill)populate the cost array with the BPR link travel times for all link segments for the specified modevoidsetDefaultParameters(double alpha, double beta)Set the default alpha and beta valuesvoidsetDefaultParameters(Mode mode, double alpha, double beta)Set the default alpha and beta values for a modevoidsetDefaultParameters(MacroscopicLinkSegmentType macroscopicLinkSegmentType, Mode mode, double alpha, double beta)Set the default alpha and beta values for a given link type and modevoidsetLinkVolumeAccessee(LinkVolumeAccessee linkVolumeAccessee)we expect a link volume accessee to be provided by the environment.voidsetParameters(MacroscopicLinkSegment linkSegment, Mode mode, double alpha, double beta)Set the alpha and beta values for a given link segment and mode-
Methods inherited from class org.planit.assignment.TrafficAssignmentComponent
equals, getId, getIdGroupingToken, getSourceId, getTrafficComponentType, hashCode
-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, getEventTypesWithListeners, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.planit.utils.id.Idable
compareTo, idEquals, idHashCode
-
Methods inherited from interface org.planit.interactor.LinkVolumeAccessor
getCompatibleAccessee
-
-
-
-
Field Detail
-
networkLayer
protected MacroscopicPhysicalNetwork networkLayer
the network layer the BPR is applied to
-
linkVolumeAccessee
protected LinkVolumeAccessee linkVolumeAccessee
Link volume accessee object for this cost function
-
defaultParameters
protected Pair<Double,Double> defaultParameters
Default alpha and beta values for all links
-
defaultParametersPerMode
protected BPRLinkTravelTimeCost.BPRParameters defaultParametersPerMode
Map to store default alpha and beta values for each mode
-
defaultParametersPerLinkSegmentTypeAndMode
protected Map<MacroscopicLinkSegmentType,BPRLinkTravelTimeCost.BPRParameters> defaultParametersPerLinkSegmentTypeAndMode
Map to store default alpha and beta values for each link type and mode
-
parametersPerLinkSegmentAndMode
protected Map<MacroscopicLinkSegment,BPRLinkTravelTimeCost.BPRParameters> parametersPerLinkSegmentAndMode
Map to store default alpha and beta values for a specific link segment
-
bprParametersPerLinkSegment
protected BPRLinkTravelTimeCost.BPRParameters[] bprParametersPerLinkSegment
Array to store BPRParameters objects for each link segment to be used in calculateSegmentCost()
-
freeFlowTravelTimePerLinkSegment
protected double[][] freeFlowTravelTimePerLinkSegment
2d Array to store free flow travel time for each [mode][link segment] to be used in calculateSegmentCost()
-
DEFAULT_ALPHA
public static final double DEFAULT_ALPHA
Default alpha BPR parameter if not other information is available- See Also:
- Constant Field Values
-
DEFAULT_BETA
public static final double DEFAULT_BETA
Default beta BPR parameter if not other information is available- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BPRLinkTravelTimeCost
public BPRLinkTravelTimeCost(IdGroupingToken groupId)
Constructor- Parameters:
groupId- , contiguous id generation within this group for instances of this class
-
-
Method Detail
-
computeCostInHours
protected double computeCostInHours(MacroscopicLinkSegment linkSegment, Mode mode, double flowPcuPerHour)
BPR function computation for- Parameters:
linkSegment- the link segmentmode- given modeflowPcuPerHour- available flow- Returns:
- travel time in hours
-
setParameters
public void setParameters(MacroscopicLinkSegment linkSegment, Mode mode, double alpha, double beta)
Set the alpha and beta values for a given link segment and mode- Parameters:
linkSegment- the specified link segmentmode- specified mode typealpha- alpha valuebeta- beta value
-
setDefaultParameters
public void setDefaultParameters(Mode mode, double alpha, double beta)
Set the default alpha and beta values for a mode- Parameters:
mode- the specified mode typealpha- alpha valuebeta- beta value
-
setDefaultParameters
public void setDefaultParameters(MacroscopicLinkSegmentType macroscopicLinkSegmentType, Mode mode, double alpha, double beta)
Set the default alpha and beta values for a given link type and mode- Parameters:
macroscopicLinkSegmentType- the specified link typemode- the specified mode typealpha- alpha valuebeta- beta value
-
setDefaultParameters
public void setDefaultParameters(double alpha, double beta)Set the default alpha and beta values- Parameters:
alpha- alpha valuebeta- beta value
-
getSegmentCost
public double getSegmentCost(Mode mode, MacroscopicLinkSegment linkSegment) throws PlanItException
Return the travel time for the current link for a given mode If the input data are invalid, this method returns a negative value.- Specified by:
getSegmentCostin interfaceCost<MacroscopicLinkSegment>- Parameters:
mode- the current Mode of travellinkSegment- the current link segment- Returns:
- the travel time for the current link (in hours)
- Throws:
PlanItException- when cost cannot be computed
-
populateWithCost
public void populateWithCost(Mode mode, double[] costToFill) throws PlanItException
populate the cost array with the BPR link travel times for all link segments for the specified mode- Specified by:
populateWithCostin classAbstractPhysicalCost- Parameters:
mode- the mode to usecostToFill- the cost to populate (in hours)- Throws:
PlanItException- thrown if error
-
initialiseBeforeSimulation
public void initialiseBeforeSimulation(InfrastructureNetwork network) throws PlanItException
Register the BPR cost parameter values on the PhysicalNetwork Call this method after all the calls to set the cost parameters have been made- Specified by:
initialiseBeforeSimulationin classAbstractPhysicalCost- Parameters:
network- network object containing the updated parameter values- Throws:
PlanItException- thrown if error
-
setLinkVolumeAccessee
public void setLinkVolumeAccessee(LinkVolumeAccessee linkVolumeAccessee)
we expect a link volume accessee to be provided by the environment. This is our point of access- Specified by:
setLinkVolumeAccesseein interfaceLinkVolumeAccessor- Parameters:
linkVolumeAccessee- the accessee to extract link volumes from
-
-