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
public abstract class Platoons<T> extends Object
Connects with a lane-based GTU generator to disable it over some time and generate a platoon instead. Platoons are added as:Platoons.ofCategory(...).addPlatoon(...).addGtu(...).addGtu(...).addPlatoon(...).addGtu(...).addGtu(...).start();. MethodaddGtu(...)may only determine a generation time if other info is set byfixInfo(...).
This class may be used with aLaneBasedGTUCharacteristicsGeneratororGTUCharacteristicsGeneratorOD. UseofGtuType()orofCategory()respectively.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 14 sep. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Platoons<T>addGtu(Time time)Add GTU to the current platoon.Platoons<T>addGtu(Time time, Node origin, Node destination, T category)Add GTU to the current platoon.Platoons<T>addPlatoon(Time start, Time end)Add a platoon.FrequencyVectorcompensate(T category, FrequencyVector demand, TimeVector time, Interpolation interpolation)Creates a demand vector in which the platoon demand has been compensated from the input demand vector.Platoons<T>fixInfo(Node origin, Node destination, T category)Fix all info except time for GTU's added hereafter.protected LaneBasedGTUGeneratorgetGenerator()Returns the vehicle generator for sub classes.protected Set<LaneDirection>getPosition()Returns the position for sub classes.static Platoons<Category>ofCategory(GTUCharacteristicsGeneratorOD characteristics, OTSSimulatorInterface simulator, StreamInterface stream, Set<LaneDirection> position)Creates aPlatoon<Category>instance for platoons.static Platoons<GTUType>ofGtuType(LaneBasedGTUCharacteristicsGenerator characteristics, OTSSimulatorInterface simulator, StreamInterface stream, Set<LaneDirection> position)Creates aPlatoon<GTUType>instance for platoons.protected abstract voidplaceGtu(org.opentrafficsim.road.gtu.generator.Platoons.PlatoonGtu<T> platoonGtu)Places the next platoon GTU and schedules the next one.protected voidstart()Starts the events.voidstart(LaneBasedGTUGenerator generator)Sets the generator and starts the events.
-
-
-
Method Detail
-
ofCategory
public static Platoons<Category> ofCategory(GTUCharacteristicsGeneratorOD characteristics, OTSSimulatorInterface simulator, StreamInterface stream, Set<LaneDirection> position)
Creates aPlatoon<Category>instance for platoons.- Parameters:
characteristics- GTUCharacteristicsGeneratorOD; characteristics generatorsimulator- OTSSimulatorInterface; simulatorstream- StreamInterface; random number streamposition- Set<LaneDirection>; position- Returns:
- Platoons<Category>; platoons based on OD
-
ofGtuType
public static Platoons<GTUType> ofGtuType(LaneBasedGTUCharacteristicsGenerator characteristics, OTSSimulatorInterface simulator, StreamInterface stream, Set<LaneDirection> position)
Creates aPlatoon<GTUType>instance for platoons.- Parameters:
characteristics- LaneBasedGTUCharacteristicsGenerator; characteristics generatorsimulator- OTSSimulatorInterface; simulatorstream- StreamInterface; random number streamposition- Set<LaneDirection>; position- Returns:
- Platoons<GTUType>; platoons based on OD
-
addPlatoon
public Platoons<T> addPlatoon(Time start, Time end) throws 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:
SimRuntimeException- on exception
-
fixInfo
public Platoons<T> fixInfo(Node origin, Node destination, T category)
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
public Platoons<T> addGtu(Time time)
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(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 SimRuntimeException
Sets the generator and starts the events.- Parameters:
generator- LaneBasedGTUGenerator; GTU generator- Throws:
SimRuntimeException- if start of first platoon is in the past
-
getGenerator
protected LaneBasedGTUGenerator getGenerator()
Returns the vehicle generator for sub classes.- Returns:
- LaneBasedGTUGenerator; vehicle generator for sub classes
-
getPosition
protected Set<LaneDirection> getPosition()
Returns the position for sub classes.- Returns:
- Set<LaneDirection>; position for sub classes
-
start
protected void start() throws SimRuntimeExceptionStarts the events.- Throws:
SimRuntimeException- if start of first platoon is in the past
-
compensate
public FrequencyVector compensate(T category, FrequencyVector demand, 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 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:
SimRuntimeException- on exceptionNamingException- on exceptionGTUException- on exceptionNetworkException- on exceptionOTSGeometryException- on exceptionorg.opentrafficsim.base.parameters.ParameterException- on exceptionProbabilityException- on exception
-
-