- All Implemented Interfaces:
NamedObjectOps
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
-
Constructor Summary
ConstructorsConstructorDescriptionStdDelayTable
(DramaSimulation sim, String name, boolean intern) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an entry describing a trip between two hubs.boolean
protected Object
clone()
final boolean
delete()
final boolean
double
estimateDelay
(double startingTime, Hub src, Hub dest, int n) Estimate the time it takes to travel between two hubs.double
Get the time it takes to travel between two hubs.double
Get the distance fraction.final String
getName()
protected Simulation
void
init
(DoubleRandomVariable speedRV, double dist, int stops, double stopProbability, double maxWait) Initialize a local delay table.final boolean
boolean
double
latestStartingTime
(double time, Hub src, Hub dest) Get the latest starting time, given a minimum starting time, for a trip between two hubs with the same arrival time.void
printConfiguration
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print the configuration for an instance of StdDelayTable.void
setDistFraction
(double value) Set the distance fraction.Methods inherited from class org.bzdev.bikeshare.DelayTable
addToDomain, estimateDelay, getDelay, latestStartingTime, localDelay
Methods inherited from class org.bzdev.drama.generic.GenericMsgFrwdngInfo
localDelay, localDelay, localDelay, localDelay, localDelay, localDelay, localDelay, localDelay, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter, localMessageFilter
Methods inherited from class org.bzdev.drama.generic.GenericSimObject
getSimulation, printState
Methods inherited from class org.bzdev.devqsim.SimObject
addSimulationListener, addTraceSet, bindCallable, bindCallable, bindCallable, bindCallable, bindRunnable, bindRunnable, bindRunnable, bindRunnable, callableObject, callableScript, callScriptFunction, callScriptMethod, clearTraceSets, evalScript, getEventListenerList, getScriptObject, getTraceSets, onDelete, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printConfiguration, printState, printState, printState, printState, printState, printState, putScriptObject, removeSimulationListener, removeTraceSet, runnableObject, runnableScript, scheduleCall, scheduleCall, scheduleCall, scheduleCall, scheduleCallObject, scheduleScript, scheduleTask, scheduleTask, scheduleTask, scheduleTask, scheduleTaskObject, scheduleTaskScript, startImmediateTask, startImmediateTask, trace, trace, unscheduledTaskThread, unscheduledTaskThread, update, update, usesTraceSet
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.obnaming.NamedObjectOps
canDelete, delete, deletePending, getName, isDeleted, isInterned
-
Constructor Details
-
StdDelayTable
Constructor.- Parameters:
sim
- the simulationname
- the name of this objectintern
- 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 distancestops
- the number of stops per unit distancestopProbability
- the probability of stopping at a stopmaxWait
- 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|).
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|).
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
-
printConfiguration
Print the configuration for an instance of StdDelayTable. The documentation for methodSimObject.printConfiguration(String,String,boolean,java.io.PrintWriter)
contains a description of how this method is used and how to override it. The methodGenericSimObject.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 classGenericSimObject<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 stringprefix
- a prefix string (typically whitespace) to put at the start of each line other than the initial line that is printed when printName is trueprintName
- requests printing the name of an objectout
- the output print writer
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
isInterned
public boolean isInterned()- Specified by:
isInterned
in interfaceNamedObjectOps
-
getObjectNamer
-
getName
- Specified by:
getName
in interfaceNamedObjectOps
-
canDelete
public boolean canDelete()- Specified by:
canDelete
in interfaceNamedObjectOps
-
delete
public final boolean delete()- Specified by:
delete
in interfaceNamedObjectOps
-
isDeleted
public final boolean isDeleted()- Specified by:
isDeleted
in interfaceNamedObjectOps
-
deletePending
public final boolean deletePending()- Specified by:
deletePending
in interfaceNamedObjectOps
-