Class GeneratorPositions
java.lang.Object
org.opentrafficsim.road.gtu.generator.GeneratorPositions
- All Implemented Interfaces:
Locatable
public final class GeneratorPositions extends java.lang.Object implements Locatable
Helper class for vehicle generation which can draw the next GTU position to try to place a GTU. If the GTU can not be placed,
it should be included in a queue. This class requires the number of unplaced GTU's per lane, in order to appropriately divide
traffic over the 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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGeneratorPositions.GeneratorLanePositionClass representing a vehicle generation lane, providing elementary information for randomly drawing links and lanes.static classGeneratorPositions.LaneBiasVehicle generation lateral bias.static classGeneratorPositions.LaneBiasDefaultsSet of lane biases per GTU type enum, based on the GTU Types that are defined by default.static classGeneratorPositions.LaneBiasesSet of lane biases per GTU type.static interfaceGeneratorPositions.RoadPositionInterface for preferred road position for a lane bias. -
Method Summary
Modifier and Type Method Description static GeneratorPositionscreate(java.util.Set<DirectedLanePosition> positions, StreamInterface stream)Create a GeneratorPositions object to draw positions from.static GeneratorPositionscreate(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, java.util.Map<CrossSectionLink,java.lang.Double> linkWeights)Create a GeneratorPositions object to draw positions from.static GeneratorPositionscreate(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, GeneratorPositions.LaneBiases biases)Create a GeneratorPositions object to draw positions from.static GeneratorPositionscreate(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, GeneratorPositions.LaneBiases biases, java.util.Map<CrossSectionLink,java.lang.Double> linkWeights)Create a GeneratorPositions object to draw positions from.GeneratorPositions.GeneratorLanePositiondraw(GTUType gtuType, java.util.Map<CrossSectionLink,java.util.Map<java.lang.Integer,java.lang.Integer>> unplaced, Speed desiredSpeed, Route route)Draw a new position to generate a GTU.java.util.Set<GeneratorPositions.GeneratorLanePosition>getAllPositions()Returns all underlying positions.javax.media.j3d.BoundsgetBounds()DirectedPointgetLocation()SpeedspeedLimit(GTUType gtuType)Returns the speed limit for the given GTU type, prior to the GTU position being determined.
-
Method Details
-
create
public static GeneratorPositions create(java.util.Set<DirectedLanePosition> positions, StreamInterface stream)Create a GeneratorPositions object to draw positions from. The given positions are grouped per link. Lanes are drawn without bias. Each link receives a weight equal to the number of lanes.- Parameters:
positions- Set<DirectedLanePosition>; all considered positions, each lane is considered separatelystream- StreamInterface; stream for random numbers- Returns:
- GeneratorPositions; object to draw positions from
-
create
public static GeneratorPositions create(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, GeneratorPositions.LaneBiases biases)Create a GeneratorPositions object to draw positions from. The given positions are grouped per link. Each link receives a weight equal to the number of lanes.- Parameters:
positions- Set<DirectedLanePosition>; all considered positions, each lane is considered separatelystream- StreamInterface; stream for random numbersbiases- LaneBiases; lane biases for GTU types- Returns:
- GeneratorPositions; object to draw positions from
-
create
public static GeneratorPositions create(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, java.util.Map<CrossSectionLink,java.lang.Double> linkWeights)Create a GeneratorPositions object to draw positions from. The given positions are grouped per link. Lanes are drawn without bias.- Parameters:
positions- Set<DirectedLanePosition>; all considered positions, each lane is considered separatelystream- StreamInterface; stream for random numberslinkWeights- Map<CrossSectionLink, Double>; weight per link direction- Returns:
- GeneratorPositions; object to draw positions from
-
create
public static GeneratorPositions create(java.util.Set<DirectedLanePosition> positions, StreamInterface stream, GeneratorPositions.LaneBiases biases, java.util.Map<CrossSectionLink,java.lang.Double> linkWeights)Create a GeneratorPositions object to draw positions from. The given positions are grouped per link.- Parameters:
positions- Set<DirectedLanePosition>; all considered positions, each lane is considered separatelystream- StreamInterface; stream for random numbersbiases- LaneBiases; lane biases for GTU typeslinkWeights- Map<CrossSectionLink, Double>; weight per link direction- Returns:
- GeneratorPositions; object to draw positions from
-
draw
public GeneratorPositions.GeneratorLanePosition draw(GTUType gtuType, java.util.Map<CrossSectionLink,java.util.Map<java.lang.Integer,java.lang.Integer>> unplaced, Speed desiredSpeed, Route route)Draw a new position to generate a GTU. The link is drawn by giving each link a weight equal to the number of accessible lanes for the GTU type. Next, a lane is drawn using (optionally biased) weights.- Parameters:
gtuType- GTUType; GTU typeunplaced- Map<CrossSectionLink, Map<Integer, Integer>>; number of unplaced GTUs per lane. The lane number should match withGeneratorLanePosition.getLaneNumber(), where 1 is the right-most lane. Missing lanes are assumed to have no queue.desiredSpeed- Speed; desired speed, possibly used to determine the biased road positionroute- Route; route, may benull- Returns:
- GeneratorLanePosition; new position to generate a GTU
-
getLocation
- Specified by:
getLocationin interfaceLocatable- Throws:
java.rmi.RemoteException
-
getBounds
public javax.media.j3d.Bounds getBounds() throws java.rmi.RemoteException -
getAllPositions
Returns all underlying positions.- Returns:
- all underlying positions
-
speedLimit
Returns the speed limit for the given GTU type, prior to the GTU position being determined.- Parameters:
gtuType- GTUType; GTU type- Returns:
- speed limit for the given GTU type, prior to the GTU position being determined
-