uchicago.src.sim.engine
Class Schedule

java.lang.Object
  extended by uchicago.src.sim.engine.BasicAction
      extended by uchicago.src.sim.engine.ScheduleBase
          extended by uchicago.src.sim.engine.Schedule
All Implemented Interfaces:
TickCounter
Direct Known Subclasses:
AsynchSchedule, CallBackSchedule

public class Schedule
extends ScheduleBase

Manages the execution of BasicActions (ActionGroups, SimActions, and SimListActions) according to a simulation clock. The clock is incremeneted at the completion of the execution of all the BasicActions scheduled for execution at that clock tick. A Schedule is itself a BasicAction and so Schedules can be added to other Schedules.

The actions scheduled on a Schedule will iterate with a simulated concurrency (i.e. in random order). If the actions should be executed in some specified order, the action should be added to an ActionGroup set for sequential execution. This ActionGroup can then be added to the Schedule for execution. Specifying the order in the scheduleActionAt and scheduleActionAtInterval methods can be used to insure that certain actions occur after other actions.

Version:
$Revision: 1.10 $ $Date: 2004/11/03 19:50:57 $
Author:
Nick Collier (Modified by Michael J. North)
See Also:
BasicAction, ActionGroup, SubSchedule

Nested Class Summary
 
Nested classes/interfaces inherited from class uchicago.src.sim.engine.ScheduleBase
ScheduleBase.Order
 
Field Summary
 
Fields inherited from class uchicago.src.sim.engine.ScheduleBase
actionQueue, CONCURRENT, groupToExecute, indexCount, LAST, lastGroup, lastQueue, preExecuted, randGroup, RANDOM, repeatInterval, ticks, topGroup
 
Fields inherited from class uchicago.src.sim.engine.BasicAction
INTERVAL_UPDATER, ONE_TIME_UPDATER, updater
 
Constructor Summary
Schedule()
          Constructs a schedule that with a default execution interval of 1.
Schedule(double executionInterval)
          Constructs a schedule that executes at the specified interval.
 
Method Summary
 void execute()
          Executes all the actions scheduled for the current clock tick.
 void executeEndActions()
          Executes all the actions scheduled to execute at simulation end.
 void executePauseActions()
          Executes all the actions scheduled to execute at a simulation pause.
 java.util.Vector getEndActions()
          Gets the Vector of BasicActions to execute at the end of the simulation run.
 java.util.Vector getPauseActions()
          Gets the Vector of BasicActions to execute during a pause in the simulation run.
 void removeEndAction(BasicAction action)
          Removes the specified action from the list of actions to be executed at the end of a simulation.
 void removePauseAction(BasicAction action)
          Removes the specified action from the list of actions to be executed at the pause in a simulation.
 BasicAction scheduleActionAtEnd(BasicAction action)
          Schedules the execution of the specified action for the end of the simulation run.
 BasicAction scheduleActionAtEnd(java.util.List list, java.lang.Class superClass, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for the end of the simulation.
 BasicAction scheduleActionAtEnd(java.util.List list, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for the end of the simulation.
 BasicAction scheduleActionAtEnd(java.lang.Object o, java.lang.String methodName)
          Schedules the execution of the specified method on the specified object for the end of the simulation run.
 BasicAction scheduleActionAtEndRnd(java.util.List list, java.lang.Class superClass, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for the end of the simulation.
 BasicAction scheduleActionAtEndRnd(java.util.List list, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for the end of the simulation.
 BasicAction scheduleActionAtPause(BasicAction action)
          Schedules the execution of the specified action for a pause in the simulation run.
 BasicAction scheduleActionAtPause(java.util.List list, java.lang.Class superClass, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for a pause in the simulation.
 BasicAction scheduleActionAtPause(java.util.List list, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for a pause in the simulation.
 BasicAction scheduleActionAtPause(java.lang.Object o, java.lang.String methodName)
          Schedules the execution of the specified method on the specified object for a pause in the simulation run.
 BasicAction scheduleActionAtPauseRnd(java.util.List list, java.lang.Class superClass, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for a pause in the simulation.
 BasicAction scheduleActionAtPauseRnd(java.util.List list, java.lang.String methodName)
          Schedules the execution of the specified method on every object in the specified List for a pause in the simulation.
 
Methods inherited from class uchicago.src.sim.engine.ScheduleBase
getCurrentTime, getCurrentTimeDouble, preExecute, removeAction, removeActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAt, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtInterval, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtIntervalRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionAtRnd, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginning, scheduleActionBeginningRnd, scheduleActionBeginningRnd, scheduleActionBeginningRnd, scheduleActionBeginningRnd
 
Methods inherited from class uchicago.src.sim.engine.BasicAction
addToGroup, getIntervalTime, getName, getNextTime, reSchedule, setIntervalTime, setName, setNextTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schedule

public Schedule()
Constructs a schedule that with a default execution interval of 1.

See Also:
Schedule(double)

Schedule

public Schedule(double executionInterval)
Constructs a schedule that executes at the specified interval. (i.e a schedule with an interval of 2 executes all its BasicActions every other clock tick. The master Schedule built in a model and used to execute all the actions in the simulation will typicaly have an interval of 1. Any sub schedules added to this "master" schedule might have other intervals.

Parameters:
executionInterval - the execution interval.
Method Detail

scheduleActionAtEnd

public BasicAction scheduleActionAtEnd(BasicAction action)
Schedules the execution of the specified action for the end of the simulation run. Excutes only once. Useful for writing data to a file at the end of the simulation.

Parameters:
action - the BasicAction to execute at the end of a run.

scheduleActionAtPause

public BasicAction scheduleActionAtPause(BasicAction action)
Schedules the execution of the specified action for a pause in the simulation run. Executes once for each pause event. Useful, for example, for updating the display on a pause if the display does not update every turn.

Parameters:
action - the BasicAction to execute when the simulation run is paused

scheduleActionAtEnd

public BasicAction scheduleActionAtEnd(java.lang.Object o,
                                       java.lang.String methodName)
Schedules the execution of the specified method on the specified object for the end of the simulation run. Excutes only once each simulation run. Useful for writing data to a file at the end of the simulation run.

Parameters:
o - the object on which the method will be called
methodName - the name of method to call on the object.

scheduleActionAtPause

public BasicAction scheduleActionAtPause(java.lang.Object o,
                                         java.lang.String methodName)
Schedules the execution of the specified method on the specified object for a pause in the simulation run. Executes once for each pause event. Useful for updating the display on a pause if the display does not update every turn.

Parameters:
o - the object on which the method will be called
methodName - the name of method to call on the object.

scheduleActionAtEnd

public BasicAction scheduleActionAtEnd(java.util.List list,
                                       java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for the end of the simulation. Excutes only once each simulation run. Useful for writing data to a file at the end of the simulation.

Parameters:
list - the List of objects on which the method will be called
methodName - the name of method to call on the object.

scheduleActionAtEndRnd

public BasicAction scheduleActionAtEndRnd(java.util.List list,
                                          java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for the end of the simulation. Excutes only once each simulation run. Useful for writing data to a file at the end of the simulation. The list will be randomized with SimUtilites.shuffle before the the method is called on the objects.

Parameters:
list - the List of objects on which the method will be called
methodName - the name of method to call on the object.
See Also:
SimUtilities

scheduleActionAtPause

public BasicAction scheduleActionAtPause(java.util.List list,
                                         java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for a pause in the simulation. Executes once for each pause event. Useful for updating the display on a pause if the display does not update every turn.

Parameters:
list - the List of objects on which the method will be called
methodName - the name of method to call on the object.

scheduleActionAtPauseRnd

public BasicAction scheduleActionAtPauseRnd(java.util.List list,
                                            java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for a pause in the simulation. Executes once for each pause event. Useful for updating the display on a pause if the display does not update every turn. The list will be randomized with SimUtilites.shuffle before the the method is called on the objects.

Parameters:
list - the List of objects on which the method will be called
methodName - the name of method to call on the object.
See Also:
SimUtilities

scheduleActionAtEnd

public BasicAction scheduleActionAtEnd(java.util.List list,
                                       java.lang.Class superClass,
                                       java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for the end of the simulation. Excutes only once each simulation run. Useful for writing data to a file at the end of the simulation. Assumes all objects in the list are instances of the specified class.

Parameters:
list - the List of objects on which the method will be called
superClass - the superclass of all the objects in the list.
methodName - the name of method to call on the object.

scheduleActionAtEndRnd

public BasicAction scheduleActionAtEndRnd(java.util.List list,
                                          java.lang.Class superClass,
                                          java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for the end of the simulation. Excutes only once each simulation run. Useful for writing data to a file at the end of the simulation. Assumes all objects in the list are instances of the specified class. The list will be randomized with SimUtilites.shuffle before the the method is called on the objects

Parameters:
list - the List of objects on which the method will be called
superClass - the superclass of all the objects in the list.
methodName - the name of method to call on the object.
See Also:
SimUtilities

scheduleActionAtPause

public BasicAction scheduleActionAtPause(java.util.List list,
                                         java.lang.Class superClass,
                                         java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for a pause in the simulation. Executes once for each pause event. Useful for updating the display on a pause if the display does not update every turn. Assumes all objects in the list are instances of the specified class.

Parameters:
list - the AList of objects on which the method will be called
superClass - the superclass of all the objects in the list.
methodName - the name of method to call on the object.

scheduleActionAtPauseRnd

public BasicAction scheduleActionAtPauseRnd(java.util.List list,
                                            java.lang.Class superClass,
                                            java.lang.String methodName)
Schedules the execution of the specified method on every object in the specified List for a pause in the simulation. Executes once for each pause event. Useful for updating the display on a pause if the display does not update every turn. Assumes all objects in the list are instances of the specified class. The list will be randomized with SimUtilites.shuffle before the the method is called on the objects

Parameters:
list - the AList of objects on which the method will be called
superClass - the superclass of all the objects in the list.
methodName - the name of method to call on the object.
See Also:
SimUtilities

removeEndAction

public void removeEndAction(BasicAction action)
Removes the specified action from the list of actions to be executed at the end of a simulation.

Parameters:
action - the action to remove

removePauseAction

public void removePauseAction(BasicAction action)
Removes the specified action from the list of actions to be executed at the pause in a simulation.

Parameters:
action - the action to remove

getEndActions

public java.util.Vector getEndActions()
Gets the Vector of BasicActions to execute at the end of the simulation run.

Returns:
the vector of BasicActions to execute at the end of the simuation run

getPauseActions

public java.util.Vector getPauseActions()
Gets the Vector of BasicActions to execute during a pause in the simulation run.

Returns:
the vector of BasicActions to execute during a pause in the simulation run.

execute

public void execute()
Executes all the actions scheduled for the current clock tick.

Specified by:
execute in class BasicAction

executeEndActions

public void executeEndActions()
Executes all the actions scheduled to execute at simulation end.


executePauseActions

public void executePauseActions()
Executes all the actions scheduled to execute at a simulation pause.