View Javadoc
1   package org.opentrafficsim.road.gtu.generator;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.djunits.value.vdouble.scalar.Speed;
5   
6   /**
7    * Extends car-following placement with a first-order bounded acceleration (BA) principle. This principle comes down to
8    * reduction of efficiency by increasing headways, as the generated GTU speed is lower than the desired speed. The increased
9    * headways allow for acceleration to occur, allowing faster flow recovery over time.
10   * <p>
11   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
13   * </p>
14   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
15   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
16   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
17   */
18  public class CfBaRoomChecker extends CfRoomChecker
19  {
20  
21      /** {@inheritDoc} */
22      @Override
23      protected double headwayFactor(final Speed desiredSpeed, final Length desiredHeadway, final Speed generationSpeed,
24              final Length generationHeadway, final Length leaderLength)
25      {
26          if (desiredSpeed.eq(generationSpeed))
27          {
28              return 1.0;
29          }
30          // following state at desired speed (capacity)
31          double k0 = 1.0 / (desiredHeadway.si + leaderLength.si);
32          double q0 = k0 * desiredSpeed.si;
33          // actual state
34          double k = 1.0 / (generationHeadway.si + leaderLength.si);
35          double q = k * generationSpeed.si;
36          // recovery flow qr
37          double qr = q; // if already on free flow branch
38          if (k > k0) // on congestion branch
39          {
40              // recovery wave speed assuming theta = 1 / q0 (theoretically sound and tested to be robust)
41              double rho = generationSpeed.si - q0 / k;
42              // recovery free flow state
43              double kr = (q - rho * k) / (desiredSpeed.si - rho);
44              qr = kr * desiredSpeed.si;
45          }
46          // efficiency factor, > 1 is larger headway, so less efficient
47          return q0 / qr;
48      }
49  
50  }