|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--haifa.shopsim.fastkernel.FastShopRun
This class implements both a ShopSimualtion and a ShopState. It is a single thread "primitive" simulation of a job shop that does not keep information regarding the location of jobs. (It is called fast, because it is much faster than the intutive-to-program ShopRun class found in haifa.shopsim.kernel package (only up to version 0.3 of this project).
The FastShopRun is implemented by using an EventQ class.
Note that this class also implements a ShopState.
Listeners are to register to the FastShopRun using the addShopChangeListener() method.
Inner Class Summary | |
private class |
FastShopRun.Buffer
This class represents a queue entity. |
private class |
FastShopRun.Machine
This class represents a machine in the job shop. |
Field Summary | |
protected EventQ |
eventQ
The EventQ |
private double |
expectedLowerBound
The expected machine lower bound. |
private int[] |
finishedJobs
An array of integers counting how many finished jobs are in each route. |
private FastShopRun.Buffer[] |
firstBuffers
An array of references to the first buffer of each route. |
(package private) double |
lastRestUpdateTime
The last time during which the resting map was updated. |
protected java.util.ArrayList |
listeners
A list of listeners that are notified whenever the state changes. |
protected java.io.PrintWriter |
log
Message log. |
private FastShopRun.Machine[] |
machines
An array of machine objects. |
private int |
numBusyMachines
The number of busy machines. |
private int[] |
numSetJobs
Stores the Nr[] array as it was defined by the problem size chooser. |
protected PostRunAction |
postRunAction
The PostRunAction, the doAction() method is called after every run of the shop. |
protected ProblemSizeChooser |
problemSizeChooser
The problem size chooser. |
protected static long |
PROGRESS_STEP
Number of milliseconds between updates to log of '~' character showing that the simulation is running. |
private java.util.HashMap |
Qmap
A map of the buffers where the keys are operations and the values are Integer objects. |
private java.util.HashMap |
QPlusMap
A map of the buffers where the keys are operations and the values are Integer objects. |
protected RandomTimeMaker |
randomTimeMaker
The random time maker. |
(package private) java.util.HashMap |
restingMap
This is a map where the keys are Integers for machine numbers and the values are doubles that specify the time at which a machine was scheduled to rest. |
protected ShopAlgorithm |
shopAlgorithm
The algorithm that is used for the run. |
protected ShopData |
shopData
The job shop data. |
private long |
startTimeMillis
The start time of the last time the go() method was called. |
protected double |
time
The system time |
private int |
totalFinishedJobs
The total number of finsihed jobs (equals the sum of finishedJobs) |
Fields inherited from interface haifa.shopsim.ShopSimulation |
MAX_SIM_TIME |
Constructor Summary | |
FastShopRun(ShopAlgorithm shopAlgorithm_,
ShopData shopData_)
Creates a new FastShopRun, setting the log to stdout. |
|
FastShopRun(ShopAlgorithm shopAlgorithm_,
ShopData shopData_,
PostRunAction postRunAction_,
java.io.PrintWriter log_)
Creates new FastShopRun. |
Method Summary | |
void |
addShopChangeListener(ShopChangeListener scl)
Registers an additional shop change listner. |
boolean |
askAgainAtCurrentTime(int machineNumber)
Instructs the shop simulation to ask the algorithm for another ShopCommand for the specific machine number at the current simulation time. |
private void |
buildShop()
Auxillary method for the constructors. |
int[] |
getBusyMachines()
Returns a collection of all of the busy machines at the current time. |
double |
getExpectedMachineLowerBound()
Returns the maximum of getExpectedProcessingTimes(). |
double |
getExpectedProcessingTime(int machine)
Uses the getInitialNr result and the means in the shop data to calcualte how much time a machine is expected to process. |
double[] |
getExpectedProcessingTimes()
Returns an array with the expectedProcssing time for each machine. |
int[] |
getFreeMachines()
Returns a collection of all of the free machines at the current time. |
int[] |
getInitialNr()
Returns the size of the shop as it was set by the problem size chooser. |
Operation[] |
getMachineActivities()
Returns an array of Operation objects, with a length the same as the number of machines in the shop. |
int |
getNumFinishedJobs(int route)
Returns the number of finsihed jobs on a particular route. |
java.util.Map |
getQMap()
Returns a Qmap. |
java.util.Map |
getQPlusMap()
Returns a Map whose keys are operation objects (meaning the queues waiting for each opeartion). |
java.util.Collection |
getSchedulableOperations()
Returns a collection of the schedulable operations. |
java.util.Collection |
getSchedulableOperations(int machineNumber)
Returns a collection of the schedulable operations for a specific machine. |
double |
getTime()
Returns the time as registered with the state. |
int |
getTotalFinishedJobs()
Returns the total number of finished jobs. |
void |
go()
Start the simulation. |
boolean |
isMachineDone(int machineNumber)
Returns true if the machine does not have anymore jobs left to do in the job shop. |
boolean |
isMachineStarved(int machineNumber)
Returns true if the machine has jobs upstream (as specified in the QPlusMap) and it's buffers are empty. |
protected void |
notifyListeners(ShopChangeEvent sce)
Iterate over all of the listeners and send the the ShopChangeEvent. |
private void |
performSchedulingCommand(ShopCommand sc)
Changes the state of the shop accoring to the shop command. |
void |
setProblemSizeChooser(ProblemSizeChooser problemSizeChooser_)
Set the ProblemSizeChooser. |
void |
setRandomTimeMaker(RandomTimeMaker randomTimeMaker_)
Set the randomTimeMaker. |
private void |
setUp()
Sets up toward running the simulation. |
java.lang.String |
toRichString()
Returns a rich represntation of the shop. |
java.lang.String |
toString()
|
private void |
updateMachines(int[] wakingMachines)
Take array of indexes of machines that came off the eventQ. |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected java.io.PrintWriter log
protected ShopData shopData
protected ShopAlgorithm shopAlgorithm
protected PostRunAction postRunAction
protected ProblemSizeChooser problemSizeChooser
protected RandomTimeMaker randomTimeMaker
protected java.util.ArrayList listeners
protected static final long PROGRESS_STEP
protected EventQ eventQ
private FastShopRun.Machine[] machines
private int[] finishedJobs
private int totalFinishedJobs
private FastShopRun.Buffer[] firstBuffers
protected double time
private int numBusyMachines
private java.util.HashMap Qmap
private java.util.HashMap QPlusMap
private long startTimeMillis
private int[] numSetJobs
private double expectedLowerBound
java.util.HashMap restingMap
double lastRestUpdateTime
Constructor Detail |
public FastShopRun(ShopAlgorithm shopAlgorithm_, ShopData shopData_, PostRunAction postRunAction_, java.io.PrintWriter log_)
public FastShopRun(ShopAlgorithm shopAlgorithm_, ShopData shopData_)
Method Detail |
private void buildShop()
public void go()
go
in interface ShopSimulation
private void updateMachines(int[] wakingMachines)
private void performSchedulingCommand(ShopCommand sc)
private void setUp()
public boolean askAgainAtCurrentTime(int machineNumber)
If the machine is not scheduled as resting at the current time, then the shop simulation will not ask the algorithm and will return a false value (other wise, it returns a true value).
askAgainAtCurrentTime
in interface ShopSimulation
public double getTime()
getTime
in interface ShopState
public int[] getBusyMachines()
getBusyMachines
in interface ShopState
public int[] getFreeMachines()
getFreeMachines
in interface ShopState
public java.util.Collection getSchedulableOperations()
getSchedulableOperations
in interface ShopState
public java.util.Collection getSchedulableOperations(int machineNumber)
getSchedulableOperations
in interface ShopState
public int getTotalFinishedJobs()
getTotalFinishedJobs
in interface ShopState
public int getNumFinishedJobs(int route)
getNumFinishedJobs
in interface ShopState
public boolean isMachineDone(int machineNumber)
isMachineDone
in interface ShopState
public boolean isMachineStarved(int machineNumber)
isMachineStarved
in interface ShopState
public java.util.Map getQMap()
getQMap
in interface ShopState
public java.util.Map getQPlusMap()
getQPlusMap
in interface ShopState
public int[] getInitialNr()
getInitialNr
in interface ShopState
public double getExpectedProcessingTime(int machine)
getExpectedProcessingTime
in interface ShopState
public double[] getExpectedProcessingTimes()
getExpectedProcessingTimes
in interface ShopState
public double getExpectedMachineLowerBound()
getExpectedMachineLowerBound
in interface ShopState
public Operation[] getMachineActivities()
getMachineActivities
in interface ShopState
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toRichString()
public void addShopChangeListener(ShopChangeListener scl)
addShopChangeListener
in interface ShopSimulation
protected void notifyListeners(ShopChangeEvent sce)
public void setProblemSizeChooser(ProblemSizeChooser problemSizeChooser_)
setProblemSizeChooser
in interface ShopSimulation
public void setRandomTimeMaker(RandomTimeMaker randomTimeMaker_)
setRandomTimeMaker
in interface ShopSimulation
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |