Class ArrivalsHeadwayGenerator
java.lang.Object
org.opentrafficsim.road.gtu.generator.headway.ArrivalsHeadwayGenerator
- All Implemented Interfaces:
Generator<org.djunits.value.vdouble.scalar.Duration>
public class ArrivalsHeadwayGenerator
extends Object
implements Generator<org.djunits.value.vdouble.scalar.Duration>
Headway generation based on
Arrivals
.
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Headway distribution. -
Constructor Summary
ConstructorDescriptionArrivalsHeadwayGenerator
(Arrivals arrivals, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, ArrivalsHeadwayGenerator.HeadwayDistribution distribution) -
Method Summary
-
Constructor Details
-
ArrivalsHeadwayGenerator
public ArrivalsHeadwayGenerator(Arrivals arrivals, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, ArrivalsHeadwayGenerator.HeadwayDistribution distribution) - Parameters:
arrivals
- Arrivals; arrivalssimulator
- OtsSimulatorInterface; simulatorstream
- StreamInterface; random stream to draw headwaydistribution
- HeadwayDistribution; random headway distribution
-
-
Method Details
-
draw
public org.djunits.value.vdouble.scalar.Duration draw() throws ProbabilityException, org.opentrafficsim.base.parameters.ParameterExceptionReturns 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<org.djunits.value.vdouble.scalar.Duration>
- Returns:
- Duration; new headway
- Throws:
ProbabilityException
- if the stored collection is emptyorg.opentrafficsim.base.parameters.ParameterException
- in case of a parameter exception
-
toString
-