Class StdDelayTable

All Implemented Interfaces:
NamedObjectOps

public class StdDelayTable extends DelayTable
Factory for delay tables used for determining the time for unscheduled trips between hubs. This class computes the time it takes to travel from one hub to another. For any two end points, the travel time may be different each time getDelay(double,Hub,Hub,int) is called with the same arguments due to the use of random variables.

This class allows one to set up a table to compute delays for any two pairs of hubs (table entries are directional so for each pair, two entries are normally needed). A default computation based on the hub's coordinates will be used when an entry is missing from the table.

A DoubleRandomVariable determines the average speed of travel, measured while in motion. For each route, one can specify

  • the length of the route
  • the number of possible stops along the route
  • the maximum wait at a stop (this is an average over all stops)
  • the probability that one will stop at any particular stopping point
A similar set of values is provided for the default, but in this case one provides a unit distance over which the number of stops applies. The number of stops used is then scaled by an estimated distance divided by the unit distance. For the default, the distance is a weighed average of two values: the line-of-sight distance between the two points and the sum of the absolute values of the differences between the end points' X values and Y values.
  • Constructor Details

    • StdDelayTable

      public StdDelayTable(DramaSimulation sim, String name, boolean intern)
      Constructor.
      Parameters:
      sim - the simulation
      name - the name of this object
      intern - true if this object should be interned in the simulation's name table; false otherwise
  • Method Details

    • init

      public void init(DoubleRandomVariable speedRV, double dist, int stops, double stopProbability, double maxWait)
      Initialize a local delay table. One will provide a random variable giving a speed (the speed while in motion, not an average speed that includes stops), a unit distance the number of stops in the unit distance, the probability of stopping at one of the stops, and a maximum waiting time for the time spent at a stop (if stopped at that point). When used, the number of stops will be scaled based on the unit distance and the actual distance.

      While the random variable speedRV will be used in general for computing travel times, the other arguments are used only in the case where an entry has not been added to the table by calling addEntry to provide explicit values for trips between two hubs. In this case the distance traveled is estimated based on the X and Y coordinates of the two hubs by using a weighted combination of the line-of-sight distance between the two points and the sum of the absolute values of the differences in X and Y coordinates

      Parameters:
      speedRV - A random variable providing a travel speed in units of meters per second.
      dist - a unit distance
      stops - the number of stops per unit distance
      stopProbability - the probability of stopping at a stop
      maxWait - the maximum waiting time when stopped
    • addEntry

      public void addEntry(Hub src, Hub dest, double distance, int stops, double stopProbability, double maxWait)
      Add an entry describing a trip between two hubs. One will provide a distance between the hubs the number of stops, the probability of stopping at one of the stops, and a maximum waiting time for the time spent at a stop (if stopped at that point). The entry applies to trips from src to dest, but not the reverse trip.
      Parameters:
      src - the starting hub
      dest - the ending hub
      distance - the distance between the two hubs (src and dest)
      stops - the number of stops
      stopProbability - the probability of stopping at a stop
      maxWait - the maximum waiting time when stopped
    • setDistFraction

      public void setDistFraction(double value)
      Set the distance fraction. The distance fraction is used to compute distances between hubs when no explicit distance is provided. One computes two quantities:
      • d1 - the line of sight distance (the square root of δx2 + δy2).
      • d2 - the sum of the distances in the X and Y directions (i.e., |δx| + |δy|).
      These quantities are combined to give a distance of (1-f)d1 + fd2, where f is the distance fraction.

      Setting f to 0.0 will result in the line of sight distance being used, whereas setting the value to 1.0 will set the distance to one appropriate for traveling parallel to the X axis and then parallel to the Y access. Other values will provide estimates between these two cases. The default value is 0.5.

      Parameters:
      value - the new value for the distance fraction (a value in the range [0.0, 1.0]).
    • getDistFraction

      public double getDistFraction()
      Get the distance fraction. The distance fraction is used to compute distances between hubs when no explicit distance is provided. One computes two quantities:
      • d1 - the line of sight distance (the square root of δx2 + δy2).
      • d2 - the sum of the distances in the X and Y directions (i.e., |δx| + |δy|).
      These quantities are combined to give a distance of (1-f)d1 + fd2, where f is the distance fraction.

      A value of 0.0 will result in the line of sight distance being used, whereas a value to 1.0 will set the distance to one appropriate for traveling parallel to the X axis and then parallel to the Y access. Other values will provide estimates between these two cases. The default value is 0.5.

      Returns:
      the distance fraction
    • latestStartingTime

      public double latestStartingTime(double time, Hub src, Hub dest)
      Description copied from class: DelayTable
      Get the latest starting time, given a minimum starting time, for a trip between two hubs with the same arrival time.
      Specified by:
      latestStartingTime in class DelayTable
      Parameters:
      time - the time in seconds, measured from the start of the simulation, at which a trip from src to dest could start
      src - the starting hub
      dest - the ending hub
      Returns:
      the latest simulation time in seconds at which the trip could start without changing the arrival time; Double.NEGATIVE_INFINITY if a trip is not possible
    • estimateDelay

      public double estimateDelay(double startingTime, Hub src, Hub dest, int n)
      Estimate the time it takes to travel between two hubs.

      Note: the startingTime argument (the first argument) is ignored by StdDelayTable instances.

      Specified by:
      estimateDelay in class DelayTable
      Parameters:
      startingTime - the time in seconds, measured from the start of the simulation, at which a trip from src to dest starts
      src - the starting hub
      dest - the ending hub
      n - the number of individuals traveling together
      Returns:
      the time in seconds to travel from src to dest; Double.POSITIVE_INFINITY if the trip is not possible
    • getDelay

      public double getDelay(double startingTime, Hub src, Hub dest, int n)
      Get the time it takes to travel between two hubs. test if a trip is possible.

      Note: the startingTime argument (the first argument) is ignored by StdDelayTable instances.

      Specified by:
      getDelay in class DelayTable
      Parameters:
      startingTime - the time in seconds, measured from the start of the simulation, at which a trip from src to dest starts
      src - the starting hub
      dest - the ending hub
      n - the number of individuals traveling together
      Returns:
      the time in seconds to travel from src to dest; Double.POSITIVE_INFINITY if the trip is not possible
    • printConfiguration

      public void printConfiguration(String iPrefix, String prefix, boolean printName, PrintWriter out)
      Print the configuration for an instance of StdDelayTable. The documentation for method SimObject.printConfiguration(String,String,boolean,java.io.PrintWriter) contains a description of how this method is used and how to override it. The method GenericSimObject.printConfiguration(String,String,boolean,java.io.PrintWriter) describes the data that will be printed for the superclass of this class. The data that will be printed when this method is called are the following.

      For class StdDelayTable:

      • the random variable giving the average speed (m/s).
      • the default distance for the number of stops.
      • the number of stops over the default distance.
      • the default probability of stopping at a stop.
      • the default maximum wait time at a stop.
      • the distance fraction (0.0 means line of sight and 1.0 means the value following a rectangular grid when computing distances from XY coordinates)
      • the hub table. For each pair of hubs, this table shows the following:
        • the distance in meters between two hubs.
        • the number of stops.
        • the probability of stopping.
        • the maximum wait while stopped.
      Overrides:
      printConfiguration in class GenericSimObject<DramaSimulation,Actor,Condition,Domain,DomainMember,DramaFactory,Group>
      Parameters:
      iPrefix - the prefix to use for an initial line when printName is true with null treated as an empty string
      prefix - a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is true
      printName - requests printing the name of an object
      out - the output print writer
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • isInterned

      public boolean isInterned()
      Specified by:
      isInterned in interface NamedObjectOps
    • getObjectNamer

      protected Simulation getObjectNamer()
    • getName

      public final String getName()
      Specified by:
      getName in interface NamedObjectOps
    • canDelete

      public boolean canDelete()
      Specified by:
      canDelete in interface NamedObjectOps
    • delete

      public final boolean delete()
      Specified by:
      delete in interface NamedObjectOps
    • isDeleted

      public final boolean isDeleted()
      Specified by:
      isDeleted in interface NamedObjectOps
    • deletePending

      public final boolean deletePending()
      Specified by:
      deletePending in interface NamedObjectOps