gnutant
Class GnutantScenario

java.lang.Object
  |
  +--gnutant.GnutantScenario
All Implemented Interfaces:
Clearable, ResponseListener, Scenario

public class GnutantScenario
extends java.lang.Object
implements Scenario, ResponseListener

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. A ScenarioImpl is composed of a Peernet and a ResourceSet object. Each resource included in the ResourceSet is inserted before starting the simulation in the Peernet. Then, the ResourceSet is used to generate a certain number of requests to be presented to the nests composing the network.

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

Field Summary
static java.lang.String DOCS_TO_DL
          String name of the parameter used to determine the percentage of documents to download upon receiving a set of documents as reply from the SearchGnutant.
protected  int docsDL
          Percentage of the satisfied requests to download
protected  Factory factory
          Factory used to instantiate objects
static java.lang.String INITAL_DOCS
          String name of the parameter used to determine the inital number of documents to be installed at each nest.
protected  int initDocsPrNest
          Initial documents per nest
protected  Keywords keywords
          Keywords holder.
protected  java.lang.String kwFile
          Keywords filename
protected  ResponseMonitor monitor
          Responses
protected  Peernet net
          Peernet on which the genetic code will be evaluated
protected  int netVersion
          Version identifier of the peer network; when init params change, the version increase
protected  int nrequests
          Number of requests to be issued per round
protected  int rounds
          Number of rounds to be performed
static java.lang.String SCENARIO_ROUNDS
          String name of the parameter used to determine the number of rounds which will be performed in this scenario.
protected  Stats stats
          Stats
 
Constructor Summary
GnutantScenario(Factory factory, int rounds, int nrequests, java.lang.String kwFile)
          Creates a new GnutantScenario instance.
GnutantScenario(Factory factory, int rounds, java.lang.String kwFile)
          Creates a new GnutantScenario instance.
 
Method Summary
 void clear()
          Restores the object to its initial state.
 void complete()
          Upcall method used to notify this listener that the request associated to it has finished to return resources.
 void evaluate()
          Perform the evaluation of this scenario object by simulating it.
 void returnResources(RequestId rid, Resource[] resources)
          Upcall method used to notify this listener that the request associated to it has returned the specified set of resources.
 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

SCENARIO_ROUNDS

public static final java.lang.String SCENARIO_ROUNDS
String name of the parameter used to determine the number of rounds which will be performed in this scenario.

INITAL_DOCS

public static final java.lang.String INITAL_DOCS
String name of the parameter used to determine the inital number of documents to be installed at each nest.

DOCS_TO_DL

public static final java.lang.String DOCS_TO_DL
String name of the parameter used to determine the percentage of documents to download upon receiving a set of documents as reply from the SearchGnutant.

factory

protected Factory factory
Factory used to instantiate objects

rounds

protected int rounds
Number of rounds to be performed

nrequests

protected int nrequests
Number of requests to be issued per round

kwFile

protected java.lang.String kwFile
Keywords filename

initDocsPrNest

protected int initDocsPrNest
Initial documents per nest

docsDL

protected int docsDL
Percentage of the satisfied requests to download

stats

protected Stats stats
Stats

monitor

protected ResponseMonitor monitor
Responses

net

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

netVersion

protected int netVersion
Version identifier of the peer network; when init params change, the version increase

keywords

protected Keywords keywords
Keywords holder.
Constructor Detail

GnutantScenario

public GnutantScenario(Factory factory,
                       int rounds,
                       java.lang.String kwFile)
Creates a new GnutantScenario instance.
Parameters:
factory - the factory object used to generate the peernet and the resource set contained in a scenario.
rounds - the number of rounds of the run.
kwFile - keyword file path.

GnutantScenario

public GnutantScenario(Factory factory,
                       int rounds,
                       int nrequests,
                       java.lang.String kwFile)
Creates a new GnutantScenario instance.
Parameters:
factory - the factory object used to generate the peernet and the resource set contained in a scenario.
rounds - the number of rounds of the run.
kwFile - keyword file path.
Method Detail

clear

public void clear()
Restores the object to its initial state. The network is re-initialized as an empty network.
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
Following copied from interface: anthill.antsim.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

returnResources

public void returnResources(RequestId rid,
                            Resource[] resources)
Upcall method used to notify this listener that the request associated to it has returned the specified set of resources.
Specified by:
returnResources in interface ResponseListener
Parameters:
resources - the resources found.

complete

public void complete()
Upcall method used to notify this listener that the request associated to it has finished to return resources. HEIN FIXME: How can we determine this?? ^^^
Specified by:
complete in interface ResponseListener