Class LaneBasedGtuGenerator

java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.road.gtu.generator.LaneBasedGtuGenerator
All Implemented Interfaces:
Serializable, Remote, org.djutils.base.Identifiable, org.djutils.event.EventProducer, Drawable, GtuGenerator, NonLocatedObject

public class LaneBasedGtuGenerator extends org.djutils.event.LocalEventProducer implements GtuGenerator
Lane based GTU generator. This generator generates lane based GTUs using a LaneBasedTemplateGTUType. The template is used to generate a set of GTU characteristics at the times implied by the headway generator. These sets are queued until there is sufficient room to construct a GTU at the specified lane locations. The speed of a construction GTU may be reduced to ensure it does not run into its immediate leader 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:
  • Field Details

    • GTU_GENERATED_EVENT

      public static final org.djutils.event.EventType GTU_GENERATED_EVENT
      Event of a generated GTU. Payload: LaneBasedGtu
  • Constructor Details

    • LaneBasedGtuGenerator

      public LaneBasedGtuGenerator(String id, Generator<org.djunits.value.vdouble.scalar.Duration> interarrivelTimeGenerator, LaneBasedGtuCharacteristicsGenerator laneBasedGtuCharacteristicsGenerator, GeneratorPositions generatorPositions, RoadNetwork network, OtsSimulatorInterface simulator, LaneBasedGtuGenerator.RoomChecker roomChecker, Supplier<String> idGenerator) throws nl.tudelft.simulation.dsol.SimRuntimeException, ProbabilityException, org.opentrafficsim.base.parameters.ParameterException, NetworkException
      Construct a new lane base GTU generator.
      Parameters:
      id - String; name of the new GTU generator
      interarrivelTimeGenerator - Generator<Duration>; generator for the interval times between GTUs
      laneBasedGtuCharacteristicsGenerator - LaneBasedGtuCharacteristicsGenerator; generator of the characteristics of each GTU
      generatorPositions - GeneratorPositions; location and initial direction provider for all generated GTUs
      network - RoadNetwork; the OTS network that owns the generated GTUs
      simulator - OtsSimulatorInterface; simulator
      roomChecker - RoomChecker; the way that this generator checks that there is sufficient room to place a new GTU
      idGenerator - Supplier<String>; id generator
      Throws:
      nl.tudelft.simulation.dsol.SimRuntimeException - when startTime lies before the current simulation time
      ProbabilityException - pe
      org.opentrafficsim.base.parameters.ParameterException - if drawing from the interarrival generator fails
      NetworkException - if the object could not be added to the network
  • Method Details

    • setNoLaneChangeDistance

      public void setNoLaneChangeDistance(org.djunits.value.vdouble.scalar.Length noLaneChangeDistance)
      Sets the initial distance over which lane changes shouldn't be performed.
      Parameters:
      noLaneChangeDistance - Length; initial distance over which lane changes shouldn't be performed
    • setInstantaneousLaneChange

      public void setInstantaneousLaneChange(boolean instantaneous)
      Sets whether GTUs will change lane instantaneously.
      Parameters:
      instantaneous - boolean; whether GTUs will change lane instantaneously
    • setErrorHandler

      public void setErrorHandler(GtuErrorHandler gtuErrorHandler)
      Sets the GTU error handler.
      Parameters:
      gtuErrorHandler - GTUErrorHandler; GTU error handler
    • setIdsInCharacteristicsOrder

      public void setIdsInCharacteristicsOrder(boolean idsInCharacteristicsOrder)
      Sets what order should be used for the ids. By default this is in the order of successful GTU generation. If however the id generator is an instance of Injections with an id column, it is by default in the order of characteristics drawing.
      Parameters:
      idsInCharacteristicsOrder - boolean; ids in order of drawing characteristics, or successful generation otherwise.
    • queueGtu

      public final void queueGtu(LaneBasedGtuCharacteristics characteristics, Lane lane)
      Adds a GTU to the generation queue. This method ignores whether vehicle generation is enabled at the location. This allows an external party to govern (over some time) what vehicles are generated.
      Parameters:
      characteristics - LaneBasedGtuCharacteristics; characteristics of GTU to add to the queue
      lane - Lane; position to generate the GTU at
    • placeGtu

      public final void placeGtu(LaneBasedGtuCharacteristics characteristics, LanePosition position, org.djunits.value.vdouble.scalar.Speed speed) throws NamingException, GtuException, NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, OtsGeometryException
      Places a GTU, regardless of whether it has room. The user of this method should verify this is the case.
      Parameters:
      characteristics - LaneBasedGtuCharacteristics; characteristics
      position - LanePosition; position
      speed - Speed; speed
      Throws:
      NamingException - on exception
      GtuException - on exception
      NetworkException - on exception
      nl.tudelft.simulation.dsol.SimRuntimeException - on exception
      OtsGeometryException - on exception
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • getGeneratedGTUs

      public final long getGeneratedGTUs()
      Returns:
      generatedGTUs.
    • getId

      public final String getId()
      Retrieve the id of this LaneBasedGtuGenerator.
      Specified by:
      getId in interface org.djutils.base.Identifiable
      Returns:
      String; the id of this LaneBasedGtuGenerator
    • disable

      public void disable(org.djunits.value.vdouble.scalar.Time start, org.djunits.value.vdouble.scalar.Time end, Lane lane) throws nl.tudelft.simulation.dsol.SimRuntimeException
      Disable the vehicle generator during the specific time. Underlying processes such as drawing characteristics and headways are continued, but simply will not result in the queuing of the GTU.
      Parameters:
      start - Time; start time
      end - Time; end time
      lane - Lane; lane to disable generation on
      Throws:
      nl.tudelft.simulation.dsol.SimRuntimeException - if time is incorrect
    • getFullId

      public String getFullId()
      Specified by:
      getFullId in interface NonLocatedObject
    • getPositions

      public Set<GtuGenerator.GtuGeneratorPosition> getPositions()
      Specified by:
      getPositions in interface GtuGenerator