Class BushTurnData


  • public class BushTurnData
    extends Object
    Track turn based data of a bush.

    For now we only track turn sending flows to minimise bookkeeping and memory usage, splitting rates are deduced from the turn sending flows when needed.

    Author:
    markr
    • Constructor Detail

      • BushTurnData

        public BushTurnData​(BushTurnData bushTurnData)
        copy constructor.
        Parameters:
        bushTurnData - to copy
    • Method Detail

      • setTurnSendingFlow

        public boolean setTurnSendingFlow​(EdgeSegment fromSegment,
                                          EdgeSegment toSegment,
                                          double turnSendingFlow,
                                          boolean allowTurnRemoval)
        Update the turn sending flow for a given turn
        Parameters:
        fromSegment - of turn
        toSegment - of turn
        turnSendingFlow - to update
        allowTurnRemoval - when true we allow for removal of turn/edge segment when no flow remains, when false we keep regardless of the remaining flow
        Returns:
        true when turn has any turn sending flow left after setting flow, false when turn sending flow no longer exists
      • addTurnSendingFlow

        public double addTurnSendingFlow​(EdgeSegment from,
                                         EdgeSegment to,
                                         double flowPcuH)
        Add turn sending flow for a given turn (can be negative), turn will not be removed if no flow remains
        Parameters:
        from - of turn
        to - of turn
        flowPcuH - to add
        Returns:
        the new turn sending flow after adding the given flow
      • addTurnSendingFlow

        public double addTurnSendingFlow​(EdgeSegment from,
                                         EdgeSegment to,
                                         double flowPcuH,
                                         boolean allowTurnRemoval)
        Add turn sending flow for a given turn (can be negative), flow can be removed if desired depending on flags set if desired
        Parameters:
        from - of turn
        to - of turn
        flowPcuH - to add
        allowTurnRemoval - when true we allow for removal of turn/edge segment when no flow remains, when false we keep regardless of the remaining flow
        Returns:
        the new labelled turn sending flow after adding the given flow
      • removeTurn

        public void removeTurn​(EdgeSegment fromEdgeSegment,
                               EdgeSegment toEdgeSegment)
        Remove the turn entirely
        Parameters:
        fromEdgeSegment - of turn
        toEdgeSegment - of turn
      • getTurnSendingFlowPcuH

        public double getTurnSendingFlowPcuH​(EdgeSegment fromSegment,
                                             EdgeSegment toSegment)
        Get the turn sending flow for a given turn
        Parameters:
        fromSegment - of turn
        toSegment - of turn
        Returns:
        turn sending flow, 0 if not present
      • getTotalSendingFlowFromPcuH

        public double getTotalSendingFlowFromPcuH​(EdgeSegment edgeSegment)
        Total sending flows s_a from given segment
        Parameters:
        edgeSegment - to use
        Returns:
        sending flow s_a
      • getTotalAcceptedFlowToPcuH

        public double getTotalAcceptedFlowToPcuH​(EdgeSegment edgeSegment,
                                                 double[] flowAcceptanceFactors)
        Collect the accepted flow towards an edge segment in the bush with the specified label, if not present, zero flow is returned
        Parameters:
        edgeSegment - to collect sending flow towards to
        flowAcceptanceFactors - to convert sending flow to accepted flow
        Returns:
        bush sending flow found
      • containsTurnSendingFlow

        public boolean containsTurnSendingFlow​(EdgeSegment fromSegment,
                                               EdgeSegment toSegment)
        Verify if the turn sending flow for a given turn is positive
        Parameters:
        fromSegment - of turn
        toSegment - of turn
        Returns:
        true when present, false otherwise
      • getSplittingRates

        public double[] getSplittingRates​(EdgeSegment fromSegment)
        Collect the splitting rates for a given link segment and composition. Splitting rates are based on the current (labelled) turn sending flows s_ab. In case no flows are present for the given composition label, zero splitting rates for all turns are returned.
        Parameters:
        fromSegment - to collect bush splitting rates for
        Returns:
        splitting rates in primitive array in order of which one iterates over the outgoing edge segments of the downstream from segment vertex
      • getSplittingRate

        public double getSplittingRate​(EdgeSegment fromSegment,
                                       EdgeSegment toSegment)
        Collect the splitting rate for a given link segment. Splitting rates are based on the current turn sending flows s_ab.

        When collecting multiple splitting rates with the same in link, do not use this method but instead collect all splitting rates at once and then filter the ones you require it is computationally more efficient.

        Parameters:
        fromSegment - of turn to collect splitting rate for
        toSegment - of turn to collect splitting rate for
        Returns:
        splitting rate, when turn is not present or not used, zero is returned
      • hasTurnFlows

        public boolean hasTurnFlows()
        Verify if any turn flows have been registered
        Returns:
        true if so, false otherwise