Class GeneratorPositions.LaneBias

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

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

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

    • NONE

      public static final GeneratorPositions.LaneBias NONE
      No bias.
    • WEAK_LEFT

      public static final GeneratorPositions.LaneBias WEAK_LEFT
      Weak left-hand bias, 2nd left lane contains 50% relative to left most lane, in free traffic.
    • LEFT

      public static final GeneratorPositions.LaneBias LEFT
      Left-hand bias, 2nd left lane contains 25% relative to left most lane, in free traffic.
    • STRONG_LEFT

      public static final GeneratorPositions.LaneBias STRONG_LEFT
      Strong left-hand bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic.
    • WEAK_MIDDLE

      public static final GeneratorPositions.LaneBias WEAK_MIDDLE
      Weak middle bias, 2nd left lane contains 50% relative to left most lane, in free traffic.
    • MIDDLE

      public static final GeneratorPositions.LaneBias MIDDLE
      Middle bias, 2nd left lane contains 25% relative to left most lane, in free traffic.
    • STRONG_MIDDLE

      public static final GeneratorPositions.LaneBias STRONG_MIDDLE
      Strong middle bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic.
    • WEAK_RIGHT

      public static final GeneratorPositions.LaneBias WEAK_RIGHT
      Weak right-hand bias, 2nd right lane contains 50% relative to right most lane, in free traffic.
    • STRONG_RIGHT

      public static final GeneratorPositions.LaneBias STRONG_RIGHT
      Strong right-hand bias, 2nd right lane contains 3.125% relative to right most lane, in free traffic.
    • TRUCK_RIGHT

      public static final GeneratorPositions.LaneBias TRUCK_RIGHT
      Strong right-hand bias, limited to a maximum of 2 lanes.
  • 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(org.djunits.value.vdouble.scalar.Speed leftSpeed, org.djunits.value.vdouble.scalar.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, org.djunits.value.vdouble.scalar.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 Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object