Class TrafficAssignment

    • 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 copy
        deepCopy - 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)register
        register - 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 use
        component - 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 class PlanitComponent<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 period
        initialLinkSegmentCost - 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 interface TrafficAssignmentComponentAccessee
        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
      • 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 interface IdAble
        Specified by:
        deepClone in class NetworkLoading
        Returns:
        deep copy of entity