Class InitialModesLinkSegmentCost

  • All Implemented Interfaces:
    Cost<MacroscopicLinkSegment>

    public class InitialModesLinkSegmentCost
    extends Object
    implements Cost<MacroscopicLinkSegment>
    Wrapper around all initial costs per link segment per mode. Used by InitialLinkSegmentCost to store costs per time period, or agnostic to a time period
    Author:
    markr
    • Field Detail

      • costPerModeAndLinkSegment

        protected final Map<Mode,​Map<Long,​Double>> costPerModeAndLinkSegment
        Map to store initial cost for each mode and link segment, not linked to a particular time period
    • Constructor Detail

      • InitialModesLinkSegmentCost

        protected InitialModesLinkSegmentCost()
        Constructor
      • InitialModesLinkSegmentCost

        protected InitialModesLinkSegmentCost​(InitialModesLinkSegmentCost initialLinkSegmentCostMode)
        Copy constructor
        Parameters:
        initialLinkSegmentCostMode - to copy
    • Method Detail

      • isSegmentCostsSetForMode

        public boolean isSegmentCostsSetForMode​(Mode mode)
        Are link segment costs available for the given mode
        Parameters:
        mode - the mode
        Returns:
        true when available, false otherwise
      • getGeneralisedCost

        public double getGeneralisedCost​(Mode mode,
                                         MacroscopicLinkSegment linkSegment)
        Returns the initial cost for each link segment and mode. When absent positive infinity is returned
        Specified by:
        getGeneralisedCost in interface Cost<MacroscopicLinkSegment>
        Parameters:
        mode - the current mode
        linkSegment - the current link segment
        Returns:
        the cost for this link segment and mode
      • setSegmentCost

        public void setSegmentCost​(Mode mode,
                                   MacroscopicLinkSegment linkSegment,
                                   double cost)
        Sets the initial cost for each link segment and mode
        Parameters:
        mode - the current mode
        linkSegment - the current link segment
        cost - the initial cost for this link segment and mode
      • setSegmentCost

        public void setSegmentCost​(Mode mode,
                                   long linkSegmentId,
                                   double cost)
        Sets the initial cost for each link segment and mode
        Parameters:
        mode - the current mode
        linkSegmentId - the id of the current link segment
        cost - the initial cost for this link segment and mode At present this method is only used in unit tests.
      • reset

        public void reset()
        Resetting initial cost will cause all intial costs to be removed
      • getTravelTimeCost

        public double getTravelTimeCost​(Mode mode,
                                        MacroscopicLinkSegment linkSegment)
        Returns the generalised cost of travel along an edge segment for a specified mode
        Specified by:
        getTravelTimeCost in interface Cost<MacroscopicLinkSegment>
        Parameters:
        mode - the specified mode of travel
        linkSegment - the specified edge segment (which can be physical or virtual)
        Returns:
        the cost of travel along the specified segment
      • getDTravelTimeDFlow

        public double getDTravelTimeDFlow​(boolean uncongested,
                                          Mode mode,
                                          MacroscopicLinkSegment linkSegment)
        Not supported returns -infinity for all calls and logs severe warning
        Specified by:
        getDTravelTimeDFlow in interface Cost<MacroscopicLinkSegment>
        Parameters:
        uncongested - flag idicating if the provided flow is uncongested or congested flow, relevant when flow can represent multiple traffic states
        mode - to use
        linkSegment - to use
        Returns:
        the first derivative of travel time for a unit flow rate change in PCU per Hour