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 StringALGORITHM_Bshort hand to choose algorithmB as assignment typestatic StringELTMshort hand to choose eLTM as assignment typeprotected Map<TimePeriod,InitialModesLinkSegmentCost>initialLinkSegmentCostByTimePeriodThe initial link segment cost to use where the mapping is based on the user provided time period.protected InitialModesLinkSegmentCostinitialLinkSegmentCostTimePeriodAgnosticDefault initial costs to apply in case no time period specific costs are providedstatic StringSLTMshort hand to choose sLTM as assignment typestatic StringTRADITIONAL_STATIC_ASSIGNMENTshort hand to choose traditional static assignment as assignment type
-
Constructor Summary
Constructors Modifier Constructor Description protectedTrafficAssignment(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 voidcheckForEmptyComponents()Check if any components are undefined, if so throw exceptionprotected StringcreateLoggingPrefix(int iterationIndex)create the logging prefix for logging statements during equilibrationabstract OutputTypeAdaptercreateOutputTypeAdapter(OutputType outputType)Create the output type adapter for the current output type, specifically tailored towards the assignment type that we are builingprotected voidcreateTransportNetwork()Initialize the transport network by combining the physical and virtual componentsabstract TrafficAssignmentdeepClone()deep clone on planit component should attempt to also update internal dependencies between deep cloned containers where possibleprotected voiddisbandTransportNetwork()detach the virtual and physical transport network againvoidexecute()Execute assignment, including initializing resources, running equilibration and then closing resourcesprotected abstract voidexecuteEquilibration()Run equilibration after resources initialized, including saving resultsprotected voidfinalizeAfterExecution()Finalize all relevant traffic assignment components after execution of the assignment has endedDemandsgetDemands()Get the demands for the current assignmentGapFunctiongetGapFunction()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 intgetIterationIndex()Collect the current iteration index of the simulationprotected OutputManagergetOutputManager()Collect the output managerAbstractPhysicalCostgetPhysicalCost()Get the dynamic physical cost object for the current assignmentSmoothinggetSmoothing()Collect the smoothing object for the current traffic assignmentprotected intgetTotalNumberOfNetworkSegments()Total number of edge segments across the entire network and all layers (physical and virtual)protected intgetTotalNumberOfNetworkVertices()Total number of vertices across the entire network (physical and virtual) and all layers<T> TgetTrafficAssignmentComponent(Class<T> planitComponentClass)Collect the desired traffic assignment component by its class assuming it is available on the assignment.TransportModelNetworkgetTransportNetwork()Get the TransportNetwork used in the current assignmentAbstractVirtualCostgetVirtualCost()Returns the virtual cost object for the current assignmentZoninggetZoning()Get the zoning for the current assignmentprotected voidinitialiseBeforeExecution()Initialize all relevant traffic assignment components before execution of the assignment commencesvoidlogAllSettings()Log settings of this traffic assignmentprotected voidlogRegisteredComponentName(Object item, boolean register)log registering an item on this traffic assignmentprotected voidregisterComponent(Class<? extends PlanitComponent<?>> componentKey, PlanitComponent<?> component)Register a PLANit component on this assignmentvoidreset()All components should be able to reset going back to some representative initial statevoidsetDemands(Demands demands)Set the Demands object for the current assignmentvoidsetGapFunction(GapFunction gapfunction)Collect the gap function which is to be set by a derived class of TrafficAssignment via the initialiseDefaults() right after constructionvoidsetInfrastructureNetwork(TopologicalLayerNetwork<?,?> physicalNetwork)Set the physicalNetwork for the current assignmentvoidsetInitialLinkSegmentCost(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 registeredvoidsetInitialLinkSegmentCost(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).voidsetOutputManager(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 InteractorAccesseevoidsetSmoothing(Smoothing smoothing)Set the Smoothing object for the current assignmentvoidsetVirtualCost(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 InteractorAccesseevoidsetZoning(Zoning zoning)Set the zoning object for the current assignmentabstract TrafficAssignmentshallowClone()Create a shallow copy of this entityprotected abstract voidverifyComponentCompatibility()Verify if the create traffic assignment (sbu)components are compatible with each other and the created transport network.protected abstract voidverifyNetworkDemandZoningCompatibility()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 PlanItExceptionCheck if any components are undefined, if so throw exception- Throws:
PlanItException- thrown if any components are undefined
-
verifyComponentCompatibility
protected abstract void verifyComponentCompatibility() throws PlanItExceptionVerify 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 PlanItExceptionVerify 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 PlanItExceptionInitialize 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 PlanItExceptiondetach the virtual and physical transport network again- Throws:
PlanItException- thrown if there is an error
-
initialiseBeforeExecution
protected void initialiseBeforeExecution() throws PlanItExceptionInitialize 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 PlanItExceptionRun equilibration after resources initialized, including saving results- Throws:
PlanItException- thrown if there is an error
-
finalizeAfterExecution
protected void finalizeAfterExecution() throws PlanItExceptionFinalize 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 PlanItExceptionExecute 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:
resetin 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:
getTrafficAssignmentComponentin 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:
shallowClonein interfaceIdAble- Specified by:
shallowClonein 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:
deepClonein interfaceIdAble- Specified by:
deepClonein classNetworkLoading- Returns:
- deep copy of entity
-
-