Package org.goplanit.assignment
Class TrafficAssignment
- java.lang.Object
-
- org.goplanit.component.PlanitComponent<NetworkLoading>
-
- org.goplanit.supply.networkloading.NetworkLoading
-
- org.goplanit.assignment.TrafficAssignment
-
- All Implemented Interfaces:
Serializable
,Comparable<IdAble>
,EventListener
,PlanitComponentListener
,InteractorAccessee
,TrafficAssignmentComponentAccessee
,EventListener
,ExternalIdAble
,IdAble
- Direct Known Subclasses:
LtmAssignment
,StaticTrafficAssignment
public abstract class TrafficAssignment extends NetworkLoading implements TrafficAssignmentComponentAccessee
Traffic assignment class which simultaneously is responsible for the loading hence it is also considered as a traffic assignment component of this type- Author:
- markr
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALGORITHM_B
short hand to choose algorithmB as assignment typestatic String
ELTM
short hand to choose eLTM as assignment typeprotected Map<TimePeriod,InitialModesLinkSegmentCost>
initialLinkSegmentCostByTimePeriod
The initial link segment cost to use where the mapping is based on the user provided time period.protected InitialModesLinkSegmentCost
initialLinkSegmentCostTimePeriodAgnostic
Default initial costs to apply in case no time period specific costs are providedstatic String
SLTM
short hand to choose sLTM as assignment typestatic String
TRADITIONAL_STATIC_ASSIGNMENT
short hand to choose traditional static assignment as assignment type
-
Constructor Summary
Constructors Modifier Constructor Description protected
TrafficAssignment(TrafficAssignment other, boolean deepCopy)
Copy ConstructorTrafficAssignment(IdGroupingToken groupId)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
checkForEmptyComponents()
Check if any components are undefined, if so throw exceptionprotected String
createLoggingPrefix(int iterationIndex)
create the logging prefix for logging statements during equilibrationabstract OutputTypeAdapter
createOutputTypeAdapter(OutputType outputType)
Create the output type adapter for the current output type, specifically tailored towards the assignment type that we are builingprotected void
createTransportNetwork()
Initialize the transport network by combining the physical and virtual componentsabstract TrafficAssignment
deepClone()
deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possibleprotected void
disbandTransportNetwork()
detach the virtual and physical transport network againvoid
execute()
Execute assignment, including initializing resources, running equilibration and then closing resourcesprotected abstract void
executeEquilibration()
Run equilibration after resources initialized, including saving resultsprotected void
finalizeAfterExecution()
Finalize all relevant traffic assignment components after execution of the assignment has endedDemands
getDemands()
Get the demands for the current assignmentGapFunction
getGapFunction()
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after constructionTopologicalLayerNetwork<?,?>
getInfrastructureNetwork()
Get the physical network for the current assignmentabstract int
getIterationIndex()
Collect the current iteration index of the simulationprotected OutputManager
getOutputManager()
Collect the output managerAbstractPhysicalCost
getPhysicalCost()
Get the dynamic physical cost object for the current assignmentSmoothing
getSmoothing()
Collect the smoothing object for the current traffic assignmentprotected int
getTotalNumberOfNetworkSegments()
Total number of edge segments across the entire network and all layers (physical and virtual)protected int
getTotalNumberOfNetworkVertices()
Total number of vertices across the entire network (physical and virtual) and all layers<T> T
getTrafficAssignmentComponent(Class<T> planitComponentClass)
Collect the desired traffic assignment component by its class assuming it is available on the assignment.TransportModelNetwork
getTransportNetwork()
Get the TransportNetwork used in the current assignmentAbstractVirtualCost
getVirtualCost()
Returns the virtual cost object for the current assignmentZoning
getZoning()
Get the zoning for the current assignmentprotected void
initialiseBeforeExecution()
Initialize all relevant traffic assignment components before execution of the assignment commencesvoid
logAllSettings()
Log settings of this traffic assignmentprotected void
logRegisteredComponentName(Object item, boolean register)
log registering an item on this traffic assignmentprotected void
registerComponent(Class<? extends PlanitComponent<?>> componentKey, PlanitComponent<?> component)
Register a PLANit component on this assignmentvoid
reset()
All components should be able to reset going back to some representative initial statevoid
setDemands(Demands demands)
Set the Demands object for the current assignmentvoid
setGapFunction(GapFunction gapfunction)
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after constructionvoid
setInfrastructureNetwork(TopologicalLayerNetwork<?,?> physicalNetwork)
Set the physicalNetwork for the current assignmentvoid
setInitialLinkSegmentCost(InitialModesLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost that is mode agnostic and can be used as the fallback if no time period specific initial cost is registeredvoid
setInitialLinkSegmentCost(TimePeriod timePeriod, InitialModesLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost for a specified time period on the assignment, otherwise revert to the general initial link segment cost (if any).void
setOutputManager(OutputManager outputManager)
Set the output manager which holds all the configuration options regarding this assignment<LS extends MacroscopicLinkSegment>
voidsetPhysicalCost(AbstractPhysicalCost physicalCost)
Set the physical cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccesseevoid
setSmoothing(Smoothing smoothing)
Set the Smoothing object for the current assignmentvoid
setVirtualCost(AbstractVirtualCost virtualCost)
Set the virtual cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccesseevoid
setZoning(Zoning zoning)
Set the zoning object for the current assignmentabstract TrafficAssignment
shallowClone()
Create a shallow copy of this entityprotected abstract void
verifyComponentCompatibility()
Verify if the create traffic assignment (sbu)components are compatible with each other and the created transport network.protected abstract void
verifyNetworkDemandZoningCompatibility()
Verify if the traffic assignment inputs (components which are provided upon creation and not subcomponents that are created as part of the build process of the assignment are compatible).-
Methods inherited from class org.goplanit.component.PlanitComponent
collectSettingsAsKeyValueMap, equals, getComponentType, getExternalId, getId, getIdGroupingToken, getKnownSupportedEventTypes, getXmlId, hashCode, onPlanitComponentEvent, 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
-
Methods inherited from interface org.goplanit.interactor.InteractorAccessee
getCompatibleAccessor
-
-
-
-
Field Detail
-
initialLinkSegmentCostByTimePeriod
protected Map<TimePeriod,InitialModesLinkSegmentCost> initialLinkSegmentCostByTimePeriod
The initial link segment cost to use where the mapping is based on the user provided time period. Note that the registered InitialLinkSegmentCostMode is part of another registered initialCost that is present on the project. However, a user might have decided that while they were parsed under one time period, to apply them on the assignment in another time period. Hence, we only track the initialcosts themselves and not their original parsed time periods nor their umbrella instance
-
initialLinkSegmentCostTimePeriodAgnostic
protected InitialModesLinkSegmentCost initialLinkSegmentCostTimePeriodAgnostic
Default initial costs to apply in case no time period specific costs are provided
-
TRADITIONAL_STATIC_ASSIGNMENT
public static String TRADITIONAL_STATIC_ASSIGNMENT
short hand to choose traditional static assignment as assignment type
-
ALGORITHM_B
public static String ALGORITHM_B
short hand to choose algorithmB as assignment type
-
ELTM
public static String ELTM
short hand to choose eLTM as assignment type
-
SLTM
public static String SLTM
short hand to choose sLTM as assignment type
-
-
Constructor Detail
-
TrafficAssignment
public TrafficAssignment(IdGroupingToken groupId)
Constructor. Note that defaults that partly depend on derived classes are assumed to be invoked by the calling method via this.initialiseDefaults()- Parameters:
groupId
- contiguous id generation within this group for instances of this class
-
TrafficAssignment
protected TrafficAssignment(TrafficAssignment other, boolean deepCopy)
Copy Constructor- Parameters:
other
- to copydeepCopy
- when true, create a deep copy, shallow copy otherwise
-
-
Method Detail
-
createLoggingPrefix
protected String createLoggingPrefix(int iterationIndex)
create the logging prefix for logging statements during equilibration- Parameters:
iterationIndex
- the iteration- Returns:
- prefix for logging of traffic assignment messages
-
checkForEmptyComponents
protected void checkForEmptyComponents() throws PlanItException
Check if any components are undefined, if so throw exception- Throws:
PlanItException
- thrown if any components are undefined
-
verifyComponentCompatibility
protected abstract void verifyComponentCompatibility() throws PlanItException
Verify if the create traffic assignment (sbu)components are compatible with each other and the created transport network. Called before starting the simulation and after the transport network has been generated from physical and virtual network. So this is called after the build of the assignment instance- Throws:
PlanItException
- thrown if the components are not compatible
-
verifyNetworkDemandZoningCompatibility
protected abstract void verifyNetworkDemandZoningCompatibility() throws PlanItException
Verify if the traffic assignment inputs (components which are provided upon creation and not subcomponents that are created as part of the build process of the assignment are compatible). Called after creation of the assignment instance by the builder, but before the traffic assignment's (sub)components have been created. So this is invoked during the build of the assignment instance, not after.- Throws:
PlanItException
- thrown if the components are not compatible
-
createTransportNetwork
protected void createTransportNetwork() throws PlanItException
Initialize the transport network by combining the physical and virtual components- Throws:
PlanItException
- thrown if there is an error
-
getTotalNumberOfNetworkSegments
protected int getTotalNumberOfNetworkSegments()
Total number of edge segments across the entire network and all layers (physical and virtual)- Returns:
- Total number of edge segments across the entire network and all layers
-
getTotalNumberOfNetworkVertices
protected int getTotalNumberOfNetworkVertices()
Total number of vertices across the entire network (physical and virtual) and all layers- Returns:
- Total number of vertices across the entire network and all layers
-
disbandTransportNetwork
protected void disbandTransportNetwork() throws PlanItException
detach the virtual and physical transport network again- Throws:
PlanItException
- thrown if there is an error
-
initialiseBeforeExecution
protected void initialiseBeforeExecution() throws PlanItException
Initialize all relevant traffic assignment components before execution of the assignment commences- Throws:
PlanItException
- thrown if there is an error
-
executeEquilibration
protected abstract void executeEquilibration() throws PlanItException
Run equilibration after resources initialized, including saving results- Throws:
PlanItException
- thrown if there is an error
-
finalizeAfterExecution
protected void finalizeAfterExecution() throws PlanItException
Finalize all relevant traffic assignment components after execution of the assignment has ended- Throws:
PlanItException
- thrown if there is an error
-
getOutputManager
protected OutputManager getOutputManager()
Collect the output manager- Returns:
- output manager for this assignment
-
logRegisteredComponentName
protected void logRegisteredComponentName(Object item, boolean register)
log registering an item on this traffic assignment- Parameters:
item
- to (un)registerregister
- when true it signals activate, otherwise deactivate
-
registerComponent
protected void registerComponent(Class<? extends PlanitComponent<?>> componentKey, PlanitComponent<?> component)
Register a PLANit component on this assignment- Parameters:
componentKey
- to usecomponent
- to register
-
getIterationIndex
public abstract int getIterationIndex()
Collect the current iteration index of the simulation- Returns:
- current iteration index
-
createOutputTypeAdapter
public abstract OutputTypeAdapter createOutputTypeAdapter(OutputType outputType)
Create the output type adapter for the current output type, specifically tailored towards the assignment type that we are builing- Parameters:
outputType
- the current output type- Returns:
- the output type adapter corresponding to the current traffic assignment and output type
-
execute
public void execute() throws PlanItException
Execute assignment, including initializing resources, running equilibration and then closing resources- Throws:
PlanItException
- thrown if there is an error
-
logAllSettings
public void logAllSettings()
Log settings of this traffic assignment
-
reset
public void reset()
All components should be able to reset going back to some representative initial state- Specified by:
reset
in classPlanitComponent<NetworkLoading>
-
getTransportNetwork
public TransportModelNetwork getTransportNetwork()
Get the TransportNetwork used in the current assignment- Returns:
- TransportNetwork used in current assignment
-
setInfrastructureNetwork
public void setInfrastructureNetwork(TopologicalLayerNetwork<?,?> physicalNetwork)
Set the physicalNetwork for the current assignment- Parameters:
physicalNetwork
- the network object for the current assignment
-
getInfrastructureNetwork
public TopologicalLayerNetwork<?,?> getInfrastructureNetwork()
Get the physical network for the current assignment- Returns:
- physical network for the current assignment
-
getDemands
public Demands getDemands()
Get the demands for the current assignment- Returns:
- demands for the current assignment
-
setDemands
public void setDemands(Demands demands)
Set the Demands object for the current assignment- Parameters:
demands
- the Demands object for the current assignment
-
getZoning
public Zoning getZoning()
Get the zoning for the current assignment- Returns:
- zoning for the current assignment
-
setZoning
public void setZoning(Zoning zoning)
Set the zoning object for the current assignment- Parameters:
zoning
- the Zoning object for the current assignment
-
setSmoothing
public void setSmoothing(Smoothing smoothing)
Set the Smoothing object for the current assignment- Parameters:
smoothing
- Smoothing object for the current assignment
-
getSmoothing
public Smoothing getSmoothing()
Collect the smoothing object for the current traffic assignment- Returns:
- smoothing
-
setGapFunction
public void setGapFunction(GapFunction gapfunction)
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after construction- Parameters:
gapfunction
- the gap function to set
-
getGapFunction
public GapFunction getGapFunction()
Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after construction- Returns:
- gapFunction
-
setInitialLinkSegmentCost
public void setInitialLinkSegmentCost(InitialModesLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost that is mode agnostic and can be used as the fallback if no time period specific initial cost is registered- Parameters:
initialLinkSegmentCost
- the initial link segment cost
-
setInitialLinkSegmentCost
public void setInitialLinkSegmentCost(TimePeriod timePeriod, InitialModesLinkSegmentCost initialLinkSegmentCost)
Set the initial link segment cost for a specified time period on the assignment, otherwise revert to the general initial link segment cost (if any). Note thta the provided time period might differ from the how the provided initial costs were parsed on the project if so desired.- Parameters:
timePeriod
- the specified time periodinitialLinkSegmentCost
- the initial link segment cost to apply for the assignment time period
-
setPhysicalCost
public <LS extends MacroscopicLinkSegment> void setPhysicalCost(AbstractPhysicalCost physicalCost)
Set the physical cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccessee- Type Parameters:
LS
- type of link segment- Parameters:
physicalCost
- the physical cost object for the current assignment
-
getPhysicalCost
public AbstractPhysicalCost getPhysicalCost()
Get the dynamic physical cost object for the current assignment- Returns:
- the physical cost object for the current assignment
-
getVirtualCost
public AbstractVirtualCost getVirtualCost()
Returns the virtual cost object for the current assignment- Returns:
- the virtual cost object for the current assignments
-
setVirtualCost
public void setVirtualCost(AbstractVirtualCost virtualCost) throws PlanItException
Set the virtual cost where in case the cost is an InteractorAccessor will trigger an event to get access to the required data via requesting an InteractorAccessee- Parameters:
virtualCost
- the virtual cost object to be assigned- Throws:
PlanItException
- thrown if there is an error
-
getTrafficAssignmentComponent
public <T> T getTrafficAssignmentComponent(Class<T> planitComponentClass)
Collect the desired traffic assignment component by its class assuming it is available on the assignment. These are traffic assignment components that are created and registered upon the assignment, so not component inputs that are readily available upon creation, but components specific to the assignment itself. Derived assignments might also register additional components as well beyond the standard components registered here on the base class (gapfunction, smoothing, physical, virtual cost).- Specified by:
getTrafficAssignmentComponent
in interfaceTrafficAssignmentComponentAccessee
- Type Parameters:
T
- component type- Parameters:
planitComponentClass
- to collect of type T- Returns:
- component, null if not available
-
setOutputManager
public void setOutputManager(OutputManager outputManager)
Set the output manager which holds all the configuration options regarding this assignment- Parameters:
outputManager
- to set
-
shallowClone
public abstract TrafficAssignment shallowClone()
Create a shallow copy of this entity- Specified by:
shallowClone
in interfaceIdAble
- Specified by:
shallowClone
in classNetworkLoading
- Returns:
- shallow copy of entity
-
deepClone
public abstract TrafficAssignment 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 classNetworkLoading
- Returns:
- deep copy of entity
-
-