All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class simulation.activity.Activity

java.lang.Object
   |
   +----simulation.activity.Activity

public abstract class Activity
extends java.lang.Object
This class may be used for activity-based discrete event simulation.

An activity is associated with a start condition, a specification of its duration, and some start and finish actions.

The start actions of an activity will be executed as soon as its associated condition becomes true. The finish actions will be executed when the activity ends (after a time period equal to the duration of the activity).

Activities are created as instances of Activity-derived classes that override the four abstract methods condition, startActions, duration and finishActions.

See Also:
simulation.activity.Simulation

Constructor Index

 o Activity()
This constructor creates an Activity and schedules it.

Method Index

 o cancel()
Cancels this scheduled activity.
 o runSimulation(double)
Runs a simulation for a specified period of simulated time.
 o schedule()
Schedules this activity.
Its start time depends on its condition.
 o stopSimulation()
Stops a simulation.
 o time()
Returns the current simulation time.

Constructors

 o Activity
 public Activity()
This constructor creates an Activity and schedules it.

Methods

 o time
 public static final double time()
Returns the current simulation time.

 o schedule
 public final void schedule()
Schedules this activity.
Its start time depends on its condition.

The activity is inserted at the back of the list of waiting activities.

 o cancel
 public final void cancel()
Cancels this scheduled activity.

The activity is removed from the the list of which it is a member (the event list or the wait list).

If it is not scheduled, the call has no effect.

 o runSimulation
 public static final void runSimulation(double period)
Runs a simulation for a specified period of simulated time.

Time will start at 0 and jump from event time to event time until either this period is over, there are no more actions to be executed, or the stopSimulation() method is called.

All activities waiting to start are held in a list, waitList. All activities that are scheduled to finish are held in a list, SQS, ordered by their associated finish times.

At each event time, the wait list is examined to see whether any activity may start. In that case, the activity is removed from the list, its start actions are executed, and a finish event is scheduled to occur when the activity finishes.

When no more activities may be started, time advances to the next imminent event, and the associated finish actions are executed.

This continues until the simulation ends.

Parameters:
period - The length of the simulation period.
 o stopSimulation
 public static final void stopSimulation()
Stops a simulation.


All Packages  Class Hierarchy  This Package  Previous  Next  Index