haifa.shopsim
Class ShopStateImpl

java.lang.Object
  |
  +--haifa.shopsim.ShopStateImpl
All Implemented Interfaces:
java.util.EventListener, ShopChangeListener, ShopState

public class ShopStateImpl
extends java.lang.Object
implements ShopState

This class represents the state of the jobshop at a given time instance as it is seen by an Algorithm. All the changes that occur during the simulation should be reflected in this class. This class is also used to schedule. (i.e. the scheduling algorithm should be able to generetate it's next command using the information in this class. Currently the state is the following:

  1. A Map of all of the sizes of all of the queues in the system.
  2. An array of booleans where the i'th element signifies if the i'th machine is vacant. (The array indexes are 0,....,shop.getN()-1). So element i actually refers to machine i+1.


Field Summary
private  int[] finishedJobs
          an array specifing how many finshed jobs per route.
private  boolean isRunning
          Indicates that the shop is running.
private  java.util.HashMap QMap
          A Map mapping Operation objects to sizes of queues.
private  java.util.ArrayList shopChangeListeners
          A list of all listeners to this state, that is all classes that should be notified when the state changes.
private  ShopData shopData
          A reference to the shop data object.
private  double time
          The current simulation time.
private  boolean[] workingMachines
          An array specifiing which of the machines is currently busy.
 
Constructor Summary
ShopStateImpl(ShopData shopData_)
          Cot'r builds state according to ShopData.
 
Method Summary
 void addShopChangeListener(ShopChangeListener scl)
          Register a listener to the state.
 java.util.Collection getBusyMachines()
          Returns a collection of all of the busy machines at the current time.
 int getNumFinishedJobs(int route)
          Returns the number of finsihed jobs on a particular route.
 java.util.Map getQMap()
           
 java.util.Collection getSchedulableOperations()
          Returns a collection of the schedulable operations.
 double getTime()
          Returns the time as registered with the state.
 int getTotalFinishedJobs()
          Returns the total number of finished jobs.
 void shopChanged(ShopChangeEvent sce)
           
 java.lang.String toString()
          Returns string representing the ShopState
 void update(java.util.Map opMap)
          Takes operation objects from opMap and updates relevant ones
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

isRunning

private boolean isRunning
Indicates that the shop is running.

QMap

private java.util.HashMap QMap
A Map mapping Operation objects to sizes of queues.

workingMachines

private boolean[] workingMachines
An array specifiing which of the machines is currently busy.

finishedJobs

private int[] finishedJobs
an array specifing how many finshed jobs per route.

time

private double time
The current simulation time.

shopData

private ShopData shopData
A reference to the shop data object.

shopChangeListeners

private java.util.ArrayList shopChangeListeners
A list of all listeners to this state, that is all classes that should be notified when the state changes.
Constructor Detail

ShopStateImpl

public ShopStateImpl(ShopData shopData_)
Cot'r builds state according to ShopData.
Method Detail

addShopChangeListener

public void addShopChangeListener(ShopChangeListener scl)
Register a listener to the state.
Specified by:
addShopChangeListener in interface ShopState

shopChanged

public void shopChanged(ShopChangeEvent sce)
Specified by:
shopChanged in interface ShopState

update

public void update(java.util.Map opMap)
Takes operation objects from opMap and updates relevant ones

toString

public java.lang.String toString()
Returns string representing the ShopState
Overrides:
toString in class java.lang.Object

getTime

public double getTime()
Returns the time as registered with the state.
Specified by:
getTime in interface ShopState

getBusyMachines

public java.util.Collection getBusyMachines()
Returns a collection of all of the busy machines at the current time.
Specified by:
getBusyMachines in interface ShopState

getTotalFinishedJobs

public int getTotalFinishedJobs()
Returns the total number of finished jobs.
Specified by:
getTotalFinishedJobs in interface ShopState

getNumFinishedJobs

public int getNumFinishedJobs(int route)
Returns the number of finsihed jobs on a particular route.
Specified by:
getNumFinishedJobs in interface ShopState

getQMap

public java.util.Map getQMap()
Specified by:
getQMap in interface ShopState

getSchedulableOperations

public java.util.Collection getSchedulableOperations()
Returns a collection of the schedulable operations.
Specified by:
getSchedulableOperations in interface ShopState