Package jsl.modeling.elements
Class ActionSchedule
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.ActionSchedule
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
public class ActionSchedule extends SchedulingElement
This class allows the creation of a schedule that represents a list of actions with the time between each action specified. The user adds a ScheduleAction or a duration/action pair and can specify when the schedule should start invoking the actions with a start time. The actions can be repeated after all duration/action pairs have been invoked only if their total duration does not exceed the time remaining until the end of the action schedule's cycle length. Model m = Model.createModel(); ActionSchedule s = new ActionSchedule(m); s.addScheduledAction(eventAction1, 20, "action 1"); s.addScheduledAction(eventAction1, 15, "action 2"); After 20 time units, action 1 will be invoked, after another 15 time units action 2 will be invoked. This pattern will be repeated. Thus the duration represents the time until the action is invoked after the previous action (or start of the schedule).The entire schedule has a cycle length. The total of all the durations added must be less than the action schedule's cycle length. The schedule can be repeated after all actions have been completed. The default length of a schedule's cycle length is positive infinity
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
Fields Modifier and Type Field Description protected JSLEvent<java.lang.Object>
myActionEvent
Represents the event for the actions on the scheduleprotected java.util.Iterator<ScheduledAction>
myActionIterator
An iterator over the actionsprotected boolean
myActionRepeatFlag
Indicates whether or not the actions on the schedule should be repeated after completing all the scheduled actions.protected java.util.List<ScheduledAction>
myActions
Holds the actions to be invoked by timeprotected boolean
myAutomaticStartFlag
Indicates whether or not the schedule should be started automatically upon initialization, default is trueprotected double
myCycleStartTime
The time that the schedule started for its current cycleprotected double
myDurationTotal
Keeps track of the total of the durations that have been added to the schedule.protected JSLEvent<java.lang.Object>
myEndEvent
Represents the event for the end of the scheduleprotected double
myInitialStartTime
The time from the beginning of the replication to the time that the schedule is to startprotected ScheduledAction
myNextScheduledAction
The action that is currently scheduled, next to occurprotected double
myScheduleLength
Represents the total length of time of the schedule.protected boolean
myScheduleRepeatFlag
The schedule repeat flag controls whether or not the entire schedule will repeat after its entire duration has elapsed.protected JSLEvent<java.lang.Object>
myStartEvent
Represents the event scheduled to start the schedule-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description ActionSchedule(ModelElement parent)
ActionSchedule(ModelElement parent, double scheduleLength)
ActionSchedule(ModelElement parent, double startTime, double scheduleLength)
ActionSchedule(ModelElement parent, double startTime, double scheduleLength, boolean repeatSchedule, boolean repeatActions, boolean startAutomatically, java.lang.String name)
ActionSchedule(ModelElement parent, double startTime, double scheduleLength, java.lang.String name)
ActionSchedule(ModelElement parent, double scheduleLength, java.lang.String name)
ActionSchedule(ModelElement parent, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addScheduledAction(EventAction eventAction, double duration)
void
addScheduledAction(EventAction eventAction, double duration, java.lang.String name)
protected void
afterReplication()
This method should be overridden by subclasses that need actions performed after each replication.boolean
getActionRepeatFlag()
True means the scheduled actions will repeat after all actions have been invoked.boolean
getAutomaticStartFlag()
This flag indicates whether or not the action will automatically scheduled when initialize() is called.double
getCycleStartTime()
Returns the time that the schedule started its current cycledouble
getDurationRemainingOnSchedule()
Returns the amount of time left within the schedule cycle length for possible duration/actionsdouble
getDurationTotal()
Returns how much of the schedule's length has been covered by actionsdouble
getElapsedCycleTime()
The time that has elapsed into the current cycledouble
getInitialStartTime()
Gets the time after the beginning of the replication that represents the starting time for the scheduleint
getNumberOfActions()
The number of actions that have been scheduleddouble
getRemainingCycleTime()
The time remaining within the current cycledouble
getScheduleLength()
Gets the total length of the schedule.boolean
getScheduleRepeatFlag()
Returns whether or not the schedule will repeat after it reaches it lengthprotected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.protected void
scheduleNextAction()
void
scheduleStart()
Schedules the start of the schedule for the start time of the schedule if it has not already be startedvoid
setActionRepeatFlag(boolean repeatActionFlag)
True means the scheduled actions will repeat after all actions have been invoked.void
setAutomaticStartFlag(boolean flag)
Sets the flag that indicates whether or not the first action will automatically schedule when initialize() is called.protected void
setInitialStartTime(double startTime)
Sets the starting time after the beginning of the replication for the schedule to start.protected void
setScheduleLength(double scheduleLength)
Sets the total length of the schedulevoid
setScheduleRepeatFlag(boolean flag)
Sets whether or not the schedule will repeat after it reaches it length-
Methods inherited from class jsl.simulation.SchedulingElement
cancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication_, asString, beforeExperiment, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
-
-
-
Field Detail
-
myAutomaticStartFlag
protected boolean myAutomaticStartFlag
Indicates whether or not the schedule should be started automatically upon initialization, default is true
-
myActionRepeatFlag
protected boolean myActionRepeatFlag
Indicates whether or not the actions on the schedule should be repeated after completing all the scheduled actions. The default is to repeat the actions
-
myInitialStartTime
protected double myInitialStartTime
The time from the beginning of the replication to the time that the schedule is to start
-
myCycleStartTime
protected double myCycleStartTime
The time that the schedule started for its current cycle
-
myScheduleRepeatFlag
protected boolean myScheduleRepeatFlag
The schedule repeat flag controls whether or not the entire schedule will repeat after its entire duration has elapsed. The default is to repeat the schedule. The use of this flag only makes sense if a finite schedule length is specified
-
myScheduleLength
protected double myScheduleLength
Represents the total length of time of the schedule. The total of the durations added to the schedule cannot exceed this amount After this time has elapsed the entire schedule can repeat if the schedule repeat flag is true. The default is infinite.
-
myDurationTotal
protected double myDurationTotal
Keeps track of the total of the durations that have been added to the schedule.
-
myActions
protected java.util.List<ScheduledAction> myActions
Holds the actions to be invoked by time
-
myStartEvent
protected JSLEvent<java.lang.Object> myStartEvent
Represents the event scheduled to start the schedule
-
myActionEvent
protected JSLEvent<java.lang.Object> myActionEvent
Represents the event for the actions on the schedule
-
myEndEvent
protected JSLEvent<java.lang.Object> myEndEvent
Represents the event for the end of the schedule
-
myActionIterator
protected java.util.Iterator<ScheduledAction> myActionIterator
An iterator over the actions
-
myNextScheduledAction
protected ScheduledAction myNextScheduledAction
The action that is currently scheduled, next to occur
-
-
Constructor Detail
-
ActionSchedule
public ActionSchedule(ModelElement parent)
- Parameters:
parent
- the parent model element
-
ActionSchedule
public ActionSchedule(ModelElement parent, java.lang.String name)
- Parameters:
parent
- the parent model elementname
- the name of the ActionSchedule as a model element, must be unique
-
ActionSchedule
public ActionSchedule(ModelElement parent, double scheduleLength)
- Parameters:
parent
- the parent model elementscheduleLength
- The total time available for the schedule
-
ActionSchedule
public ActionSchedule(ModelElement parent, double startTime, double scheduleLength)
- Parameters:
parent
- the parent model elementstartTime
- The time that the schedule should startscheduleLength
- The total time available for the schedule
-
ActionSchedule
public ActionSchedule(ModelElement parent, double scheduleLength, java.lang.String name)
- Parameters:
parent
- the parent model elementscheduleLength
- The total time available for the schedulename
- the name of the ActionSchedule as a model element, must be unique
-
ActionSchedule
public ActionSchedule(ModelElement parent, double startTime, double scheduleLength, java.lang.String name)
- Parameters:
parent
- the parent model elementstartTime
- The time that the schedule should startscheduleLength
- The total time available for the schedulename
- the name of the ActionSchedule as a model element, must be unique
-
ActionSchedule
public ActionSchedule(ModelElement parent, double startTime, double scheduleLength, boolean repeatSchedule, boolean repeatActions, boolean startAutomatically, java.lang.String name)
- Parameters:
parent
- the parent model elementstartTime
- The time that the schedule should startscheduleLength
- The total time available for the schedulerepeatSchedule
- Whether or not the schedule will repeatrepeatActions
- Whether or not the actions may repeatstartAutomatically
- Whether or not the start of the schedule is scheduled automaticallyname
- the name of the ActionSchedule as a model element, must be unique
-
-
Method Detail
-
setAutomaticStartFlag
public final void setAutomaticStartFlag(boolean flag)
Sets the flag that indicates whether or not the first action will automatically schedule when initialize() is called.- Parameters:
flag
- true means start automatically
-
getAutomaticStartFlag
public final boolean getAutomaticStartFlag()
This flag indicates whether or not the action will automatically scheduled when initialize() is called. By default this option is true.- Returns:
- true means it starts automatically
-
getActionRepeatFlag
public final boolean getActionRepeatFlag()
True means the scheduled actions will repeat after all actions have been invoked. By default the scheduled actions will repeat.- Returns:
- Returns the repeatActionFlag.
-
setActionRepeatFlag
public final void setActionRepeatFlag(boolean repeatActionFlag)
True means the scheduled actions will repeat after all actions have been invoked. By default the scheduled actions will repeat.- Parameters:
repeatActionFlag
- The repeatActionFlag to set.
-
getInitialStartTime
public final double getInitialStartTime()
Gets the time after the beginning of the replication that represents the starting time for the schedule- Returns:
- the initial start time
-
setInitialStartTime
protected final void setInitialStartTime(double startTime)
Sets the starting time after the beginning of the replication for the schedule to start.- Parameters:
startTime
- Must be >= zero
-
getCycleStartTime
public final double getCycleStartTime()
Returns the time that the schedule started its current cycle- Returns:
- the time that the schedule started its current cycle
-
getElapsedCycleTime
public final double getElapsedCycleTime()
The time that has elapsed into the current cycle- Returns:
- time that has elapsed into the current cycle
-
getRemainingCycleTime
public final double getRemainingCycleTime()
The time remaining within the current cycle- Returns:
- time remaining within the current cycle
-
setScheduleRepeatFlag
public final void setScheduleRepeatFlag(boolean flag)
Sets whether or not the schedule will repeat after it reaches it length- Parameters:
flag
- true indicates it will repeat
-
getScheduleRepeatFlag
public final boolean getScheduleRepeatFlag()
Returns whether or not the schedule will repeat after it reaches it length- Returns:
- true indicates that it will repeat
-
setScheduleLength
protected final void setScheduleLength(double scheduleLength)
Sets the total length of the schedule- Parameters:
scheduleLength
- Must be > 0
-
getScheduleLength
public final double getScheduleLength()
Gets the total length of the schedule. The total length of the schedule must be >= the total of the durations on the schedule- Returns:
- the total length of the schedule.
-
getDurationRemainingOnSchedule
public final double getDurationRemainingOnSchedule()
Returns the amount of time left within the schedule cycle length for possible duration/actions- Returns:
- the amount of time left within the schedule cycle length for possible duration/actions
-
getDurationTotal
public final double getDurationTotal()
Returns how much of the schedule's length has been covered by actions- Returns:
- how much of the schedule's length has been covered by actions
-
getNumberOfActions
public final int getNumberOfActions()
The number of actions that have been scheduled- Returns:
- number of actions that have been scheduled
-
addScheduledAction
public final void addScheduledAction(EventAction eventAction, double duration)
- Parameters:
duration
- the duration from the start of the schedule, must be positiveeventAction
- the event action that will be invoked, cannot be null
-
addScheduledAction
public final void addScheduledAction(EventAction eventAction, double duration, java.lang.String name)
- Parameters:
duration
- the duration from the start of the schedule, must be positiveeventAction
- the event action that will be invoked, cannot be nullname
- the name of the scheduled action
-
scheduleStart
public final void scheduleStart()
Schedules the start of the schedule for the start time of the schedule if it has not already be started
-
initialize
protected void initialize()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called- Overrides:
initialize
in classModelElement
-
afterReplication
protected void afterReplication()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.- Overrides:
afterReplication
in classModelElement
-
scheduleNextAction
protected void scheduleNextAction()
-
-