Package org.goplanit.cost.physical
Class BPRLinkTravelTimeCost
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<AbstractPhysicalCost>
-
- org.goplanit.cost.physical.AbstractPhysicalCost
-
- org.goplanit.cost.physical.BPRLinkTravelTimeCost
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<IdAble>
,EventListener
,PlanitComponentListener
,Cost<MacroscopicLinkSegment>
,PhysicalCost
,InteractorAccessor<LinkVolumeAccessee>
,LinkVolumeAccessor
,EventListener
,ExternalIdAble
,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 class
BPRLinkTravelTimeCost.BPRParameters
Inner 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[]
bprParametersPerLinkSegment
Array to store BPRParameters objects for each link segment to be used in calculateSegmentCost()static double
DEFAULT_ALPHA
Default alpha BPR parameter if not other information is availablestatic double
DEFAULT_BETA
Default beta BPR parameter if not other information is availableprotected Pair<Double,Double>
defaultParameters
Default alpha and beta values for all linksprotected Map<MacroscopicLinkSegmentType,BPRLinkTravelTimeCost.BPRParameters>
defaultParametersPerLinkSegmentTypeAndMode
Map to store default alpha and beta values for each link type and modeprotected BPRLinkTravelTimeCost.BPRParameters
defaultParametersPerMode
Map to store default alpha and beta values for each modeprotected double[][]
freeFlowTravelTimePerLinkSegment
2d Array to store free flow travel time for each [mode][link segment] to be used in calculateSegmentCost()protected LinkVolumeAccessee
linkVolumeAccessee
Link volume accessee object for this cost functionprotected Map<MacroscopicLinkSegment,BPRLinkTravelTimeCost.BPRParameters>
parametersPerLinkSegmentAndMode
Map to store default alpha and beta values for a specific link segment-
Fields inherited from interface org.goplanit.cost.physical.PhysicalCost
BPR, FREEFLOW, STEADY_STATE
-
-
Constructor Summary
Constructors Constructor Description BPRLinkTravelTimeCost(BPRLinkTravelTimeCost bprLinkTravelTimeCost)
Copy ConstructorBPRLinkTravelTimeCost(IdGroupingToken groupId)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BPRLinkTravelTimeCost
clone()
Create a shallow copy of this entityprotected double
computeCostInHours(MacroscopicLinkSegment linkSegment, Mode mode, double flowPcuPerHour)
BPR function computation for.double
getDTravelTimeDFlow(boolean uncongested, Mode mode, MacroscopicLinkSegment linkSegment)
Get the first derivative of the used travel time computation method towards the edge segment (in) flow rate in PCU per hour, i.e.double
getGeneralisedCost(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.double
getTravelTimeCost(Mode mode, MacroscopicLinkSegment linkSegment)
Returns the generalised cost of travel along an edge segment for a specified modevoid
initialiseBeforeSimulation(TransportLayerNetwork<?,?> network)
Register the BPR cost parameter values on the PhysicalNetworkvoid
populateWithCost(UntypedPhysicalLayer<?,?,?> physicalLayer, Mode mode, double[] costToFill)
populate the cost array with the BPR link travel times for all link segments for the specified modevoid
reset()
return to pre-initialiseBeforeSimulation(TransportLayerNetwork)
statevoid
setAccessee(LinkVolumeAccessee linkVolumeAccessee)
we expect a link volume accessee to be provided by the environment.void
setDefaultParameters(double alpha, double beta)
Set the default alpha and beta valuesvoid
setDefaultParameters(Mode mode, double alpha, double beta)
Set the default alpha and beta values for a modevoid
setDefaultParameters(MacroscopicLinkSegmentType macroscopicLinkSegmentType, Mode mode, double alpha, double beta)
Set the default alpha and beta values for a given link type and modevoid
setParameters(MacroscopicLinkSegment linkSegment, Mode mode, double alpha, double beta)
Set the alpha and beta values for a given link segment and modevoid
updateTimePeriod(TimePeriod timePeriod)
Provide the cost calculation with information regarding the time period for which the cost is to be calculated-
Methods inherited from class org.goplanit.component.PlanitComponent
equals, getComponentType, getExternalId, getId, getIdGroupingToken, getKnownSupportedEventTypes, getXmlId, hashCode, onPlanitComponentEvent, setExternalId, setXmlId
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.goplanit.utils.event.EventListener
hasKnownSupportedEventTypes
-
Methods inherited from interface org.goplanit.utils.id.ExternalIdAble
hasExternalId, hasXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, idEquals, idHashCode
-
Methods inherited from interface org.goplanit.interactor.InteractorAccessor
setAccessee
-
Methods inherited from interface org.goplanit.interactor.LinkVolumeAccessor
getCompatibleAccessee
-
-
-
-
Field Detail
-
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
-
BPRLinkTravelTimeCost
public BPRLinkTravelTimeCost(BPRLinkTravelTimeCost bprLinkTravelTimeCost)
Copy Constructor- Parameters:
bprLinkTravelTimeCost
- to use
-
-
Method Detail
-
computeCostInHours
protected double computeCostInHours(MacroscopicLinkSegment linkSegment, Mode mode, double flowPcuPerHour)
BPR function computation for. In case mode is nto allowed Double.MAX_VALUE is returned- 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
-
initialiseBeforeSimulation
public void initialiseBeforeSimulation(TransportLayerNetwork<?,?> network) throws PlanItException
Register the BPR cost parameter values on the PhysicalNetwork- Specified by:
initialiseBeforeSimulation
in classAbstractPhysicalCost
- Parameters:
network
- network object containing the updated parameter values- Throws:
PlanItException
- thrown if error
-
updateTimePeriod
public void updateTimePeriod(TimePeriod timePeriod)
Provide the cost calculation with information regarding the time period for which the cost is to be calculated- Specified by:
updateTimePeriod
in classAbstractPhysicalCost
- Parameters:
timePeriod
- to apply
-
getGeneralisedCost
public double getGeneralisedCost(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.- Specified by:
getGeneralisedCost
in interfaceCost<MacroscopicLinkSegment>
- Parameters:
mode
- the current Mode of travellinkSegment
- the current link segment- Returns:
- the travel time for the current link (in hours)
-
getTravelTimeCost
public double getTravelTimeCost(Mode mode, MacroscopicLinkSegment linkSegment)
Returns the generalised cost of travel along an edge segment for a specified mode- Specified by:
getTravelTimeCost
in interfaceCost<MacroscopicLinkSegment>
- Parameters:
mode
- the specified mode of travellinkSegment
- the specified edge segment (which can be physical or virtual)- Returns:
- the cost of travel along the specified segment
-
getDTravelTimeDFlow
public double getDTravelTimeDFlow(boolean uncongested, Mode mode, MacroscopicLinkSegment linkSegment)
Get the first derivative of the used travel time computation method towards the edge segment (in) flow rate in PCU per hour, i.e. dTraveltime//dFlow.- Specified by:
getDTravelTimeDFlow
in interfaceCost<MacroscopicLinkSegment>
- Parameters:
uncongested
- flag idicating if the provided flow is uncongested or congested flow, relevant when flow can represent multiple traffic statesmode
- to uselinkSegment
- to use- Returns:
- the first derivative of travel time for a unit flow rate change in PCU per Hour
-
populateWithCost
public void populateWithCost(UntypedPhysicalLayer<?,?,?> physicalLayer, Mode mode, double[] costToFill) throws PlanItException
populate the cost array with the BPR link travel times for all link segments for the specified mode- Overrides:
populateWithCost
in classAbstractPhysicalCost
- Parameters:
mode
- the mode to usecostToFill
- the cost to populate (in hours)physicalLayer
- these cost pertain to- Throws:
PlanItException
- thrown if error
-
setAccessee
public void setAccessee(LinkVolumeAccessee linkVolumeAccessee)
we expect a link volume accessee to be provided by the environment. This is our point of access- Specified by:
setAccessee
in interfaceInteractorAccessor<LinkVolumeAccessee>
- Parameters:
linkVolumeAccessee
- the accessee to extract link volumes from
-
clone
public BPRLinkTravelTimeCost clone()
Create a shallow copy of this entity- Specified by:
clone
in interfaceIdAble
- Specified by:
clone
in classPlanitComponent<AbstractPhysicalCost>
- Returns:
- shallow copy of entity
-
reset
public void reset()
return to pre-initialiseBeforeSimulation(TransportLayerNetwork)
state- Specified by:
reset
in classPlanitComponent<AbstractPhysicalCost>
-
-