antsim.impl
Class ScenarioImpl

java.lang.Object
  |
  +--antsim.impl.ScenarioImpl
All Implemented Interfaces:
Clearable, Scenario

public class ScenarioImpl
extends Object
implements Scenario

Class ScenarioImpl is a simple implementation of interface Scenario in which a predefined set of resources is inserted in the network and then a certain number of requests are performed and simulate. Initial resources are generated and distributed in the network using a ResourceGenerator object; at runtime, requests are generated using a RequestGenerator object.

Version:
$Revision: 1.7 $
Author:
Alberto Montresor
, Hein Meling

Field Summary
protected  ScenarioAnalyzer analyzer
          Scenario analyzer used to display information about the behavior of the ant algorithm.
protected  Factory factory
          Factory used to instantiate objects
protected  int finalRounds
          Final rounds to be performed; during this phase, requests are not generated and statistics are computed
protected  int initRounds
          Initialization rounds to be performed; during this phase, requests are generated and statistics are not computed
protected  ResponseMonitor monitor
          Response monitor to evaluate response time
static String PAR_FINALROUNDS
          String name of the parameter used to determine
static String PAR_INITROUNDS
          String name of the parameter used to determine
static String PAR_REGULARROUNDS
          String name of the parameter used to determine
protected  Peernet peernet
          Peernet on which the genetic code will be evaluated
protected  int regularRounds
          Regular rounds to be performed; during this phase, requests are generated and statistics are computed
protected  RequestGenerator requestGenerator
          Request generator used to generate run-time requests
protected  ResourceDistribution resourceDistribution
          Resource distribution used to distribute initial resources
protected  ResourceSet resourceSet
          Set containing the initial resources
protected  Stats stats
          Stats
 
Fields inherited from interface antsim.Scenario
NAME
 
Constructor Summary
ScenarioImpl(Factory factory, String name)
          Instantiates a new ScenarioImpl.
 
Method Summary
 void analyze(Stats stats)
          Analyze the scenario object by displaying information about it.
 void clear()
          Restores the object to its initial state.
 void evaluate()
          Perform the evaluation of this scenario object by simulating it.
 void setStats(Stats stats)
          Set the statistics object which will be used throughout the scenario evaluation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAR_INITROUNDS

public static final String PAR_INITROUNDS
String name of the parameter used to determine

See Also:
Constant Field Values

PAR_REGULARROUNDS

public static final String PAR_REGULARROUNDS
String name of the parameter used to determine

See Also:
Constant Field Values

PAR_FINALROUNDS

public static final String PAR_FINALROUNDS
String name of the parameter used to determine

See Also:
Constant Field Values

initRounds

protected int initRounds
Initialization rounds to be performed; during this phase, requests are generated and statistics are not computed


regularRounds

protected int regularRounds
Regular rounds to be performed; during this phase, requests are generated and statistics are computed


finalRounds

protected int finalRounds
Final rounds to be performed; during this phase, requests are not generated and statistics are computed


factory

protected Factory factory
Factory used to instantiate objects


stats

protected Stats stats
Stats


peernet

protected Peernet peernet
Peernet on which the genetic code will be evaluated


resourceSet

protected ResourceSet resourceSet
Set containing the initial resources


resourceDistribution

protected ResourceDistribution resourceDistribution
Resource distribution used to distribute initial resources


requestGenerator

protected RequestGenerator requestGenerator
Request generator used to generate run-time requests


monitor

protected ResponseMonitor monitor
Response monitor to evaluate response time


analyzer

protected ScenarioAnalyzer analyzer
Scenario analyzer used to display information about the behavior of the ant algorithm.

Constructor Detail

ScenarioImpl

public ScenarioImpl(Factory factory,
                    String name)
Instantiates a new ScenarioImpl.

Parameters:
factory - the factory to be used to read configuration arguments and to create other configurable objects
name - the name that is associated to this instance in the configuration file
Method Detail

clear

public void clear()
Restores the object to its initial state.

Specified by:
clear in interface Clearable

setStats

public void setStats(Stats stats)
Set the statistics object which will be used throughout the scenario evaluation.

Specified by:
setStats in interface Scenario
Parameters:
stats - the object used to collect statistics

evaluate

public void evaluate()
Perform the evaluation of this scenario object by simulating it. The simulation is subdivided in rounds. At each iteration, a new request is generated and assigned to one of the nest included in the simulated peer network, which generates an ant for it. Furthermore, for each nest, an ant included in the manager queue is selected and its run() method is executed. Statistics about the simulated execution of the code are collected in the Stats object specified through method setStats().

Specified by:
evaluate in interface Scenario

analyze

public void analyze(Stats stats)
Analyze the scenario object by displaying information about it. The behavior of this method is delagated to an instance of ScenarioAnalyzer.

Specified by:
analyze in interface Scenario