massim.framework.simulation
Class AbstractSimulation

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

public abstract class AbstractSimulation
extends DefaultSimulation

This class provides some reasonable defaults for relatively simple simulations and allows the reuse of classes written for such simulations. In contrast to DefaultSimulation there are som import paradigm shifts. There is now an array of agent states. Each agent state contains all agent specific state information. This might be the agents condition, position or score. Additionally there is one world state. It contains all information about the world meaning everything that is not directly associated with one agent. These two states describe the whole state of the simulation implementation specific side. Please note that those states are also exported via massim.Simulation.getSimulationState(). So they are supposed to be "clean", i.e. not containing any helper structures that are just there to ease access to data inside the state, like hashtables or something similar.


Constructor Summary
AbstractSimulation()
           
 
Method Summary
 void configureSimulation(SimulationConfiguration config)
          This method can be used by simulation managers to configure a simulation.
 java.lang.String endSimulation()
          This method will be automatically called once when the simulation has been started and it is to end.
abstract  java.lang.String finalizeSimpleSimulation()
          This method is supposed to make final actions before the simulation is shut down.
 SimulationAgent[] getAgents()
          Retrieves an array of SimulationAgent objects that participate in this simulation.
abstract  WorldState getSimpleSimulationState()
          This method is supposed to return the state of the world, excluding agents.
 SimulationState getSimulationState()
          This method will retrieve the whole simulation state.
 int getSteps()
          Retrieves the number of the steps that have been started to process in this simulation run.
abstract  void initializeSimpleSimulation()
          This method is supposed to initialize a simulation.
abstract  void postSimulationStep()
          This method is supposed to make necessary changes to the world that must occur after agent act in have acted in that step.
abstract  void preSimulationStep()
          This method is supposed to make necessary changes to the world that must occur before agents act in that step.
abstract  void runAgents()
          This method is supposed to let agents act.
abstract  void runFinalAgents()
           
abstract  void runInitAgents()
           
 void setSteps(int steps)
          Set number of the step. this is important when the server is started with recovery mode In recovery mode a simulation will run continuously at the step where he was stopped
abstract  void simulationStep()
           
 void startSimulation()
          This method will be automatically called when the simulation starts.
 void stepSimulation()
          This method will be automatically called when the simulation is supposed to do a simulation step.
 
Methods inherited from class massim.framework.DefaultSimulation
concurrentCreateAgent, concurrentGetAction, createAgent, getAction, getAgentManager, getController, removeAgent, removeAllAgents, setAgentManager, setController, start, stop
 
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
isFinished
 

Constructor Detail

AbstractSimulation

public AbstractSimulation()
Method Detail

startSimulation

public void startSimulation()
Description copied from interface: Simulation
This method will be automatically called when the simulation starts. Simulation implementors are encouraged to override this method. They may or may not create and remove agents and even ask them to act. It is however recommended to do initialization here.


stepSimulation

public void stepSimulation()
Description copied from interface: Simulation
This method will be automatically called when the simulation is supposed to do a simulation step. Simulation implementors are encouraged to override this method. They may or may not create and remove agents and ask them to act.


getSimulationState

public SimulationState getSimulationState()
Description copied from interface: Simulation
This method will retrieve the whole simulation state. In general this state object should contain any information about the simulation game state though this is not a requirement. So it's up to you what information is put here.

Returns:
the simulation state

configureSimulation

public void configureSimulation(SimulationConfiguration config)
Description copied from class: DefaultSimulation
This method can be used by simulation managers to configure a simulation.

Specified by:
configureSimulation in interface Simulation
Overrides:
configureSimulation in class DefaultSimulation
Parameters:
config - configuration message

getSimpleSimulationState

public abstract WorldState getSimpleSimulationState()
This method is supposed to return the state of the world, excluding agents.

Returns:
state of the world

initializeSimpleSimulation

public abstract void initializeSimpleSimulation()
This method is supposed to initialize a simulation. It should setup a world state and make everything ready for the first step. When this method is called agents are already initialized and available. Possibly it will also have to initialize their states.


getAgents

public SimulationAgent[] getAgents()
Retrieves an array of SimulationAgent objects that participate in this simulation.

Returns:
simulation agents

getSteps

public int getSteps()
Retrieves the number of the steps that have been started to process in this simulation run.

Returns:
number of steps

setSteps

public void setSteps(int steps)
Set number of the step. this is important when the server is started with recovery mode In recovery mode a simulation will run continuously at the step where he was stopped

Parameters:
steps -

preSimulationStep

public abstract void preSimulationStep()
This method is supposed to make necessary changes to the world that must occur before agents act in that step.


postSimulationStep

public abstract void postSimulationStep()
This method is supposed to make necessary changes to the world that must occur after agent act in have acted in that step.


runAgents

public abstract void runAgents()
This method is supposed to let agents act.


simulationStep

public abstract void simulationStep()

runInitAgents

public abstract void runInitAgents()

runFinalAgents

public abstract void runFinalAgents()

finalizeSimpleSimulation

public abstract java.lang.String finalizeSimpleSimulation()
This method is supposed to make final actions before the simulation is shut down. Agents are still available in this method.


endSimulation

public java.lang.String endSimulation()
Description copied from interface: Simulation
This method will be automatically called once when the simulation has been started and it is to end. It's not mandatory that startSimulation or stepSimulation returned false.



Copyright © 2011. All Rights Reserved.