Class SchedDelayTable

All Implemented Interfaces:
NamedObjectOps

public class SchedDelayTable extends DelayTable
Class representing a delay table for scheduled 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) and a sequence of starting times.

  • Constructor Details

    • SchedDelayTable

      public SchedDelayTable(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

    • addEntry

      public void addEntry(Hub src, Hub dest, double startingTime, double endingTime)
      Add an entry describing a trip between two hubs. One will provide a starting and ending time for a scheduled trip (one direction only).
      Parameters:
      src - the starting hub
      dest - the ending hub
      startingTime - a starting time for a trip
      endingTime - an ending time for a trip
    • addEntry

      public void addEntry(Hub src, Hub dest, double initialTime, double cutoffTime, double period, double duration)
      Add a periodic entry describing a sequence of trips between two hubs. One will provide an initial time and a final time, a period, and the duration for each trip. The initial and final times refer to the starting times of a trip. scheduled trip (one direction only).

      The cutoff should generally be slightly larger than the desired time for the last trip in the sequence so that floating point accuracy will not be an issue.

      Parameters:
      src - the starting hub
      dest - the ending hub
      initialTime - the time in seconds at which a sequence of trips is defined.
      cutoffTime - an upper bound on the starting time in units of seconds
      period - the period (in seconds) at which starting times repeat
      duration - the duration of each trip.
    • getEntry

      protected org.bzdev.bikeshare.SchedDelayTable.Entry getEntry(Hub src, Hub dest, double time)
      Get the best entry for a source, destination, and starting time. Given a source and destination hub, the method finds the a description of a scheduled trip with the earliest arrival time that has a departure time that is past the time specified by the third argument. If multiple entries have the same arrival time, the one with the latest departure time is selected.

      This method is used getDelay(double,Hub,Hub,int) and indirectly by estimateDelay(double,Hub,Hub,int) in order fetch data for computing the delay.

      Parameters:
      src - the starting hub
      dest - the ending hub
      time - the starting time for a trip.
      Returns:
      an entry that will describe the trip
    • 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)
      Description copied from class: DelayTable
      Estimate the time it takes to travel between two hubs.
      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)
      Description copied from class: DelayTable
      Get the time it takes to travel between two hubs. test if a trip is possible.
      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
    • localDelay

      protected long localDelay(Domain domain, Actor src, Object msg, Actor dest)
      Overrides:
      localDelay in class DelayTable
    • 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