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.BurstTripGenerator
- All Implemented Interfaces:
CondObserver<Condition,
,Actor> NamedObjectOps
Trip generator for trips that occur in bursts.
While the trips start in bursts, the destinations for
each trip is independent of the others.
-
Constructor Summary
ConstructorsConstructorDescriptionBurstTripGenerator
(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
int
Get the estimation-count parameter.double
Get the estimation-factor parameter.double
Get the estimation-offset parameter.final String
getName()
protected double
Get the time interval to wait before scheduling the next trip.protected Simulation
void
init
(Hub hub, double time, int nbikes, Hub[] otherHubs, double[] weights, double[] overflowProb, boolean fanIn) Initialization.final boolean
boolean
void
printConfiguration
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print the configuration for an instance of TripGenerator.void
printState
(String iPrefix, String prefix, boolean printName, PrintWriter out) Print the configuration for an instance of TripGenerator.void
restart()
Restart the trip generator after it has been stopped.void
setFanInParameters
(int estimationCount, double estimationFactor, double estimationOffset) Set parameters for the fan-in case.void
stop()
Stop the trip generator.Methods inherited from class org.bzdev.bikeshare.TripGenerator
addTripDataListener, createTripID, fireTripEnded, fireTripFailedAtStart, fireTripFailedMidstream, fireTripPauseEnd, fireTripPauseStart, fireTripStarted, getInitialDelay, getProbabilityFunction, isRunning, removeTripDataListener, setInitialDelay, setProbabilityFunction, setProbabilitySimFunction
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
-
BurstTripGenerator
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
-
setFanInParameters
public void setFanInParameters(int estimationCount, double estimationFactor, double estimationOffset) Set parameters for the fan-in case. The estimation count is used to compute an estimated delay between two hubs, assuming thatestimationCount
is the number of users traveling together (the delay is the mean delay for the slowest of a set ofestimationCount
users). This estimated delay is then multiplied byestimationFactor
. Finally a fixed numberestimationOffset
is added to that delay to compute the delay that will be assumed.- Parameters:
estimationCount
- the number of users to assume in a delay estimateestimationFactor
- the factor by which to scale the delayestimationOffset
- an offset (in seconds) to add to the delay
-
getEstimationCount
public int getEstimationCount()Get the estimation-count parameter.- Returns:
- the estimation count
- See Also:
-
getEstimationFactor
public double getEstimationFactor()Get the estimation-factor parameter.- Returns:
- the estimation factor
- See Also:
-
getEstimationOffset
public double getEstimationOffset()Get the estimation-offset parameter.- Returns:
- the estimation offset
- See Also:
-
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
-
restart
public void restart()Description copied from class:TripGenerator
Restart the trip generator after it has been stopped. If the trip generator is already running, callingTripGenerator.restart()
will have no effect.- Overrides:
restart
in classTripGenerator
- See Also:
-
stop
public void stop()Description copied from class:TripGenerator
Stop the trip generator. If this method is called when a trip generator is not running, it will have no effect. AfterTripGenerator.stop()
is called, the traffic generator may be restarted. If one stops and restarts before the event associated with the initial delay is processed, the initial delay will be ignored.- Overrides:
stop
in classTripGenerator
- See Also:
-
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 in
BurstTripGenerator
:- the burst time - he time at which trips are secheduled to leave from or arrive at the central hub. This is the exact time for the "fan-in" case and an estimate for the fan-out case.
- the burst size - the number of trips that will be generated.
- the fan-in flag - true if trips start at the central hub; false if trips end at the central hub.
- the central hub - the destination hub when the fan-in value is true; the originating hub when the fan-in value is false.
- the other-hub table - A table of hubs other than the central
hub. Each entry contains the following:
- the hub - a destination hub when the fan-in value is false; an originating hub when the fan-in value is true.
- the branching probability - the probability that a trip uses the specified hub.
- the overflow probability - the probability that the overflow area is chosen regardless of the hub state. This value is ignored when the fan-in value is true and is not printed for this case.
- 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
-
printState
Print the configuration for an instance of TripGenerator. The documentation for methodSimObject.printState(String,String,boolean,java.io.PrintWriter)
contains a description of how this method is used and how to override it. The methodGenericSimObject.printState(String,String,boolean,java.io.PrintWriter)
describes this method as it applies to all actors. In addition, the state that is printed includes the following items.Defined in
TripGenerator
:- whether or not the trip generator is running and the next time an action will be run if the trip generator is running.
Defined for class BurstTripGenerator:
- trips pending. The number of trips scheduled but not yet started.
- trips completed. The number of trips that were completed.
- trips in progress. The number of trips in progress.
- trips failed. The number of trips that could not be completed.
- Overrides:
printState
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
-