Class GeneratorPositions.LaneBias
java.lang.Object
org.opentrafficsim.road.gtu.generator.GeneratorPositions.LaneBias
- Enclosing interface:
- GeneratorPositions
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 Summary
Modifier and TypeFieldDescriptionstatic final GeneratorPositions.LaneBias
Left-hand bias, 2nd left lane contains 25% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
Middle bias, 2nd left lane contains 25% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
No bias.static final GeneratorPositions.LaneBias
Right-hand bias, 2nd right lane contains 25% relative to right most lane, in free traffic.static final GeneratorPositions.LaneBias
Strong left-hand bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
Strong middle bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
Strong right-hand bias, 2nd right lane contains 3.125% relative to right most lane, in free traffic.static final GeneratorPositions.LaneBias
Strong right-hand bias, limited to a maximum of 2 lanes.static final GeneratorPositions.LaneBias
Weak left-hand bias, 2nd left lane contains 50% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
Weak middle bias, 2nd left lane contains 50% relative to left most lane, in free traffic.static final GeneratorPositions.LaneBias
Weak right-hand bias, 2nd right lane contains 50% relative to right most lane, in free traffic. -
Constructor Summary
ConstructorDescriptionLaneBias
(GeneratorPositions.RoadPosition roadPosition, double bias, double stickyLanes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic GeneratorPositions.LaneBias
bySpeed
(double leftSpeedKm, double rightSpeedKm) Returns a bias by speed with normal extent.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.double
calculateWeight
(int laneNumFromRight, int numberOfLanes, int numberOfUnplacedGTUs, org.djunits.value.vdouble.scalar.Speed desiredSpeed) Returns a random draw weight for given lane.boolean
int
hashCode()
toString()
-
Field Details
-
NONE
No bias. -
WEAK_LEFT
Weak left-hand bias, 2nd left lane contains 50% relative to left most lane, in free traffic. -
LEFT
Left-hand bias, 2nd left lane contains 25% relative to left most lane, in free traffic. -
STRONG_LEFT
Strong left-hand bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic. -
WEAK_MIDDLE
Weak middle bias, 2nd left lane contains 50% relative to left most lane, in free traffic. -
MIDDLE
Middle bias, 2nd left lane contains 25% relative to left most lane, in free traffic. -
STRONG_MIDDLE
Strong middle bias, 2nd left lane contains 3.125% relative to left most lane, in free traffic. -
WEAK_RIGHT
Weak right-hand bias, 2nd right lane contains 50% relative to right most lane, in free traffic. -
RIGHT
Right-hand bias, 2nd right lane contains 25% relative to right most lane, in free traffic. -
STRONG_RIGHT
Strong right-hand bias, 2nd right lane contains 3.125% relative to right most lane, in free traffic. -
TRUCK_RIGHT
Strong right-hand bias, limited to a maximum of 2 lanes.
-
-
Constructor Details
-
LaneBias
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 preferencestickyLanes
- 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 biasrightSpeed
- Speed; desired speed for full right bias- Returns:
- bias by speed with normal extent
-
bySpeed
Returns a bias by speed with normal extent. Convenience km/h input.- Parameters:
leftSpeedKm
- double; desired speed for full left biasrightSpeedKm
- 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 leftnumberOfLanes
- int; total number of lanesnumberOfUnplacedGTUs
- int; number of GTU's in the generation queuedesiredSpeed
- Speed; desired speed, possibly used to determine the biased road position- Returns:
- double; random draw weight for given lane
-
hashCode
public int hashCode() -
equals
-
toString
-