Information Technology Reference
In-Depth Information
Agent-based model Simulation engine (implementation)
Event
EventEvent
Action
ActionStartEvent
×
ActionEndEvent
This means, each model event is mapped onto a corresponding simu-
lator event. Each action of an agent (either sensor or effector action)
is mapped onto two simulator events, namely one for the start of an
action and one for the end of an action.
Algorithm 2 Main loop of the single-threaded event-driven simula-
tion engine
futureEvents = [ 0 : StartEvent ]
now = timeOfFirstEvent(futureEvents)
while futureEvents not empty AND now ¡ end do
now = timeOfFirstEvent(futureEvents)
currentEvents = futureEvents.eventsAt(now)
for all ActionEndEvent e in currentEvents do
The action corresponding to event e could be executed success-
fully, therefore change model state accordingly
end for
for all EnvironmentalEvent e in currentEvents do
Update environment and check constraints
end for
for all AgentEvent e in currentEvents do
Relay event e to agents
end for
for all ActionStartEvent e in currentEvents do
Check constraints AND handle violated constraints
end for
end while
The main loop of the event-driven simulation engine is shown in
Algorithm 2. The futureEvents data structure holds all upcoming
events (timepoint and event). At the beginning, futureEvents is
initialized to hold the StartEvent which is sent to all agents at the
 
Search WWH ::




Custom Search