Class ArrivalsHeadwayGenerator

    • Method Detail

      • draw

        public Duration draw()
                      throws ProbabilityException,
                             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<Duration>
        Returns:
        Duration; new headway
        Throws:
        ProbabilityException - if the stored collection is empty
        ParameterException - in case of a parameter exception