Class Injections
java.lang.Object
org.opentrafficsim.road.gtu.generator.Injections
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:
Generator<Duration>for inter-arrival timesLaneBasedGtuCharacteristicsGeneratorthroughasLaneBasedGtuCharacteristicsGeneratorGeneratorPositionsRoomCheckerSupplier<String>for GTU ids
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDestination column id.static final StringFront column id.static final StringGTU type column id.static final StringId column id.static final StringLane column id.static final StringLength column id.static final StringLink column id.static final StringMaximum acceleration column id.static final StringMaximum deceleration column id.static final StringMaximum speed column id.static final StringOrigin column id.static final StringPosition (on lane) column id.static final StringRoute column id.static final StringSpeed column id.static final StringTime column id.static final StringWidth column id. -
Constructor Summary
ConstructorsConstructorDescriptionInjections(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) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturns a Supplier<Duration> view to supply inter-arrival time of injections.Returns a GeneratorPositions view of injections.Returns an Supplier<String> view as id supplier of injections.Returns a characteristics generator view of the injections, as used byLaneBasedGtuGenerator.Returns RoomChecker view of injections.booleanReturns whether the column of given id is present.
-
Field Details
-
TIME_COLUMN
Time column id.- See Also:
-
ID_COLUMN
Id column id.- See Also:
-
GTU_TYPE_COLUMN
GTU type column id.- See Also:
-
POSITION_COLUMN
Position (on lane) column id.- See Also:
-
LANE_COLUMN
Lane column id.- See Also:
-
LINK_COLUMN
Link column id.- See Also:
-
SPEED_COLUMN
Speed column id.- See Also:
-
ORIGIN_COLUMN
Origin column id.- See Also:
-
DESTINATION_COLUMN
Destination column id.- See Also:
-
ROUTE_COLUMN
Route column id.- See Also:
-
LENGTH_COLUMN
Length column id.- See Also:
-
WIDTH_COLUMN
Width column id.- See Also:
-
MAX_SPEED_COLUMN
Maximum speed column id.- See Also:
-
MAX_ACCELERATION_COLUMN
Maximum acceleration column id.- See Also:
-
MAX_DECELERATION_COLUMN
Maximum deceleration column id.- See Also:
-
FRONT_COLUMN
Front column id.- See Also:
-
-
Constructor Details
-
Injections
public Injections(Table table, Network network, ImmutableMap<String, GtuType> gtuTypes, BiFunction<GtuType, throws IllegalArgumentExceptionnl.tudelft.simulation.jstats.streams.StreamInterface, Optional<GtuTemplate>> gtuCharacteristicsGenerator, LaneBasedStrategicalPlannerFactory<?> strategicalPlannerFactory, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Duration timeToCollision) Constructor. Depending on what information is provided in the injections table, some arguments may or should not benull. In particular:- "time": always required, allows the
Injectionsto be used as aGenerator<Duration>. - "id": allows the
Injectionsto be used as aSupplier<String>for GTU ids. - "position", "lane", "link": allows the
Injectionsto be used as aGeneratorPositions, requires network. - "speed": allows the
Injectionsto be used as aRoomChecker, requires timeToCollision. - all other columns: allows the
Injectionsto be used as aLaneBasedGtuCharacteristicsGeneratorthroughasLaneBasedGtuCharacteristicsGenerator(), requires gtuTypes, network, strategicalPlannerFactory and stream; gtuCharacteristicsGenerator may then be null.
- Parameters:
table- table with at least a "time" column.network- network, may benull.gtuTypes- GTU types, as obtained fromDefinitions, may benull.gtuCharacteristicsGenerator- generator of GTU characteristics, may benull.strategicalPlannerFactory- strategical planner factory, may benull.stream- random number stream, may benull.timeToCollision- critical time-to-collision to allow GTU generation, may benull.- Throws:
IllegalArgumentException- when the right arguments are not provided for the columns in the injection table.
- "time": always required, allows the
-
-
Method Details
-
hasColumn
Returns whether the column of given id is present.- Parameters:
columnId- column id.- Returns:
- whether the column of given id is present.
-
asIdSupplier
Returns an Supplier<String> view as id supplier of injections.- Returns:
- Supplier<String> view as id supplier of injections
-
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
Returns a characteristics generator view of the injections, as used byLaneBasedGtuGenerator. 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
Returns a GeneratorPositions view of injections.- Returns:
- GeneratorPositions view of injections
-
asRoomChecker
Returns RoomChecker view of injections.- Returns:
- RoomChecker view of injections
-