haifa.shopsim.fastkernel
Class EventQ

java.lang.Object
  |
  +--haifa.shopsim.fastkernel.EventQ

public class EventQ
extends java.lang.Object

This class keeps a record of the next events in the machine world that are to occur. It is designed specfically for the job shop setting. An event is simply defined by a machine. The methods getNextTime() and getNextMachines are to be used with care. The getNextTime method should be called before the getNextMachines method. This is because the getNextTime method does not alter the Q while the getNextMachines methods removes the next machines from the Q.

Version:
1.1

Inner Class Summary
(package private)  class EventQ.Event
          A node in the event Q. pnext points to null if this is the head of the queue. pprev points to null if this is the tail of the queue.
 
Field Summary
(package private)  int numInQ
          Stores how many events are currently in the queue.
protected  EventQ.Event phead
          Points to the head event of the queue
protected  EventQ.Event ptail
          Points to the tail event (highest time) of the queue.
 
Constructor Summary
EventQ()
          Creates new empty EventQ.
 
Method Summary
(package private)  double getMachineTime(int number)
          Returns the earliest time that the machine is scheduled on or -1.0 if it is not scheduled.
(package private)  int[] getNextMachines()
          Returns an array of the machine numbers of the next machines in the Q (machines with earliest time).A meachine may appear several times in this array.
(package private)  double getNextTime()
          Returns the time of the next event in the Q.
static void main(java.lang.String[] args)
          For testing.
 void removeMachine(int number)
          Removes a machine from the EventQ.
 void removeMachine(int number, double untilTime)
          Removes all events of a machine from the EventQ which are before untilTime.
(package private)  void scheduleMachine(int machine, double endTime)
          Schedules an event for a machine to wake up at endTime.
private  void testAdd(int machine, double time)
           
private  void testRemove(int machine)
           
private  void testRemoveNext()
          For testing.
 java.lang.String toString()
          Generates string of all events starting at the head.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

phead

protected EventQ.Event phead
Points to the head event of the queue

ptail

protected EventQ.Event ptail
Points to the tail event (highest time) of the queue.

numInQ

int numInQ
Stores how many events are currently in the queue.
Constructor Detail

EventQ

public EventQ()
Creates new empty EventQ.
Method Detail

getNextMachines

int[] getNextMachines()
Returns an array of the machine numbers of the next machines in the Q (machines with earliest time).A meachine may appear several times in this array. The length of this array may often be 1.

getNextTime

double getNextTime()
Returns the time of the next event in the Q. Returns -1.0 if the Q is empty.

getMachineTime

double getMachineTime(int number)
Returns the earliest time that the machine is scheduled on or -1.0 if it is not scheduled.

scheduleMachine

void scheduleMachine(int machine,
                     double endTime)
Schedules an event for a machine to wake up at endTime.

removeMachine

public void removeMachine(int number)
Removes a machine from the EventQ. (Removes all event with current machine).

removeMachine

public void removeMachine(int number,
                          double untilTime)
Removes all events of a machine from the EventQ which are before untilTime. (Removes all event with current machine).

toString

public java.lang.String toString()
Generates string of all events starting at the head.
Overrides:
toString in class java.lang.Object

testAdd

private void testAdd(int machine,
                     double time)

testRemove

private void testRemove(int machine)

testRemoveNext

private void testRemoveNext()
For testing.

main

public static void main(java.lang.String[] args)
For testing.