Class Injections

java.lang.Object
org.opentrafficsim.road.gtu.generator.Injections

public class Injections extends Object
Injections can be used to have a large degree of control over GTU generation. Depending on the information provided in an injections table, this class may be used in conjunction with LaneBasedGtuGenerator as a:
  1. Generator<Duration> for inter-arrival times
  2. LaneBasedGtuCharacteristicsGenerator through asLaneBasedGtuCharacteristicsGenerator
  3. GeneratorPositions
  4. RoomChecker
  5. Supplier<String> for GTU ids
Note that there are various asXxx() methods to supply a view of injections as the components mentioned above.

It is assumed that for each next GTU, first an inter-arrival time is requested. Functions 2 and 3 will not check order and simply return information from the current row in the injections table. Function 4 and 5 are tracked independently and asynchronous with the rest, as these occur at later times when GTUs are (attempted to be) placed.

Copyright (c) 2022-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
  • Field Details

  • Constructor Details

    • Injections

      public Injections(Table table, Network network, ImmutableMap<String,GtuType> gtuTypes, BiFunction<GtuType,nl.tudelft.simulation.jstats.streams.StreamInterface,Optional<GtuTemplate>> gtuCharacteristicsGenerator, LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Duration timeToCollision) throws IllegalArgumentException
      Constructor. Depending on what information is provided in the injections table, some arguments may or should not be null. In particular:
      • "time": always required, allows the Injections to be used as a Generator<Duration>.
      • "id": allows the Injections to be used as a Supplier<String> for GTU ids.
      • "position", "lane", "link": allows the Injections to be used as a GeneratorPositions, requires network.
      • "speed": allows the Injections to be used as a RoomChecker, requires timeToCollision.
      • all other columns: allows the Injections to be used as a LaneBasedGtuCharacteristicsGenerator through asLaneBasedGtuCharacteristicsGenerator(), requires gtuTypes, network, strategicalPlannerFactory and stream; gtuCharacteristicsGenerator may then be null.
      Time should be in increasing order. If length is provided, but no front, front will be 75% of the length.
      Parameters:
      table - table with at least a "time" column.
      network - network, may be null.
      gtuTypes - GTU types, as obtained from Definitions, may be null.
      gtuCharacteristicsGenerator - generator of GTU characteristics, may be null.
      strategicalPlannerFactory - strategical planner factory, may be null.
      stream - random number stream, may be null.
      timeToCollision - critical time-to-collision to allow GTU generation, may be null.
      Throws:
      IllegalArgumentException - when the right arguments are not provided for the columns in the injection table.
  • Method Details

    • hasColumn

      public boolean hasColumn(String columnId)
      Returns whether the column of given id is present.
      Parameters:
      columnId - column id.
      Returns:
      whether the column of given id is present.
    • asIdSupplier

      public Supplier<String> asIdSupplier()
      Returns an Supplier<String> view as id supplier of injections.
      Returns:
      Supplier<String> view as id supplier of injections
    • asArrivalsSupplier

      public Supplier<Duration> asArrivalsSupplier()
      Returns a Supplier<Duration> view to supply inter-arrival time of injections.
      Returns:
      Supplier<Duration> view to supply inter-arrival time of injections
    • asLaneBasedGtuCharacteristicsGenerator

      public LaneBasedGtuCharacteristicsGenerator asLaneBasedGtuCharacteristicsGenerator()
      Returns a characteristics generator view of the injections, as used by LaneBasedGtuGenerator. This requires at the least that a GTU type column, a strategical planner factory, a network, and a stream of random numbers are provided.
      Returns:
      characteristics generator view of the injections.
    • asGeneratorPositions

      public GeneratorPositions asGeneratorPositions()
      Returns a GeneratorPositions view of injections.
      Returns:
      GeneratorPositions view of injections
    • asRoomChecker

      public LaneBasedGtuGenerator.RoomChecker asRoomChecker()
      Returns RoomChecker view of injections.
      Returns:
      RoomChecker view of injections