Class Platoons<T>
java.lang.Object
org.opentrafficsim.road.gtu.generator.Platoons<T>
- Type Parameters:
T
- type of demand category, typically a Category in an OdMatrix or a GtuType
Connects with a lane-based GTU generator to disable it over some time and generate a platoon instead. Platoons are added as:
This class may be used with a
Platoons.ofCategory(...).addPlatoon(...).addGtu(...).addGtu(...).addPlatoon(...).addGtu(...).addGtu(...).start();
.
Method addGtu(...)
may only determine a generation time if other info is set by fixInfo(...)
.This class may be used with a
LaneBasedGtuCharacteristicsGenerator
or GtuCharacteristicsGeneratorOD
. Use
ofGtuType()
or ofCategory()
respectively.
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
-
Method Summary
Modifier and TypeMethodDescriptionaddGtu
(org.djunits.value.vdouble.scalar.Time time) Add GTU to the current platoon.Add GTU to the current platoon.addPlatoon
(org.djunits.value.vdouble.scalar.Time start, org.djunits.value.vdouble.scalar.Time end) Add a platoon.org.djunits.value.vdouble.vector.FrequencyVector
compensate
(T category, org.djunits.value.vdouble.vector.FrequencyVector demand, org.djunits.value.vdouble.vector.TimeVector time, Interpolation interpolation) Creates a demand vector in which the platoon demand has been compensated from the input demand vector.Fix all info except time for GTU's added hereafter.protected LaneBasedGtuGenerator
Returns the vehicle generator for sub classes.protected Lane
Returns the position for sub classes.ofCategory
(LaneBasedGtuCharacteristicsGeneratorOd characteristics, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Lane position) Creates aPlatoon<Category>
instance for platoons.ofGtuType
(LaneBasedGtuCharacteristicsGenerator characteristics, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Lane position) Creates aPlatoon<GtuType>
instance for platoons.protected abstract void
Places the next platoon GTU and schedules the next one.protected void
start()
Starts the events.void
start
(LaneBasedGtuGenerator generator) Sets the generator and starts the events.
-
Method Details
-
ofCategory
public static Platoons<Category> ofCategory(LaneBasedGtuCharacteristicsGeneratorOd characteristics, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Lane position) Creates aPlatoon<Category>
instance for platoons.- Parameters:
characteristics
- GtuCharacteristicsGeneratorOD; characteristics generatorsimulator
- OtsSimulatorInterface; simulatorstream
- StreamInterface; random number streamposition
- Lane; position- Returns:
- Platoons<Category>; platoons based on OD
-
ofGtuType
public static Platoons<GtuType> ofGtuType(LaneBasedGtuCharacteristicsGenerator characteristics, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, Lane position) Creates aPlatoon<GtuType>
instance for platoons.- Parameters:
characteristics
- LaneBasedGtuCharacteristicsGenerator; characteristics generatorsimulator
- OtsSimulatorInterface; simulatorstream
- StreamInterface; random number streamposition
- Lane; position- Returns:
- Platoons<GtuType>; platoons based on OD
-
addPlatoon
public Platoons<T> addPlatoon(org.djunits.value.vdouble.scalar.Time start, org.djunits.value.vdouble.scalar.Time end) throws nl.tudelft.simulation.dsol.SimRuntimeException Add a platoon. The generator is disabled during the provided time frame. Individual GTU's should be added usingaddGtu
.- Parameters:
start
- Time; start timeend
- Time; end time- Returns:
- Platoons<T>; for method chaining
- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- on exception
-
fixInfo
Fix all info except time for GTU's added hereafter.- Parameters:
origin
- Node; origindestination
- Node; destinationcategory
- T; category- Returns:
- Platoons<T>; for method chaining
-
addGtu
Add GTU to the current platoon. Per platoon, GTU may be given in any order. This method uses info set withfixInfo
.- Parameters:
time
- Time; time of generation- Returns:
- Platoons<T>; for method chaining
- Throws:
IllegalStateException
- if no fixed info was set usingfixInfo
-
addGtu
public Platoons<T> addGtu(org.djunits.value.vdouble.scalar.Time time, Node origin, Node destination, T category) Add GTU to the current platoon. Per platoon, GTU may be given in any order.- Parameters:
time
- Time; time of generationorigin
- Node; origindestination
- Node; destinationcategory
- T; category- Returns:
- Platoons<T>; for method chaining
- Throws:
IllegalStateException
- if no platoon was started or time is outside of the platoon time range
-
start
public void start(LaneBasedGtuGenerator generator) throws nl.tudelft.simulation.dsol.SimRuntimeException Sets the generator and starts the events.- Parameters:
generator
- LaneBasedGtuGenerator; GTU generator- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- if start of first platoon is in the past
-
getGenerator
Returns the vehicle generator for sub classes.- Returns:
- LaneBasedGtuGenerator; vehicle generator for sub classes
-
getPosition
Returns the position for sub classes.- Returns:
- Set<Lane>; position for sub classes
-
start
protected void start() throws nl.tudelft.simulation.dsol.SimRuntimeExceptionStarts the events.- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- if start of first platoon is in the past
-
compensate
public org.djunits.value.vdouble.vector.FrequencyVector compensate(T category, org.djunits.value.vdouble.vector.FrequencyVector demand, org.djunits.value.vdouble.vector.TimeVector time, Interpolation interpolation) Creates a demand vector in which the platoon demand has been compensated from the input demand vector. Only demand pertaining to the location where the platoons are generated should be compensated.- Parameters:
category
- T; categorydemand
- FrequencyVector; demand vectortime
- TimeVector; time vectorinterpolation
- Interpolation; interpolation- Returns:
- FrequencyVector; demand vector in which the platoon demand has been compensated from the input demand vector
-
placeGtu
protected abstract void placeGtu(org.opentrafficsim.road.gtu.generator.Platoons.PlatoonGtu<T> platoonGtu) throws nl.tudelft.simulation.dsol.SimRuntimeException, NamingException, GtuException, NetworkException, OtsGeometryException, ProbabilityException, org.opentrafficsim.base.parameters.ParameterException Places the next platoon GTU and schedules the next one.- Parameters:
platoonGtu
- PlatoonGtu<T>; info of GTU to generate- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- on exceptionNamingException
- on exceptionGtuException
- on exceptionNetworkException
- on exceptionOtsGeometryException
- on exceptionorg.opentrafficsim.base.parameters.ParameterException
- on exceptionProbabilityException
- on exception
-