Package org.simplesim.model
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 variablesE
- type of the events
- All Implemented Interfaces:
Agent
,ModelEntity
- Direct Known Subclasses:
Cell
,InstrumentationDecorator
,RoutingAgent
,StaticElevator
,StaticVisitor
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:
- read the messages from the inports
(
Message
) - modify the agent's state (
State
) - compute output and write messages to other entities to the outports
- add events to the internal event queue if necessary
(
EventQueue
) - return the time of the next local event
(
Time
)
Agents are always embedded in an Domain
for compartmentalization.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.simplesim.model.Agent
Agent.UnknownEventType
Nested classes/interfaces inherited from interface org.simplesim.model.ModelEntity
ModelEntity.PortConnectionException, ModelEntity.PortOperationException, ModelEntity.UniqueConstraintViolationException
-
Field Summary
Fields inherited from interface org.simplesim.model.ModelEntity
ROOT_LEVEL
-
Constructor Summary
ConstructorsConstructorDescriptionBasicAgent
(EventQueue<E> queue, S s) Sets the agent's local event queue and the internal state.BasicAgent
(S s) -
Method Summary
Modifier and TypeMethodDescriptiongetState()
Returns the agent's state containing all internal variablesReturns the time of the next internal event.static final boolean
Gets the status of simulation run.static final ChangeRequest
Removes first model change request in queuestatic final void
toggleSimulationIsRunning
(boolean toggle) Sets the status of simulation run.Methods inherited from class org.simplesim.model.BasicModelEntity
addToDomain, equals, getAddress, getFullName, getInport, getLevel, getName, getOutport, getParent, removeFromDomain, toString
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.simplesim.model.ModelEntity
addToDomain, getAddress, getFullName, getInport, getLevel, getName, getOutport, getParent, removeFromDomain
-
Constructor Details
-
BasicAgent
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 queues
- the state of the agent
-
BasicAgent
-
-
Method Details
-
getState
Description copied from interface:Agent
Returns the agent's state containing all internal variables -
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 interfaceAgent
- Returns:
- time of the next internal event
-
pollModelChangeRequest
Removes first model change request in queueShould 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
-