ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.queue
Class DequeueEvent

java.lang.Object
  extended by umontreal.iro.lecuyer.simevents.Event
      extended by umontreal.iro.lecuyer.contactcenters.queue.DequeueEvent
All Implemented Interfaces:
Cloneable, Comparable<Event>, ContactStepInfo

public final class DequeueEvent
extends Event
implements ContactStepInfo, Cloneable

Represents an event happening when a contact leaves a waiting queue without being explicitly removed. This event also holds the necessary information about a contact in queue and is added to the waiting queue's data structure. When it becomes obsolete, it can be used to keep track of the queueing step of the concerned contact. For this reason, the event implements the ContactStepInfo interface.

Note that the natural ordering of dequeue events corresponds to ascending order of automatic removal from queue, not the order of insertion. This is adapted for insertion of dequeue events in event lists, not for priority queues. The class DequeueEventComparator must be used to impose the order of insertion, for priority queues. This comparator is used when calling the default constructor of PriorityWaitingQueue and QueueWaitingQueue.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.simevents.Event
eventTime, priority, sim
 
Constructor Summary
protected DequeueEvent(WaitingQueue queue, Contact contact, double enqueueTime)
          Constructs a new dequeue event with contact contact entering waiting queue queue at simulation time enqueueTime.
 
Method Summary
 void actions()
           
 DequeueEvent clone()
          Returns a copy of this event.
 DequeueEvent clone(Contact clonedContact)
          Similar to clone(), but initializes the contact of the cloned event with clonedContact instead of a clone of the contact returned by getContact().
 int compareTo(DequeueEvent ev)
          Compares this dequeue event with the other event ev.
 boolean dequeued()
          Indicates that the contact has left the queue and that this event is obsolete.
 Contact getContact()
          Returns a reference to the queued contact.
 int getEffectiveDequeueType()
          Returns the effective dequeue type of the contact having waited in this queue.
 double getEffectiveQueueTime()
          Returns the simulation time the contact has effectively spent in queue.
 double getEndingTime()
          Returns the simulation time at which this step ended.
 double getEnqueueTime()
          Returns the simulation time at which the contact was enqueued.
 int getScheduledDequeueType()
          Returns the scheduled dequeue type of the contact if this event occurs.
 double getScheduledQueueTime()
          Returns the scheduled queue time for this contact.
 double getStartingTime()
          Returns the simulation time at which this step started.
 WaitingQueue getWaitingQueue()
          Returns a reference to the waiting queue.
 boolean isObsolete()
          Determines if this event is obsolete.
 boolean remove(int dqType1)
          Removes this dequeue event from its associated waiting queue, with dequeue type dqType.
 void setScheduledDequeueType(int dqType)
          Changes the dequeue type of the contact to dqType when the event occurs.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.simevents.Event
cancel, cancel, compareTo, getRa, priority, reschedule, schedule, scheduleAfter, scheduleBefore, scheduleNext, setPriority, setRa, setSimulator, setTime, simulator, time
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DequeueEvent

protected DequeueEvent(WaitingQueue queue,
                       Contact contact,
                       double enqueueTime)
Constructs a new dequeue event with contact contact entering waiting queue queue at simulation time enqueueTime.

This constructor is rarely used directly; the recommended way to create dequeue events is to use WaitingQueue.add(Contact).

Parameters:
queue - the associated waiting queue.
contact - the contact being queued.
enqueueTime - the time at which the contact enters the queue.
Method Detail

getContact

public Contact getContact()
Returns a reference to the queued contact.

Specified by:
getContact in interface ContactStepInfo
Returns:
a reference to the queued contact.

getWaitingQueue

public WaitingQueue getWaitingQueue()
Returns a reference to the waiting queue.

Returns:
a reference to the waiting queue.

getEnqueueTime

public double getEnqueueTime()
Returns the simulation time at which the contact was enqueued.

Returns:
the contact's enqueue time.

getStartingTime

public double getStartingTime()
Description copied from interface: ContactStepInfo
Returns the simulation time at which this step started.

Specified by:
getStartingTime in interface ContactStepInfo
Returns:
the start time of the step.

getEndingTime

public double getEndingTime()
Description copied from interface: ContactStepInfo
Returns the simulation time at which this step ended.

Specified by:
getEndingTime in interface ContactStepInfo
Returns:
the end time of the step.

getScheduledQueueTime

public double getScheduledQueueTime()
Returns the scheduled queue time for this contact. This corresponds to the maximal time the contact can spend in queue before being automatically removed, if this event occurs.

Returns:
the contact's scheduled queue time.

getScheduledDequeueType

public int getScheduledDequeueType()
Returns the scheduled dequeue type of the contact if this event occurs. This scheduled dequeue type can be overridden when a contact is manually removed.

Returns:
the contact's scheduled dequeue type.

setScheduledDequeueType

public void setScheduledDequeueType(int dqType)
Changes the dequeue type of the contact to dqType when the event occurs. If this is called after the contact was dequeued, an IllegalStateException is thrown.

Parameters:
dqType - the new type of removal.
Throws:
IllegalStateException - if the contact was dequeued.

getEffectiveQueueTime

public double getEffectiveQueueTime()
Returns the simulation time the contact has effectively spent in queue.

Returns:
the effective queue time.
Throws:
IllegalStateException - if the contact is still in queue.

getEffectiveDequeueType

public int getEffectiveDequeueType()
Returns the effective dequeue type of the contact having waited in this queue. Throws an IllegalStateException if the contact is still in queue.

Returns:
the effective dequeue type.
Throws:
IllegalStateException - if the contact is still in queue.

remove

public boolean remove(int dqType1)
Removes this dequeue event from its associated waiting queue, with dequeue type dqType. Returns true if and only if the removal was successful. This method calls getWaitingQueue() .remove (this, dqType), and returns the result.

Parameters:
dqType1 - the dequeue type.
Returns:
the success indicator of the operation.

dequeued

public boolean dequeued()
Indicates that the contact has left the queue and that this event is obsolete. If an obsolete event is scheduled, an IllegalStateException is thrown at the time it happens. The event can be used as a data structure to keep a trace of the queueing process of the contact.

Returns:
the dequeue indicator.

isObsolete

public boolean isObsolete()
Determines if this event is obsolete. When calling WaitingQueue.init(), some dequeue events might still be in the simulator's event list. One must use this method in actions() to test if this event is obsolete. If that returns true, one should return immediately.

Returns:
true for an obsolete event, false otherwise.

actions

public void actions()
Specified by:
actions in class Event

compareTo

public int compareTo(DequeueEvent ev)
Compares this dequeue event with the other event ev. The method extracts the Contact object from this event and from the ev argument. The Contact.compareTo(Contact) method is then used to compare objects. A contact that cannot be extracted is assigned the null value and precedes any non-null contacts.

Parameters:
ev - the other event being compared.
Returns:
the result of the comparison.

toString

public String toString()
Overrides:
toString in class Object

clone

public DequeueEvent clone()
Returns a copy of this event. This method clones every field of the event, except the waiting queue which is not cloneable.

Overrides:
clone in class Object

clone

public DequeueEvent clone(Contact clonedContact)
Similar to clone(), but initializes the contact of the cloned event with clonedContact instead of a clone of the contact returned by getContact(). This method can be useful when cloning a contact c for which c.getSteps() returns a non-empty list containing dequeue events. In that case, the contact associated with the events included in c.getSteps() must correspond to c rather than clones of c.

Specified by:
clone in interface ContactStepInfo
Parameters:
clonedContact - the contact being cloned.
Returns:
the clone of this data object.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.