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
  • Constructor Details

    • ArrivalsHeadwayGenerator

      public ArrivalsHeadwayGenerator(Arrivals arrivals, OtsSimulatorInterface simulator, nl.tudelft.simulation.jstats.streams.StreamInterface stream, ArrivalsHeadwayGenerator.HeadwayDistribution distribution)
      Parameters:
      arrivals - Arrivals; arrivals
      simulator - OtsSimulatorInterface; simulator
      stream - StreamInterface; random stream to draw headway
      distribution - HeadwayDistribution; random headway distribution
  • Method Details

    • draw

      public org.djunits.value.vdouble.scalar.Duration draw() throws ProbabilityException, org.opentrafficsim.base.parameters.ParameterException
      Returns a new headway h assuming that the previous vehicle arrived at the current time t0. The vehicle thus arrives at t1 = 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 find h such that the integral of the demand pattern D from t0 until t1 equals r: ΣD(t0 > t1) = r. One can think of r as being 1 and representing an additional vehicle to arrive. The headway h that results correlates directly to the mean demand between t0 and t1.

      The value of r 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 headways r may range anywhere between 0 and infinity.

      This usage of r 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 interface Generator<org.djunits.value.vdouble.scalar.Duration>
      Returns:
      Duration; new headway
      Throws:
      ProbabilityException - if the stored collection is empty
      org.opentrafficsim.base.parameters.ParameterException - in case of a parameter exception
    • toString

      public String toString()
      Overrides:
      toString in class Object