Delays agents for a given amount of time. The delay time is evaluated dynamically, may be stochastic and may depend on the agent as well as on any other conditions. Optionally, it may be calculated as the length of the animation path of the Delay divided by the "speed" of the agent. Multiple agents (up to the given Delay capacity) can be delayed simultaneously and independently.
An example of delay time definition: let the delay time of e.g. a data packet (class Packet) processing is proportional to the size of the packet + some random time. Then you may do the following: specify Packet as the Generic Parameter of Delay and write processingTimePerDataUnit * agent.size + uniform( timeMin, timeMax ) in the delayTime parameter.
If the capacity of the Delay object is changed dynamically, and the number of currently delayed agents exceeds the capacity, the Delay object will let them complete their delay times and will not let new agents in until the number falls below the new capacity.
You can access the agents being delayed, in particular you can get their remaining times and even remove agents from the block before they finish their delays.
The Delay block can animate the agents either as moving along the specified path or as staying at the specified positions. In case the agents are moving, they will cover the full path during the delay time.
void suspend(double dt) - Suspends this delay for the given timeout dt.
void suspend() - Suspends this delay. Blocks input port - even if delay isn't full. Timeouts of agents already being delayed are suspended until the resume() function call. Agents which have already finished their delay (and waiting for acceptance at the subsequent block) - are free to exit at any time subsequent block gets ready to consume them.
void resume() - Resumes previously suspended Delay (if was not suspended, throws error). After this method is called, all timeouts of agents being delayed are resumed, thus their timeouts totally get increased by amount of time spent between suspend() and resume() calls. Unblocks input port if there is a room for incoming agents.
Agent resume(Agent agent) - resumes previously suspended Delay (if was not suspended, throws error).
Agent suspend (Agent agent) - suspends this delay for the given timeout dt.
boolean isSuspended() - Returns suspended status of this Delay block: true, if the Delay is suspended, false - if not.
double getDelayTime(agent) - Returns the initial (chosen) delay time calculated for the given agent in this Delay (it considers possible delay prolongations by the extendDelay() function calls). In case of PULL protocol, the actual delay may be greater - when subsequent block cannot accept outgoing agents immediately.
double getElapsedTime(Agent agent ) - Returns the time spent by the given agent in this Delay. In case of PULL protocol, the returned value may exceed getDelayTime() - when subsequent block cannot accept agents immediately.
void stopDelay(Agent agent) - Stops delay for the given agent. If the argument evaluates to null all the agents are released.
void stopDelayForAll() - Stops delay for all the agents currently being delayed.
void extendDelay(Agent agent, double dt) - Extends delay for the given agent (if it is possible to pass null as an argument, all delayed agents will be affected).
int size() - Returns the number of agents currently being delayed.
T remove(Agent agent) - removes the given agent from the object and returns it.
T get(int i) - Returns the agent by index i. Note that this method is very slow and moreover the order of agents and their indexes aren't preserved and may be different at the next time moment.
resetStats() - Resets the statistics collected for this object.
Iterator<Agent> iterator() - Returns the iterator over agents (ordering: the first is at the exit, the last has the largest remaining time to be delayed).