java.lang.Object
org.bzdev.devqsim.SimObject
org.bzdev.drama.generic.GenericSimObject<S,A,C,D,DM,F,G>
org.bzdev.drama.generic.GenericTaskObject<S,A,C,D,DM,F,G>
org.bzdev.drama.common.MessageRecipient<S,A,C,D,DM,F,G>
org.bzdev.drama.generic.GenericMsgRecipient<S,A,C,D,DM,F,G>
org.bzdev.drama.generic.GenericActor<DramaSimulation,Actor,Condition,Domain,DomainMember,DramaFactory,Group>
org.bzdev.drama.Actor
org.bzdev.bikeshare.TripGenerator
org.bzdev.bikeshare.RoundTripGenerator
- All Implemented Interfaces:
CondObserver<Condition,
,Actor> NamedObjectOps
Trip generator trips between two hubs given Poisson traffic,
A specified number of bicycles per trip, a starting hub and
a set of destination hubs, the probabilities for using a
given destination, and the probabilities for each destination
of using the overflow area. There is additionally a random
variable providing the waiting time before the return trip.
Many trips in practice will be individual trips, but some trips may be made a groups of people traveling together. To account for these trips, RoundTripGenerator allows one to specify the number of bicycles taken for a trip (one can create different trip generators for each number of bicycles that one expects to see). The generator assumes that bicycles are picked up at a hub's preferred location, and that a fraction of the trips will always use a hub's overflow area.
-
Constructor Summary
ConstructorsConstructorDescriptionRoundTripGenerator
(DramaSimulation sim, String name, boolean intern) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
action()
Perform an action that generates a trip.boolean
protected Object
clone()
final boolean
delete()
final boolean
double
getMean()
Get the mean interarrival time for trips.final String
getName()
protected double
Get the time interval to wait before scheduling the next trip.protected Simulation
void
init
(Hub hub, double mean, int nbikes, DoubleRandomVariable waitrv, Double returnOverflowProb, Hub[] destHubs, double[] weights, double[] overflowProb) Initialization.final boolean
boolean
void
printConfiguration
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print the configuration for an instance of TripGenerator.void
setMean
(double mean) Set the mean interarrival time for trips.void
setReturnOverflowProb
(double p) Set the probability of using the starting hub's overflow area at the end of a return trip.void
setWaitRV
(DoubleRandomVariable waitrv) Set the time interval between arriving at a destination and starting a return trip.Methods inherited from class org.bzdev.bikeshare.TripGenerator
addTripDataListener, createTripID, fireTripEnded, fireTripFailedAtStart, fireTripFailedMidstream, fireTripPauseEnd, fireTripPauseStart, fireTripStarted, getInitialDelay, getProbabilityFunction, isRunning, printState, removeTripDataListener, restart, setInitialDelay, setProbabilityFunction, setProbabilitySimFunction, stop
Methods inherited from class org.bzdev.drama.Actor
doReceive, onConditionChange
Methods inherited from class org.bzdev.drama.generic.GenericActor
addCondition, conditionSet, domainSet, drainMessageQueue, findMsgFrwdngInfo, findMsgFrwdngInfo, findMsgFrwdngInfo, findMsgFrwdngInfo, findMsgFrwdngInfo, findMsgFrwdngInfo, findMsgFrwdngInfo, getChildDomains, getConditionChangeQMode, getCondObserverImpl, hasCondition, inDomain, joinDomain, joinDomain, leaveDomain, onConditionChange, onDelete, removeCondition, send, send, send, send, send, send, send, send, send, send, send, setConditionChangeQMode, setMessageQueueing, setSharedDomainMember
Methods inherited from class org.bzdev.drama.generic.GenericMsgRecipient
getGroups, inGroup, joinGroup, joinGroup, leaveGroup
Methods inherited from class org.bzdev.drama.generic.GenericTaskObject
cancelDefaultCall, cancelDefaultTask, defaultCall, defaultTask, scheduleDefaultCall, scheduleDefaultTask, scheduleDefaultTask
Methods inherited from class org.bzdev.drama.generic.GenericSimObject
getSimulation
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, 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
-
RoundTripGenerator
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
-
setMean
public void setMean(double mean) Set the mean interarrival time for trips. This method will stop the traffic generator, change the mean interarrival time, and restart the traffic generator. Correct operation is dependent on Poission traffic being memoryless: calling stop() followed by restart() has no effect on the statisitical distribution of the trips' starting times.- Parameters:
mean
- the mean interarrival time in seconds
-
getMean
public double getMean()Get the mean interarrival time for trips.- Returns:
- the mean interarrival time in seconds
-
setWaitRV
Set the time interval between arriving at a destination and starting a return trip.- Parameters:
waitrv
- a random variable giving the time interval in seconds
-
setReturnOverflowProb
public void setReturnOverflowProb(double p) Set the probability of using the starting hub's overflow area at the end of a return trip.- Parameters:
p
- the probability
-
getNextInterval
protected double getNextInterval()Description copied from class:TripGenerator
Get the time interval to wait before scheduling the next trip.- Specified by:
getNextInterval
in classTripGenerator
- Returns:
- the next trip interarrival time
-
action
protected boolean action()Description copied from class:TripGenerator
Perform an action that generates a trip. Implementations of this method will typically call theHub
methodHub.sendUsers(Hub,int,boolean,Callable)
orHub.sendUsers(Hub,int,boolean,RealValuedFunctionTwo,Callable)
. TheCallable
argument handles multi-hop trips and also a final call toTripGenerator.fireTripEnded(long,Hub)
for successfully completed trips. The return value forsendUsers
orsendUsers
can be used to determine whetherTripGenerator.fireTripStarted(long,Hub,HubDomain)
orTripGenerator.fireTripFailedAtStart(long,Hub)
should be called. IfsendUsers
orsendUsers
is used mid-trip, a failure is noted by callingTripGenerator.fireTripFailedMidstream(long,Hub)
(which should not be called except for multi-hop trips). For multi-hop trips, theTripGenerator.fireTripPauseStart(long,Hub)
should be called to note that a trip has temporarily paused at an intermediate hub andTripGenerator.fireTripPauseEnd(long,Hub,HubDomain)
to indicate that the trip is continuing after a pause.Note: when this method returns false, the traffic generator cannot be restarted.
- Specified by:
action
in classTripGenerator
- Returns:
- true if more trips can be generated; false otherwise
-
printConfiguration
Print the configuration for an instance of TripGenerator. 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 methodGenericActor.printConfiguration(String,String,boolean,java.io.PrintWriter)
describes this method as it applies to all actors . The data that will be printed when this method is called are the following.For class
TripGenerator
:- the initial delay - the time to wait before trips are generated.
Defined for class RoundTripGenerator:
- the mean interarrival time in seconds for trips.
- the number of bicycles per trip.
- the starting hub.
- the destination hubs. For each destination, the following
are printed:
- the name of a destination hub.
- the probability of choosing this hub.
- the probability of using the overflow area.
- Overrides:
printConfiguration
in classTripGenerator
- 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
-