Class NeighborsUtil


  • public final class NeighborsUtil
    extends Object
    Utilities to perceive neighbors.

    Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version 19 okt. 2018
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Method Detail

      • getFirstDownstreamGTUs

        public static SortedSet<NeighborsUtil.DistanceGTU> getFirstDownstreamGTUs​(LaneStructureRecord startRecord,
                                                                                  RelativePosition egoRelativePosition,
                                                                                  RelativePosition egoFrontPosition,
                                                                                  RelativePosition.TYPE otherRelativePosition,
                                                                                  Time now)
                                                                           throws GTUException,
                                                                                  org.opentrafficsim.base.parameters.ParameterException
        Returns a set of first leaders per branch, relative to given relative position. Helper method to find first leaders and GTU's alongside.
        Parameters:
        startRecord - LaneStructureRecord; lane structure record to start the search from
        egoRelativePosition - RelativePosition; position of GTU to start search from
        egoFrontPosition - RelativePosition; front position of GTU to determine headway
        otherRelativePosition - RelativePosition.TYPE; position of other GTU that has to be downstream
        now - Time; current time
        Returns:
        set of first leaders per branch
        Throws:
        GTUException - if the GTU was not initialized
        org.opentrafficsim.base.parameters.ParameterException - if a parameter was not present or out of bounds
      • getFirstUpstreamGTUs

        public static SortedSet<NeighborsUtil.DistanceGTU> getFirstUpstreamGTUs​(LaneStructureRecord startRecord,
                                                                                RelativePosition egoRelativePosition,
                                                                                RelativePosition egoRearPosition,
                                                                                RelativePosition.TYPE otherRelativePosition,
                                                                                Time now)
                                                                         throws GTUException,
                                                                                org.opentrafficsim.base.parameters.ParameterException
        Returns a set of first followers per branch, relative to given relative position. Helper method to find first followers and GTU's alongside.
        Parameters:
        startRecord - LaneStructureRecord; lane structure record to start the search from
        egoRelativePosition - RelativePosition; position of GTU to start search from
        egoRearPosition - RelativePosition; rear position of GTU to determine headway
        otherRelativePosition - RelativePosition.TYPE; type of position of other GTU that has to be upstream
        now - Time; current time
        Returns:
        set of first followers per branch
        Throws:
        GTUException - if the GTU was not initialized
        org.opentrafficsim.base.parameters.ParameterException - if a parameter was not present or out of bounds
      • perceive

        public static SortedSet<HeadwayGTU> perceive​(SortedSet<NeighborsUtil.DistanceGTU> base,
                                                     HeadwayGtuType headwayGtuType,
                                                     LaneBasedGTU perceivingGtu,
                                                     boolean downstream)
        Translation from a set of DistanceGTU's, to a sorted set of HeadwayGTU's. This bridges the gap between a raw network search, and the perceived result.
        Parameters:
        base - SortedSet<DistanceGTU>; base set of GTU's at distance
        headwayGtuType - HeadwayGtuType; headway type for perceived GTU's
        perceivingGtu - LaneBasedGTU; perceiving GTU
        downstream - boolean; whether the GTU's are downstream
        Returns:
        SortedSet<HeadwayGTU>; set of perceived GTU's