Class NeighborsUtil


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

    Copyright (c) 2013-2020 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 java.util.SortedSet<NeighborsUtil.DistanceGTU> getFirstDownstreamGTUs​(LaneStructureRecord startRecord,
                                                                                            RelativePosition egoRelativePosition,
                                                                                            RelativePosition egoFrontPosition,
                                                                                            RelativePosition.TYPE otherRelativePosition,
                                                                                            Time now)
                                                                                     throws GTUException,
                                                                                            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
        ParameterException - if a parameter was not present or out of bounds
      • getFirstUpstreamGTUs

        public static java.util.SortedSet<NeighborsUtil.DistanceGTU> getFirstUpstreamGTUs​(LaneStructureRecord startRecord,
                                                                                          RelativePosition egoRelativePosition,
                                                                                          RelativePosition egoRearPosition,
                                                                                          RelativePosition.TYPE otherRelativePosition,
                                                                                          Time now)
                                                                                   throws GTUException,
                                                                                          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
        ParameterException - if a parameter was not present or out of bounds
      • perceive

        public static java.util.SortedSet<HeadwayGTU> perceive​(java.util.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