java.lang.Object
org.djutils.event.LocalEventProducer
All Implemented Interfaces:
Serializable, Remote, EventListener, nl.tudelft.simulation.dsol.animation.Locatable, org.djutils.base.Identifiable, org.djutils.event.EventListener, org.djutils.event.EventProducer, org.opentrafficsim.base.geometry.OtsLocatable, Drawable, LocatedObject, LaneBasedObject

public final class Conflict extends AbstractLaneBasedObject implements org.djutils.event.EventListener
Conflicts deal with traffic on different links/roads that need to consider each other as their paths may be in conflict spatially. A single Conflict represents the one-sided consideration of a conflicting situation. I.e., what is considered a single conflict in traffic theory, is represented by two Conflicts, one on each of the conflicting Lanes.

This class provides easy access to upstream and downstream GTUs through PerceptionIterables using methods getUpstreamGtus and getDownstreamGtus. These methods are efficient in that they reuse underlying data structures if the GTUs are requested at the same time by another GTU.

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

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Light-weight lane based object to indicate the end of a conflict.
  • Field Summary

    Fields inherited from interface org.djutils.event.EventProducer

    FIRST_POSITION, LAST_POSITION
  • Method Summary

    Modifier and Type
    Method
    Description
     
    static void
    generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, org.djunits.value.vdouble.scalar.Length longitudinalPosition1, org.djunits.value.vdouble.scalar.Length length1, org.djutils.draw.line.Polygon2d geometry1, Lane lane2, org.djunits.value.vdouble.scalar.Length longitudinalPosition2, org.djunits.value.vdouble.scalar.Length length2, org.djutils.draw.line.Polygon2d geometry2, OtsSimulatorInterface simulator)
    Creates a pair of conflicts.
     
     
    getDownstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, org.djunits.value.vdouble.scalar.Length visibility)
    Provides the downstream GTUs.
    org.djutils.draw.line.Polygon2d
    org.djunits.value.vdouble.scalar.Length
    Returns the length of the object.
     
    org.djunits.value.vdouble.scalar.Length
    getTrafficLightDistance(org.djunits.value.vdouble.scalar.Length maxDistance)
    Returns the distance to an upstream traffic light.
    getUpstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, org.djunits.value.vdouble.scalar.Length visibility)
    Provides the upstream GTUs.
    double
    protected void
    boolean
    If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.
    void
    notify(org.djutils.event.Event event)

    Methods inherited from class org.opentrafficsim.road.network.lane.object.AbstractLaneBasedObject

    getFullId, getLane, getLongitudinalPosition

    Methods inherited from class org.opentrafficsim.core.object.StaticObject

    create, create, getBounds, getHeight, getId, getLocation

    Methods inherited from class org.djutils.event.LocalEventProducer

    addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djutils.event.EventProducer

    addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener

    Methods inherited from interface org.djutils.base.Identifiable

    getId

    Methods inherited from interface org.opentrafficsim.road.network.lane.object.LaneBasedObject

    getLocation

    Methods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable

    getDirZ

    Methods inherited from interface org.opentrafficsim.core.object.LocatedObject

    getHeight

    Methods inherited from interface org.opentrafficsim.base.geometry.OtsLocatable

    getBounds
  • Method Details

    • init

      protected void init() throws NetworkException
      Overrides:
      init in class AbstractLaneBasedObject
      Throws:
      NetworkException
    • getUpstreamGtus

      public PerceptionCollectable<HeadwayGtu,LaneBasedGtu> getUpstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, org.djunits.value.vdouble.scalar.Length visibility)
      Provides the upstream GTUs.
      Parameters:
      perceivingGtu - LaneBasedGtu; perceiving GTU
      headwayGtuType - HeadwayGtuType; headway GTU type to use
      visibility - Length; distance over which GTU's are provided
      Returns:
      PerceptionIterable<HeadwayGtU>; iterable over the upstream GTUs
    • getDownstreamGtus

      public PerceptionCollectable<HeadwayGtu,LaneBasedGtu> getDownstreamGtus(LaneBasedGtu perceivingGtu, HeadwayGtuType headwayGtuType, org.djunits.value.vdouble.scalar.Length visibility)
      Provides the downstream GTUs.
      Parameters:
      perceivingGtu - LaneBasedGtu; perceiving GTU
      headwayGtuType - HeadwayGtuType; headway GTU type to use
      visibility - Length; distance over which GTU's are provided
      Returns:
      PerceptionIterable<HeadwayGtU>; iterable over the downstream GTUs
    • notify

      public void notify(org.djutils.event.Event event) throws RemoteException
      Specified by:
      notify in interface org.djutils.event.EventListener
      Throws:
      RemoteException
    • getConflictType

      public ConflictType getConflictType()
      Returns:
      conflictType.
    • getConflictRule

      public ConflictRule getConflictRule()
      Returns:
      conflictRule.
    • conflictPriority

      public ConflictPriority conflictPriority()
      Returns:
      conflictPriority.
    • getGeometry

      public org.djutils.draw.line.Polygon2d getGeometry()
      Specified by:
      getGeometry in interface LocatedObject
      Overrides:
      getGeometry in class StaticObject
    • getLength

      public org.djunits.value.vdouble.scalar.Length getLength()
      Returns the length of the object. The default value is zero.
      Specified by:
      getLength in interface LaneBasedObject
      Returns:
      Length; length of the object.
    • getOtherConflict

      public Conflict getOtherConflict()
      Returns:
      otherConflict.
    • isPermitted

      public boolean isPermitted()
      If permitted, traffic upstream of traffic lights may not be ignored, as these can have green light.
      Returns:
      permitted.
    • getTrafficLightDistance

      public org.djunits.value.vdouble.scalar.Length getTrafficLightDistance(org.djunits.value.vdouble.scalar.Length maxDistance)
      Returns the distance to an upstream traffic light.
      Parameters:
      maxDistance - Length; maximum distance of traffic light
      Returns:
      Length; distance to upstream traffic light, infinite if beyond maximum distance
    • generateConflictPair

      public static void generateConflictPair(ConflictType conflictType, ConflictRule conflictRule, boolean permitted, Lane lane1, org.djunits.value.vdouble.scalar.Length longitudinalPosition1, org.djunits.value.vdouble.scalar.Length length1, org.djutils.draw.line.Polygon2d geometry1, Lane lane2, org.djunits.value.vdouble.scalar.Length longitudinalPosition2, org.djunits.value.vdouble.scalar.Length length2, org.djutils.draw.line.Polygon2d geometry2, OtsSimulatorInterface simulator) throws NetworkException
      Creates a pair of conflicts.
      Parameters:
      conflictType - ConflictType; conflict type, i.e. crossing, merge or split
      conflictRule - ConflictRule; conflict rule
      permitted - boolean; whether the conflict is permitted in traffic light control
      lane1 - Lane; lane of conflict 1
      longitudinalPosition1 - Length; longitudinal position of conflict 1
      length1 - Length; Length of conflict 1
      geometry1 - Polygon2d; geometry of conflict 1
      lane2 - Lane; lane of conflict 2
      longitudinalPosition2 - Length; longitudinal position of conflict 2
      length2 - Length; Length of conflict 2
      geometry2 - Polygon2d; geometry of conflict 2
      simulator - OtsSimulatorInterface; the simulator for animation and timed events
      Throws:
      NetworkException - if the combination of conflict type and both conflict rules is not correct
    • getZ

      public double getZ() throws RemoteException
      Specified by:
      getZ in interface nl.tudelft.simulation.dsol.animation.Locatable
      Throws:
      RemoteException
    • toString

      public String toString()
      Overrides:
      toString in class AbstractLaneBasedObject