Class ArrivalsHeadwayGenerator
- java.lang.Object
-
- org.opentrafficsim.road.gtu.generator.headway.ArrivalsHeadwayGenerator
-
public class ArrivalsHeadwayGenerator extends Object implements Generator<Duration>
Headway generation based onArrivals
.Copyright (c) 2013-2020 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 13 dec. 2017
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ArrivalsHeadwayGenerator.HeadwayDistribution
Headway distribution.
-
Constructor Summary
Constructors Constructor Description ArrivalsHeadwayGenerator(Arrivals arrivals, SimulatorInterface.TimeDoubleUnit simulator, StreamInterface stream, ArrivalsHeadwayGenerator.HeadwayDistribution distribution)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Duration
draw()
Returns a new headwayh
assuming that the previous vehicle arrived at the current timet0
.String
toString()
-
-
-
Constructor Detail
-
ArrivalsHeadwayGenerator
public ArrivalsHeadwayGenerator(Arrivals arrivals, SimulatorInterface.TimeDoubleUnit simulator, StreamInterface stream, ArrivalsHeadwayGenerator.HeadwayDistribution distribution)
- Parameters:
arrivals
- Arrivals; arrivalssimulator
- SimulatorInterface.TimeDoubleUnit; simulatorstream
- StreamInterface; random stream to draw headwaydistribution
- HeadwayDistribution; random headway distribution
-
-
Method Detail
-
draw
public Duration draw() throws ProbabilityException, ParameterException
Returns a new headwayh
assuming that the previous vehicle arrived at the current timet0
. The vehicle thus arrives att1 = t0 + h
. This method guarantees that no vehicle arrives during periods where demand is zero, while maintaining random headways based on average demand over a certain time period.
The general method is to findh
such that the integral of the demand patternD
fromt0
untilt1
equalsr
: ΣD(t0 > t1) = r
. One can think ofr
as being 1 and representing an additional vehicle to arrive. The headwayh
that results correlates directly to the mean demand betweent0
andt1
.
The value ofr
always has a mean of 1, but may vary between specific vehicle arrivals depending on the headway distribution. When assuming constant headways for any given demand level,r
always equals 1. For exponentially distributed headwaysr
may range anywhere between 0 and infinity.
This usage ofr
guarantees that no vehicles arrive during periods with 0 demand. For example:- Suppose we have 0 demand between 300s and 400s.
- The previous vehicle was generated at 299s.
- The demand at 299s equals 1800veh/h (1 veh per 2s).
- For both constant and exponentially distributed headways, the expected next vehicle arrival based on this demand value alone would be 299 + 2 = 301s. This is within the 0-demand period and should not happen. It's also not theoretically sound, as the demand from 299s until 301s is not 1800veh/h on average.
- Using integration we find that the surface of demand from 299s until 300s equals 0.5 veh for stepwise demand, and 0.25 veh for linear demand. Consequently, the vehicle will not arrive until later slices integrate to an additional 0.5 veh or 0.75 veh respectively. This additional surface under the demand curve is only found after 400s.
- In case the exponential headway distribution would have resulted in
r
< 0.5 (stepwise demand) or 0.25 (linear demand), a vehicle will simply arrive between 299s and 300s.
- Specified by:
draw
in interfaceGenerator<Duration>
- Returns:
- Duration; new headway
- Throws:
ProbabilityException
- if the stored collection is emptyParameterException
- in case of a parameter exception
-
-