Class TrafficAssignment

    • Field Detail

      • trafficAssignmentBuilder

        protected TrafficAssignmentBuilder trafficAssignmentBuilder
        The builder for all traffic assignment instances
      • physicalNetwork

        protected PhysicalNetwork physicalNetwork
        Physical network to use
      • outputManager

        protected OutputManager outputManager
        Output manager deals with all the output configurations for the registered traffic assignments
      • transportNetwork

        protected TransportNetwork transportNetwork
        The transport network to use which is an adaptor around the physical network and the zoning
      • virtualCost

        protected VirtualCost virtualCost
        The virtual cost function
      • numberOfNetworkSegments

        protected int numberOfNetworkSegments
        holds the count of all link segments in the transport network
      • numberOfNetworkVertices

        protected int numberOfNetworkVertices
        holds the count of all vertices in the transport network
      • smoothing

        protected Smoothing smoothing
        the smoothing to use
      • demands

        protected Demands demands
        The demand to use
      • initialLinkSegmentCost

        protected InitialLinkSegmentCost initialLinkSegmentCost
        The initial link segment cost
      • physicalCost

        protected PhysicalCost physicalCost
        The physical generalized cost approach
      • initialLinkSegmentCostByTimePeriod

        protected Map<TimePeriod,​InitialLinkSegmentCost> initialLinkSegmentCostByTimePeriod
        Map storing InitialLinkSegmentCost objects for each time period
      • TRADITIONAL_STATIC_ASSIGNMENT

        public static String TRADITIONAL_STATIC_ASSIGNMENT
    • 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
    • Method Detail

      • createTrafficAssignmentBuilder

        protected abstract TrafficAssignmentBuilder createTrafficAssignmentBuilder​(InputBuilderListener trafficComponentCreateListener,
                                                                                   Demands demands,
                                                                                   Zoning zoning,
                                                                                   PhysicalNetwork physicalNetwork)
                                                                            throws PlanItException
        create the traffic assignment builder for this traffic assignment
        Parameters:
        trafficComponentCreateListener - listener to register on all traffic assignment components that this builder can build
        demands - the demands this assignment works on
        zoning - the zoning this assignment works on
        physicalNetwork - the physical network this assignment works on
        Returns:
        created traffic assignment builder
        Throws:
        PlanItException - thrown if there is an error
      • addRegisteredEventTypeListeners

        protected abstract void addRegisteredEventTypeListeners​(org.djutils.event.EventType eventType)
        register all the known listeners for the passed in eventType on this producer for this event type
        Parameters:
        eventType - the event type to register
      • 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 void verifyComponentCompatibility()
                                             throws PlanItException
        Verify if the traffic assignment components are compatible and nonnull
        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
      • 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
      • 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
      • collectBuilder

        public TrafficAssignmentBuilder collectBuilder​(InputBuilderListener trafficComponentCreateListener,
                                                       Demands theDemands,
                                                       Zoning theZoning,
                                                       PhysicalNetwork thePhysicalNetwork)
                                                throws PlanItException
        Each traffic assignment class can have its own builder which reveals what components need to be registered on the traffic assignment instance in order to function properly.
        Parameters:
        trafficComponentCreateListener - , the listener should be registered on all traffic component factories the traffic assignment utilises
        theDemands - this assignment works on
        theZoning - this assignment works on
        thePhysicalNetwork - this assignment works on
        Returns:
        trafficAssignmentBuilder to use
        Throws:
        PlanItException - thrown if there is an error
      • executeEquilibration

        public abstract void executeEquilibration()
                                           throws PlanItException
        Run equilibration after resources initialized, including saving results
        Throws:
        PlanItException - thrown if there is an error
      • createOutputTypeAdapter

        public abstract OutputTypeAdapter createOutputTypeAdapter​(OutputType outputType)
        Create the output type adapter for the current output type
        Parameters:
        outputType - the current output type
        Returns:
        the output type adapter corresponding to the current traffic assignment and output type
      • activateOutput

        public OutputTypeConfiguration activateOutput​(OutputType outputType)
                                               throws PlanItException
        Method that allows one to activate specific output types for persistence which is passed on to the output manager
        Parameters:
        outputType - OutputType object to be used
        Returns:
        outputTypeConfiguration the output type configuration that is now active
        Throws:
        PlanItException - thrown if there is an error activating the output
      • deactivateOutput

        public void deactivateOutput​(OutputType outputType)
        Deactivate the specified output type
        Parameters:
        outputType - the output type to be deactivated
      • isOutputTypeActive

        public boolean isOutputTypeActive​(OutputType outputType)
        Verify if a given output type is active
        Parameters:
        outputType - the output type to check if active
        Returns:
        true if active, false otherwise
      • 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
      • getTransportNetwork

        public TransportNetwork getTransportNetwork()
        Get the TransportNetwork used in the current assignment
        Returns:
        TransportNetwork used in current assignment
      • getOutputConfiguration

        public OutputConfiguration getOutputConfiguration()
        Provide the output configuration for user access (via the output manager)
        Returns:
        outputConfiguration for this traffic 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
      • 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
      • 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
      • setPhysicalNetwork

        public void setPhysicalNetwork​(PhysicalNetwork physicalNetwork)
        Set the PhysicalNetwork for the current assignment
        Parameters:
        physicalNetwork - the PhysicalNetwork object 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
      • setZoning

        public void setZoning​(Zoning zoning)
        Set the zoning object for the current assignment
        Parameters:
        zoning - the Zoning object for the current assignment
      • setInitialLinkSegmentCost

        public void setInitialLinkSegmentCost​(InitialLinkSegmentCost initialLinkSegmentCost)
        Set the initial link segment cost unrelated to any particular time period, i.e., used for all time periods that do not have designated initial costs specified for them
        Parameters:
        initialLinkSegmentCost - the initial link segment cost
      • setInitialLinkSegmentCost

        public void setInitialLinkSegmentCost​(TimePeriod timePeriod,
                                              InitialLinkSegmentCost initialLinkSegmentCost)
        Set the initial link segment cost for a specified time period, otherwise revert to the general initial link segment cost (if any)
        Parameters:
        timePeriod - the specified time period
        initialLinkSegmentCost - the initial link segment cost
      • getPhysicalCost

        public PhysicalCost getPhysicalCost()
        Get the dynamic physical cost object for the current assignment
        Returns:
        the physical cost object for the current assignment
      • setPhysicalCost

        public void setPhysicalCost​(PhysicalCost physicalCost)
                             throws PlanItException
        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
        Parameters:
        physicalCost - the physical cost object for the current assignment
        Throws:
        PlanItException - thrown if there is an error
      • getVirtualCost

        public VirtualCost getVirtualCost()
        Returns the virtual cost object for the current assignment
        Returns:
        the virtual cost object for the current assignments
      • setVirtualCost

        public void setVirtualCost​(VirtualCost 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
      • registerOutputFormatter

        public void registerOutputFormatter​(OutputFormatter outputFormatter)
        Register the output formatter on the assignment
        Parameters:
        outputFormatter - OutputFormatter to be registered
      • unregisterOutputFormatter

        public void unregisterOutputFormatter​(OutputFormatter outputFormatter)
        Unregister an output formatter
        Parameters:
        outputFormatter - the output formatter to be removed
      • getOutputFormatters

        public List<OutputFormatter> getOutputFormatters()
        Returns a list of output formatters registered on this assignment
        Returns:
        List of OutputFormatter objects registered on this assignment
      • getSimulationData

        public abstract SimulationData getSimulationData()
        Return the simulation data for the current iteration
        Returns:
        the simulation data for the current iteration