massim.framework
Class DefaultSimulation

java.lang.Object
  extended by massim.framework.DefaultSimulation
All Implemented Interfaces:
Component, Simulation
Direct Known Subclasses:
AbstractSimulation

public abstract class DefaultSimulation
extends java.lang.Object
implements Simulation

This class is a good starting point to create a new simulation. It provides some methods to create and remove agents aswell as methods to ask agents to act according to some perception.


Constructor Summary
DefaultSimulation()
           
 
Method Summary
protected  java.util.concurrent.Future<SimulationAgent> concurrentCreateAgent(AgentParameter parameter)
          This method does the same as createAgent, but it won't block and return a Future instead.
protected  java.util.concurrent.Future<Action> concurrentGetAction(Perception perception, SimulationAgent a)
          This is the non-blocking version of getAction.
 void configureSimulation(SimulationConfiguration m)
          This method can be used by simulation managers to configure a simulation.
protected  SimulationAgent createAgent(AgentParameter parameter)
          Create an agent, represented by an Agent object.
protected  Action getAction(Perception perception, SimulationAgent a)
          This method will deliver a perception to an agent, getting the agents reaction in return.
 AgentManager getAgentManager()
          Retrieve the AgentManager that will be used for agent creation by this simulation.
 Controller getController()
           
protected  void removeAgent(SimulationAgent a)
          Remove an agent.
protected  void removeAllAgents()
          Remove all agents that were created by this simulation.
 void setAgentManager(AgentManager agentmanager)
           
 void setController(Controller controller)
           
 void start()
          Tell the component to start activity.
 void stop()
          Tell the component to cease activity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface massim.framework.Simulation
endSimulation, getSimulationState, isFinished, startSimulation, stepSimulation
 

Constructor Detail

DefaultSimulation

public DefaultSimulation()
Method Detail

createAgent

protected SimulationAgent createAgent(AgentParameter parameter)
Create an agent, represented by an Agent object. This method should be used by simulation implementors.

Parameters:
parameter - agent creation parameters
Returns:
according agent object

concurrentCreateAgent

protected java.util.concurrent.Future<SimulationAgent> concurrentCreateAgent(AgentParameter parameter)
This method does the same as createAgent, but it won't block and return a Future instead.

Parameters:
parameter - agent creation parameters
Returns:
according agent future

removeAgent

protected void removeAgent(SimulationAgent a)
Remove an agent. This method will remove an agent from the simulation and make thus make it possible that system resources can be freed. It's imperative to remove all created agents before the simulation ends.

Parameters:
a - agent to remove

removeAllAgents

protected void removeAllAgents()
Remove all agents that were created by this simulation. It's imperative to remove all created agents before the simulation ends.


getAction

protected Action getAction(Perception perception,
                           SimulationAgent a)
This method will deliver a perception to an agent, getting the agents reaction in return.

Parameters:
perception - perception to deliver to the agent
a - agent to access
Returns:
action as returned by the agent

concurrentGetAction

protected java.util.concurrent.Future<Action> concurrentGetAction(Perception perception,
                                                                  SimulationAgent a)
This is the non-blocking version of getAction.

Parameters:
perception - perception to deliver to the agent
a - agent to access
Returns:
future of the action returned by the agent

start

public void start()
Description copied from interface: Component
Tell the component to start activity.

Specified by:
start in interface Component

stop

public void stop()
Description copied from interface: Component
Tell the component to cease activity.

Specified by:
stop in interface Component

configureSimulation

public void configureSimulation(SimulationConfiguration m)
This method can be used by simulation managers to configure a simulation.

Specified by:
configureSimulation in interface Simulation
Parameters:
m - configuration message

getAgentManager

public AgentManager getAgentManager()
Retrieve the AgentManager that will be used for agent creation by this simulation. Simulation implementors should not use getAgentManager and access it directly, but use the Agent object and createAgent instead.

Specified by:
getAgentManager in interface Simulation
Returns:
Returns the agentmanager.

setAgentManager

public void setAgentManager(AgentManager agentmanager)
Specified by:
setAgentManager in interface Simulation
Parameters:
agentmanager - The agentmanager to set.

getController

public Controller getController()
Returns:
Returns the controller.

setController

public void setController(Controller controller)
Parameters:
controller - The controller to set.


Copyright © 2011. All Rights Reserved.