peersim.cdsim
Class CDSimulator

java.lang.Object
  extended by peersim.cdsim.CDSimulator

public class CDSimulator
extends java.lang.Object

This is the cycle driven simulation engine. It is a fully static singleton class. For a cycle driven simulation the configuration can describe a set of Protocols, and their ordering, a set of Controls and their ordering and a set of initializers and their ordering. See parameters "init", "control". Out of the set of protocols, this engine only executes the ones that implement the CDProtocol interface.

One experiment run by nextExperiment() works as follows. First the initializers are run in the specified order, then the following is iterated "simulation.cycles" times: If "simulation.nodefaultcycle" is specified, then simply the controls specified in the configuration are run in the specified order. If "simulation.nodefaultcycle" is not specified, then the controls in the configuration are run in the specified order, followed by the execution of FullNextCycle.

All components (controls and protocols) can have configuration parameters that control their scheduling (see Scheduler). This way they can skip cycles, start from a specified cycle, etc. As a special case, components can be scheduled to run after the last cycle. That is, each experiment is finished by running the controls that are scheduled after the last cycle.

Finally, any control can interrupt an experiment at any time it is executed by returning true in method Control.execute(). However, the controls scheduled to run after the last cycle are still executed completely, irrespective of their return value and even if the experiment was interrupted.

See Also:
Configuration

Parameter Summary
simulation.cycles
          Parameter representing the maximum number of cycles to be performed
simulation.nodefaultcycle
          This option is only for experts.
init
          This is the prefix for initializers.
control
          This is the prefix for controls.
 
Method Summary
static boolean isConfigurationCycleDriven()
          This method is used to check whether the current configuration can be used for cycle-driven simulations.
static void nextExperiment()
          Runs an experiment, resetting everything except the random seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

simulation.cycles

Parameter representing the maximum number of cycles to be performed


simulation.nodefaultcycle

This option is only for experts. It switches off the main cycle that calls the cycle driven protocols. When you switch this off, you need to control the execution of the protocols by configuring controls that do the job (e.g., FullNextCycle, NextCycle). It's there for people who want maximal flexibility for their hacks.


init

This is the prefix for initializers. These have to be of type Control. They are run at the beginning of each experiment, in the order specified by the configuration.

See Also:
Configuration

control

This is the prefix for controls. These have to be of type Control. They are run before each cycle, in the order specified by the configuration.

See Also:
Configuration
Method Detail

isConfigurationCycleDriven

public static final boolean isConfigurationCycleDriven()
This method is used to check whether the current configuration can be used for cycle-driven simulations. It checks for the existence of configuration parameter "simulation.cycles".


nextExperiment

public static final void nextExperiment()
Runs an experiment, resetting everything except the random seed.