cz.cuni.amis.pogamut.base.agent.utils.runner.impl
Class AgentDescriptor<PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>

Package class diagram package AgentDescriptor
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentDescriptor<PARAMS,MODULE>
Type Parameters:
PARAMS -
MODULE -
All Implemented Interfaces:
IAgentDescriptor<PARAMS,MODULE>

public class AgentDescriptor<PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>
extends Object
implements IAgentDescriptor<PARAMS,MODULE>

Base implementation of the IAgentDescriptor. It specify which agents and how many should be instantiated and which parameters they should be given.

See the interface (IAgentDescriptor) for more info.

Have checked the javadoc for IAgentDescriptor? Good. Now you might be wondering, about number of agents that are going to be instantiated. Here are the scenarios again:

  1. You will specify only number of agents via setCount(int) - in this case, the IMultipleAgentRunner will instantiate specified number of agents with default parameters
  2. You will specify only parameters of the agents via either setAgentParameters(IAgentParameters[]) or addParams(IAgentParameters...) - in this case, the IMultipleAgentRunner will instantiate the same number of agents as there are parameters
  3. You will specify both, count and parameters - in this case it depends on the relation between set count and number of parameters

    If count > number of parameters - the IMultipleAgentRunner will instantiate 'count' of agents and first 'number of parameters' will have custom params as specified, rest will have defaults

    If count == number of parameters - same as the case 2

    If count < number of parameters - the IMultipleAgentRunner will instancitate 'count' of agents using first 'count' of 'parameters' passed

The exact number of agents that will be instantiated can be obtained from the getCount() that not necessarily match the number you will pass into it through setCount(int) because of described possibilities.

Author:
Jimmy

Constructor Summary
AgentDescriptor()
           
 
Method Summary
 AgentDescriptor<PARAMS,MODULE> addParams(PARAMS... params)
          Adds parameters for another agents.
 MODULE getAgentModule()
          Agent module that contains bindings for the classes, used by GuiceAgentFactory (or concretely by the Guice) to instantiate the agent.
 PARAMS[] getAgentParameters()
          Respective parameters of the agents.
 int getCount()
          Returns number of agents to be instantiated using current getAgentModule().
 AgentDescriptor<PARAMS,MODULE> setAgentModule(MODULE module)
          Sets agent module to be used for the instantiation of the agent.
 AgentDescriptor<PARAMS,MODULE> setAgentParameters(PARAMS[] params)
          Clears all the params stored within AgentDescriptor and assigns 'params'.
 AgentDescriptor<PARAMS,MODULE> setCount(int count)
          Set number of agents to be instantiated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentDescriptor

public AgentDescriptor()
Method Detail

getAgentModule

public MODULE getAgentModule()
Description copied from interface: IAgentDescriptor
Agent module that contains bindings for the classes, used by GuiceAgentFactory (or concretely by the Guice) to instantiate the agent.

Specified by:
getAgentModule in interface IAgentDescriptor<PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>
Returns:
agent's module

setAgentModule

public AgentDescriptor<PARAMS,MODULE> setAgentModule(MODULE module)
Sets agent module to be used for the instantiation of the agent.

For more info see IAgentDescriptor.getAgentModule().

Parameters:
module -
Returns:
this instance

getAgentParameters

public PARAMS[] getAgentParameters()
Description copied from interface: IAgentDescriptor
Respective parameters of the agents. The length of the array must be the same as IAgentDescriptor.getCount(), i.e., there must be a separate parameter instance for every agent).

Note that some parameters may be null as IMultipleAgentRunner implementation can provide default parameters for agents (usually).

Specified by:
getAgentParameters in interface IAgentDescriptor<PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>
Returns:

setAgentParameters

public AgentDescriptor<PARAMS,MODULE> setAgentParameters(PARAMS[] params)
Clears all the params stored within AgentDescriptor and assigns 'params'.

For more info see IAgentDescriptor.getAgentParameters().

Parameters:
params -
Returns:

addParams

public AgentDescriptor<PARAMS,MODULE> addParams(PARAMS... params)
Adds parameters for another agents. Note that the number of parameters must be the same as the count of agents specified via setCount(int).

For more info see IAgentDescriptor.getAgentParameters().

Parameters:
params -
Returns:
this instance

getCount

public int getCount()
Returns number of agents to be instantiated using current getAgentModule().

If setCount(int) is called with positive int param, that this will return the passed count. Otherwise it returns the params.size(). I.e. the number of parameters you've added via AgentDescriptor#addParams(IAgentParameters) or set via setAgentParameters(IAgentParameters[]).

For more info see IAgentDescriptor.getCount() and javadoc for IAgentDescriptor and AgentDescriptor.

Specified by:
getCount in interface IAgentDescriptor<PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>
Returns:
number of agents to instantiate

setCount

public AgentDescriptor<PARAMS,MODULE> setCount(int count)
Set number of agents to be instantiated.

For more info see IAgentDescriptor.getCount().

Parameters:
count -
Returns:


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.