Class BasicAgent<S extends State,E>

java.lang.Object
org.simplesim.model.BasicModelEntity
org.simplesim.model.BasicAgent<S,E>
Type Parameters:
S - type of the agent state containing all state variables
E - type of the events
All Implemented Interfaces:
Agent, ModelEntity
Direct Known Subclasses:
Cell, InstrumentationDecorator, RoutingAgent, StaticElevator, StaticVisitor

public abstract class BasicAgent<S extends State,E> extends BasicModelEntity implements Agent
Implements all basic functionality of an agent.

Agents are the acting entities of the simulation model. They should implement a strategy within their Agent.doEvent(Time) method. This is usually done by the following five steps:

  1. read the messages from the inports (Message)
  2. modify the agent's state (State)
  3. compute output and write messages to other entities to the outports
  4. add events to the internal event queue if necessary (EventQueue)
  5. return the time of the next local event (Time)

Agents are always embedded in an Domain for compartmentalization.

See Also:
  • Constructor Details

    • BasicAgent

      public BasicAgent(EventQueue<E> queue, S s)
      Sets the agent's local event queue and the internal state.

      Note: Generally, a HeapEventQueue will work best as local event queue.

      Parameters:
      queue - the local event queue
      s - the state of the agent
    • BasicAgent

      public BasicAgent(S s)
  • Method Details

    • getState

      public S getState()
      Description copied from interface: Agent
      Returns the agent's state containing all internal variables
      Specified by:
      getState in interface Agent
      Returns:
      the agent's internal state
    • getTimeOfNextEvent

      public Time getTimeOfNextEvent()
      Returns the time of the next internal event.

      This method is called by the simulator to update the global event queue.

      Specified by:
      getTimeOfNextEvent in interface Agent
      Returns:
      time of the next internal event
    • pollModelChangeRequest

      public static final ChangeRequest pollModelChangeRequest()
      Removes first model change request in queue

      Should only be used by a dynamic simulator implementation and by an agent

      This method is thread-safe.

      Returns:
      next model change request or null if queue is empty
      See Also:
    • toggleSimulationIsRunning

      public static final void toggleSimulationIsRunning(boolean toggle)
      Sets the status of simulation run.

      Static method and variable to be accessible for all agents of the simulation model

      Parameters:
      toggle - the status of the simulation, true means simulation is running
    • isSimulationRunning

      public static final boolean isSimulationRunning()
      Gets the status of simulation run.

      Static method and variable to be accessible for all entities of the simulation model

      Returns:
      current simulation status, true means simulation is running