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
  • 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 separately
      stream - 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 separately
      stream - StreamInterface; stream for random numbers
      biases - 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 separately
      stream - StreamInterface; stream for random numbers
      linkWeights - 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 separately
      stream - StreamInterface; stream for random numbers
      biases - LaneBiases; lane biases for GTU types
      linkWeights - 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 type
      unplaced - Map<CrossSectionLink, Map<Integer, Integer>>; number of unplaced GTUs per lane. The lane number should match with GeneratorLanePosition.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 position
      route - Route; route, may be null
      Returns:
      GeneratorLanePosition; new position to generate a GTU
    • getLocation

      public DirectedPoint getLocation() throws java.rmi.RemoteException
      Specified by:
      getLocation in interface Locatable
      Throws:
      java.rmi.RemoteException
    • getBounds

      public javax.media.j3d.Bounds getBounds() throws java.rmi.RemoteException
      Specified by:
      getBounds in interface Locatable
      Throws:
      java.rmi.RemoteException
    • getAllPositions

      public java.util.Set<GeneratorPositions.GeneratorLanePosition> getAllPositions()
      Returns all underlying positions.
      Returns:
      all underlying positions
    • speedLimit

      public Speed speedLimit​(GTUType gtuType)
      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