Package repast.simphony.engine.schedule
Class AbstractAction
java.lang.Object
repast.simphony.engine.schedule.AbstractAction
- All Implemented Interfaces:
IAction
,ISchedulableAction
- Direct Known Subclasses:
DefaultAction
,ThreadedAction
Abstract base action used by the default scheduling mechanism.
- Author:
- Nick Collier
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Reschedules this AbstractAction for execution by resetting its nextTime to the last time it executed plus the interval of execution.protected static class
Empty implementation because an action scheduled not to repeat does not need to be rescheduled.protected static interface
An rescheduler is responsible for rescheduling an action in the ActionQueue. -
Field Summary
Modifier and TypeFieldDescriptionprotected Frequency
The Frequency of this AbstractAction.protected double
The interval at which to execute this action.protected double
The next clock tick that this AbstractAction should be executed.protected boolean
If the action is a back-end action (true) or if it is a model action (false).protected double
The priority of this AbstractAction with respect to other actions scheduled for the same clock tick.protected PriorityType
protected AbstractAction.Rescheduler
The Rescheduler used by this AbstractAction to reschedule it for execution. -
Constructor Summary
ConstructorDescriptionAbstractAction
(ScheduleParameters params) Creates an AbstractAction using the specified ScheduleParameters.AbstractAction
(ScheduleParameters params, long orderIndex) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addForExecution
(ScheduleGroup group) Add this ScheduableAction to the specified group for execution.double
Returns the next time this AbstractAction should be executed.long
Gets an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.double
Gets the priority of this action.Gets the PriorityType of this action.boolean
This is used by the schedule to determine if the action is a model related action or a back-end action.void
reschedule
(ActionQueue queue) Reschedule this AbstractAction for execution.protected void
setFrequency
(Frequency freq) Sets the frequency of this AbstractAction.protected void
setIsNonModelAction
(boolean nonModelAction) protected void
setIsNonModelAction
(IAction action)
-
Field Details
-
frequency
The Frequency of this AbstractAction. -
nextTime
protected double nextTimeThe next clock tick that this AbstractAction should be executed. -
pType
-
interval
protected double intervalThe interval at which to execute this action. -
priority
protected double priorityThe priority of this AbstractAction with respect to other actions scheduled for the same clock tick. -
nonModelAction
protected boolean nonModelActionIf the action is a back-end action (true) or if it is a model action (false). -
rescheduler
The Rescheduler used by this AbstractAction to reschedule it for execution.
-
-
Constructor Details
-
AbstractAction
-
AbstractAction
Creates an AbstractAction using the specified ScheduleParameters. The AbstractAction's scheduling data is set from the ScheduleParameters argument.- Parameters:
params
- the scheduling data used by this AbstractAction
-
-
Method Details
-
getNextTime
public double getNextTime()Returns the next time this AbstractAction should be executed.- Specified by:
getNextTime
in interfaceISchedulableAction
- Returns:
- the next time this AbstractAction should be executed.
-
setIsNonModelAction
-
setIsNonModelAction
protected void setIsNonModelAction(boolean nonModelAction) -
isNonModelAction
public boolean isNonModelAction()Description copied from interface:ISchedulableAction
This is used by the schedule to determine if the action is a model related action or a back-end action. NormalIAction
s useNonModelAction
to specify this, butISchedulableAction
s should use this method.- Specified by:
isNonModelAction
in interfaceISchedulableAction
- Returns:
- if this is a back-end type action or not
-
setFrequency
Sets the frequency of this AbstractAction.- Parameters:
freq
- the new Frequency of execution of this AbstractAction.
-
reschedule
Reschedule this AbstractAction for execution.- Specified by:
reschedule
in interfaceISchedulableAction
-
addForExecution
Add this ScheduableAction to the specified group for execution.- Specified by:
addForExecution
in interfaceISchedulableAction
- Parameters:
group
- the group to add the ISchedulableAction to.
-
getPriority
public double getPriority()Gets the priority of this action. The priority refers to this AbstractAction's place in the order of execution with respect to all the other actions that will execute at the same clock tick. The range is from Double.NEGATIVE_INFINITY (execute first) to Double.POSITIVE_INFINITY (execute last). The default is ScheduleParameters.RANDOM_PRIORITY which means the priority will be randomly assigned from a uniform distribution.- Specified by:
getPriority
in interfaceISchedulableAction
- Returns:
- the priority of this AbstractAction.
-
getPriorityType
Description copied from interface:ISchedulableAction
Gets the PriorityType of this action.- Specified by:
getPriorityType
in interfaceISchedulableAction
- Returns:
- the PriorityType of this action.
-
getOrderIndex
public long getOrderIndex()Gets an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.- Specified by:
getOrderIndex
in interfaceISchedulableAction
- Returns:
- an index indicating where this IAction was added to a schedule w/r to all other actions added to a schedule.
-