Class FundamentalDiagramComponent
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<FundamentalDiagramComponent>
-
- org.goplanit.supply.fundamentaldiagram.FundamentalDiagramComponent
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,EventListener
,PlanitComponentListener
,EventListener
,ExternalIdAble
,IdAble
- Direct Known Subclasses:
NewellFundamentalDiagramComponent
public abstract class FundamentalDiagramComponent extends PlanitComponent<FundamentalDiagramComponent> implements Serializable
Fundamental diagram traffic component. Here we track the relation between a macroscopic link segment and its fundamental diagram. To minimise memory usage only unique fundamental diagrams are retained based on their relaxed hash codes. IF a duplicate it registered it is simply discarded and the related link segment is attached to the already present fundamental diagram in the pool- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
RELAXED_HASH_CODE_SCALE
precision scale to apply for the relaxed hash code to compare fundamental diagrams on being identical regarding their floating point variables, where 6 equates to 6 decimals of precision
-
Constructor Summary
Constructors Constructor Description FundamentalDiagramComponent(FundamentalDiagramComponent other, boolean deepCopy)
Copy constructorFundamentalDiagramComponent(IdGroupingToken groupId)
Base constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description FundamentalDiagram[]
asLinkSegmentIndexedArray(MacroscopicLinkSegments linkSegments)
Method to collect all fundamental diagrams for the given link segments in a 1:1 fashion in a raw array based on the current setup of this component.abstract FundamentalDiagramComponent
deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possibleFundamentalDiagram
get(MacroscopicLinkSegment linkSegment)
Collect the fundamental diagram for the given link segment.FundamentalDiagram
get(MacroscopicLinkSegmentType linkSegmentType)
Collect the fundamental diagram for the given link segment type.PlanitComponentEventType[]
getKnownSupportedEventTypes()
The fundamental diagram component registers for the PopulateFundamentalDiagramEvent in order to initialise its default fundamental diagrams based on the network layer that it is created for.protected abstract void
initialiseDefaultFundamentalDiagramsForLayer(MacroscopicNetworkLayer parentNetworkLayer)
Initialise the default available fundamental diagrams for the layer the component is registered on.void
onPlanitComponentEvent(PlanitComponentEvent event)
Registered for PopulateFundamentalDiagramEvent which allows the component to initialise all the default available Fds based on the network layer it is registered for.protected FundamentalDiagram
register(MacroscopicLinkSegment linkSegment, FundamentalDiagram fundamentalDiagram)
Register the given fundamental diagram for the link segment.protected FundamentalDiagram
register(MacroscopicLinkSegmentType linkSegmentType, FundamentalDiagram fundamentalDiagram)
Register the given fundamental diagram for the link segment type.void
reset()
All components should be able to reset going back to some representative initial statevoid
setCapacityLinkSegmentPcuHourLane(MacroscopicLinkSegment linkSegment, double capacityPcuHourLane)
Set the capacity in pcu/h/lane to use for the Newell FD for a given link segment.void
setCapacityLinkSegmentTypePcuHourLane(MacroscopicLinkSegmentType linkSegmentType, double capacityPcuHourLane)
Set the capacity in pcu/h/lane to use for the Newell FD for a given link segment type.void
setMaximumDensityLinkSegmentPcuKmLane(MacroscopicLinkSegment linkSegment, double maxDensityPcuKmLane)
Set the maximum density in pcu/km/lane to use for the Newell FD for a given link segment.void
setMaximumDensityLinkSegmentTypePcuKmLane(MacroscopicLinkSegmentType linkSegmentType, double maxDensityPcuKmLane)
Set the maximum density in pcu/km/lane to use for the Newell FD for a given link segment type.abstract FundamentalDiagramComponent
shallowClone()
Create a shallow copy of this entity-
Methods inherited from class org.goplanit.component.PlanitComponent
collectSettingsAsKeyValueMap, equals, getComponentType, getExternalId, getId, getIdGroupingToken, getXmlId, hashCode, setExternalId, setXmlId
-
Methods inherited from class java.lang.Object
clone, 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
appendExternalId, appendExternalId, getIdsAsString, getSplitExternalId, getSplitExternalId, hasExternalId, hasXmlId, setXmlId
-
Methods inherited from interface org.goplanit.utils.id.IdAble
compareTo, idEquals, idHashCode
-
-
-
-
Field Detail
-
RELAXED_HASH_CODE_SCALE
public static final int RELAXED_HASH_CODE_SCALE
precision scale to apply for the relaxed hash code to compare fundamental diagrams on being identical regarding their floating point variables, where 6 equates to 6 decimals of precision- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FundamentalDiagramComponent
public FundamentalDiagramComponent(IdGroupingToken groupId)
Base constructor- Parameters:
groupId
- token
-
FundamentalDiagramComponent
public FundamentalDiagramComponent(FundamentalDiagramComponent other, boolean deepCopy)
Copy constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
initialiseDefaultFundamentalDiagramsForLayer
protected abstract void initialiseDefaultFundamentalDiagramsForLayer(MacroscopicNetworkLayer parentNetworkLayer)
Initialise the default available fundamental diagrams for the layer the component is registered on. This includes the fundamental diagrams for the link segment types and possible anomalies for links where the physical link segment characteristics would overrule the link segment type defaults- Parameters:
parentNetworkLayer
- to initialise default fundamental diagrams for
-
register
protected FundamentalDiagram register(MacroscopicLinkSegment linkSegment, FundamentalDiagram fundamentalDiagram)
Register the given fundamental diagram for the link segment. This overrules the fundamental diagram that would be used based on the link segment's type. In case there already exists an identical fundamental diagram (based on relaxed hashcode comparison), the link segment is assigned the already present fundamental diagram. The fundamental diagram used for the link segment is returned, which is either the passed in one, or an already present functionally identical version- Parameters:
linkSegment
- to usefundamentalDiagram
- to register- Returns:
- used Fd for the link segment, can be different (but functionally equivalent) if registered Fd was already present for another link segment
-
register
protected FundamentalDiagram register(MacroscopicLinkSegmentType linkSegmentType, FundamentalDiagram fundamentalDiagram)
Register the given fundamental diagram for the link segment type. In case there already exists an identical fundamental diagram (based on relaxed hashcode comparison), the link segment type is assigned the already present fundamental diagram. The fundamental diagram used for the link segment type is returned, which is either the passed in one, or an already present functionally identical version- Parameters:
linkSegmentType
- to usefundamentalDiagram
- to register- Returns:
- used Fd for the link segment type, can be different (but functionally equivalent) if registered Fd was already present for another link segment
-
get
public FundamentalDiagram get(MacroscopicLinkSegment linkSegment)
Collect the fundamental diagram for the given link segment.- Parameters:
linkSegment
- to collect fundamental diagram for- Returns:
- related fundamental diagram, null if not present
-
get
public FundamentalDiagram get(MacroscopicLinkSegmentType linkSegmentType)
Collect the fundamental diagram for the given link segment type.- Parameters:
linkSegmentType
- to collect fundamental diagram for- Returns:
- related fundamental diagram, null if not present
-
setCapacityLinkSegmentPcuHourLane
public void setCapacityLinkSegmentPcuHourLane(MacroscopicLinkSegment linkSegment, double capacityPcuHourLane)
Set the capacity in pcu/h/lane to use for the Newell FD for a given link segment. This only impacts the backward wave speed used to keep the FD viable.- Parameters:
linkSegment
- the specified link segmentcapacityPcuHourLane
- to use
-
setMaximumDensityLinkSegmentPcuKmLane
public void setMaximumDensityLinkSegmentPcuKmLane(MacroscopicLinkSegment linkSegment, double maxDensityPcuKmLane)
Set the maximum density in pcu/km/lane to use for the Newell FD for a given link segment. This only impacts the backward wave speed used to keep the FD viable. one to change the capacity.- Parameters:
linkSegment
- the specified link segmentmaxDensityPcuKmLane
- to use
-
setCapacityLinkSegmentTypePcuHourLane
public void setCapacityLinkSegmentTypePcuHourLane(MacroscopicLinkSegmentType linkSegmentType, double capacityPcuHourLane)
Set the capacity in pcu/h/lane to use for the Newell FD for a given link segment type. This only impacts the backward wave speed used to keep the FD viable.- Parameters:
linkSegmentType
- the specified link segment typecapacityPcuHourLane
- to use
-
setMaximumDensityLinkSegmentTypePcuKmLane
public void setMaximumDensityLinkSegmentTypePcuKmLane(MacroscopicLinkSegmentType linkSegmentType, double maxDensityPcuKmLane)
Set the maximum density in pcu/km/lane to use for the Newell FD for a given link segment type. This only impacts the backward wave speed used to keep the FD viable. one to change the capacity.- Parameters:
linkSegmentType
- the specified link segment typemaxDensityPcuKmLane
- to use
-
asLinkSegmentIndexedArray
public FundamentalDiagram[] asLinkSegmentIndexedArray(MacroscopicLinkSegments linkSegments)
Method to collect all fundamental diagrams for the given link segments in a 1:1 fashion in a raw array based on the current setup of this component. The returned array is indexed by the link segments linkSegmentId (not id). The returned array is a newly created array yet the fundamental diagrams contained in it are references to the fundamental diagrams registered on this component. Further, it is also assumed that the provided link segments are indeed the segments (and types) on which the registered fundamental diagrams on this component are based. If not, then this would result in undefined behaviour.- Parameters:
linkSegments
- to collect fundamental diagrams for- Returns:
- fundamental diagrams per link segment by linkSegmentId, if no fd is present, the entry remains null
-
reset
public void reset()
All components should be able to reset going back to some representative initial state- Specified by:
reset
in classPlanitComponent<FundamentalDiagramComponent>
-
getKnownSupportedEventTypes
public PlanitComponentEventType[] getKnownSupportedEventTypes()
The fundamental diagram component registers for the PopulateFundamentalDiagramEvent in order to initialise its default fundamental diagrams based on the network layer that it is created for. Further user or builder overrides, can alter these subsequently at a later stage- Specified by:
getKnownSupportedEventTypes
in interfaceEventListener
- Overrides:
getKnownSupportedEventTypes
in classPlanitComponent<FundamentalDiagramComponent>
- Returns:
- default supported event types (none)
-
onPlanitComponentEvent
public void onPlanitComponentEvent(PlanitComponentEvent event) throws PlanItException
Registered for PopulateFundamentalDiagramEvent which allows the component to initialise all the default available Fds based on the network layer it is registered for. Delegates toinitialiseDefaultFundamentalDiagramsForLayer(MacroscopicNetworkLayer)
for concrete derived implementations to execute- Specified by:
onPlanitComponentEvent
in interfacePlanitComponentListener
- Overrides:
onPlanitComponentEvent
in classPlanitComponent<FundamentalDiagramComponent>
- Parameters:
event
- the component is registered for- Throws:
PlanItException
- thrown if error during processing of event
-
shallowClone
public abstract FundamentalDiagramComponent shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in classPlanitComponent<FundamentalDiagramComponent>
- Returns:
- shallow copy of entity
-
deepClone
public abstract FundamentalDiagramComponent deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possible- Specified by:
deepClone
in interfaceIdAble
- Specified by:
deepClone
in classPlanitComponent<FundamentalDiagramComponent>
- Returns:
- deep copy of entity
-
-