Class GeneratorPositions.LaneBias

java.lang.Object
org.opentrafficsim.road.gtu.generator.GeneratorPositions.LaneBias
Enclosing class:
GeneratorPositions

public static final class GeneratorPositions.LaneBias
extends java.lang.Object
Vehicle generation lateral bias. Includes a lane maximum, e.g. trucks only on 2 right-hand lanes.

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 22 dec. 2017
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Field Details

  • Constructor Details

    • LaneBias

      public LaneBias​(GeneratorPositions.RoadPosition roadPosition, double bias, double stickyLanes)
      Constructor.
      Parameters:
      roadPosition - RoadPosition; lateral position on the road (0 = right, 0.5 = middle, 1 = left)
      bias - double; bias extent, lower values create more spread traffic, 0.0 causes no lane preference
      stickyLanes - double; number of lanes to consider in either direction, including the preferred lane
  • Method Details

    • bySpeed

      public static GeneratorPositions.LaneBias bySpeed​(Speed leftSpeed, Speed rightSpeed)
      Returns a bias by speed with normal extent.
      Parameters:
      leftSpeed - Speed; desired speed for full left bias
      rightSpeed - Speed; desired speed for full right bias
      Returns:
      bias by speed with normal extent
    • bySpeed

      public static GeneratorPositions.LaneBias bySpeed​(double leftSpeedKm, double rightSpeedKm)
      Returns a bias by speed with normal extent. Convenience km/h input.
      Parameters:
      leftSpeedKm - double; desired speed for full left bias
      rightSpeedKm - double; desired speed for full right bias
      Returns:
      bias by speed with normal extent
    • calculateWeight

      public double calculateWeight​(int laneNumFromRight, int numberOfLanes, int numberOfUnplacedGTUs, Speed desiredSpeed)
      Returns a random draw weight for given lane. The weight is calculated as:
       weight = { 0,                               d >= number of sticky lanes
                { 1 / ((d + 1)^bias * (m + 1)),    otherwise
       
       where,
            d:      lane deviation from lateral bias position
            bias:   bias extent
            m:      number of unplaced GTU's
       
      The formula makes sure that all lanes have equal weight for bias = 0, given an equal number of unplaced GTU's m. The bias can be seen to result in this: for each GTU on the 2nd lane, there are 2^(bias - 1) GTU's on the 1st lane. In numbers: 1 vs. 1 for bias = 0, 1 vs. 2 for bias = 1, 1 vs. 4 for bias = 2, 1 vs. 8 for bias = 3, etc.

      Division by m + 1 makes sure traffic distributes over the lanes in case of spillback, or otherwise too high demand on a particular lane. The weight for lanes with more unplaced GTU's simply reduces. This effect balances out with the bias, meaning that for a strong bias, GTU's are still likely to be generated on the biased lanes. Given a relatively strong bias of bias = 5, the weight for the 1st and 2nd lane becomes equal if the 2nd lane has no unplaced GTU's, while the 1st lane has 31 unplaced GTU's.

      Lane deviation d is calculated as d = abs(latBiasLane - laneNumFromRight). Here, latBiasLane = 1 + roadPosition*(numberOfLanes - 1), i.e. ranging from 1 to 4 on a 4-lane road. For lanes that are beyond the number of sticky lanes, the weight is always 0.

      Parameters:
      laneNumFromRight - int; number of lane counted from right to left
      numberOfLanes - int; total number of lanes
      numberOfUnplacedGTUs - int; number of GTU's in the generation queue
      desiredSpeed - Speed; desired speed, possibly used to determine the biased road position
      Returns:
      double; random draw weight for given lane
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object