Simulation Architecture - Refactoring

Simulation
Weather Info
•Temperature
•Rainfall
Global
Clock
Environment
Environment
List of Agents
Stats by Step
•Weather Info
•Stats for
each List of
Agents
List of Agents
Human
Stats by Step
•Weather Info
•Stats for
each List of
Agents
Human
Human
Human
Human
Human
...
List of Agents
List of Agents
List of Agents
List of Agents
Mosquito
Pond
Mosquito
Pond
Mosquito
Mosquito
Pond
Pond
Mosquito
Mosquito
Pond
Pond
Pond Object
Baby Object
Adult Object
Private Data:
•Water Level
•Location
•Max Population
•Population
•Age Distribution
Needs:
•Rainfall
•Temperature
•Population changes
Actions:
•Update water level
•Update Max Population
•Calculate DMR?
Private Data:
•Name, Age, Gender,
Genes
•Parent Pond
•Strategy
Needs:
•DMR
•Temperature
Actions:
•Call Strategy for update
•Die
•Hatch
Private Data:
•Name, Age, Gender,
Genes, numEggs
•Location
•Strategy
Needs:
•DMR
•Temperature
•List of Ponds
•List of Humans
Actions:
•Call Strategy for update
•Die
•Lay Eggs
•Mate
•Bite Human
•Fly
Pond List
Baby List
Adult List
Private Data:
•List of Ponds
•List of incoming Babies
•List of outgoing Adults
Needs:
•Number of dead Babies
from Baby List
Actions:
•Update all Pond Objects
Private Data:
•List of incoming Babies
•List of outgoing Adults
Needs:
•Receive Baby Objects
from Adult List
Actions:
•Update all Baby Objects
•Send Adult Objects to
Adult List
•Delete Dead Baby
Objects
•Send Pond List number
of dead Baby Objects
Private Data:
•List of incoming Adults
•List of outgoing Babies
Needs:
•Receive Adult Objects
from Baby List
•Receive Adult Objects
from other Adult Lists
Actions:
•Update all Adult Objects
•Send Baby Objects to
Baby List
•Send Adult Objects to
other Adult Lists
Message Delivery
•
•
•
•
•
Communication between different Environments within the Simulation is
coordinated with a Message delivery system
Each Environment has an Inbox, an Outbox, and a MessageHandler
who knows how to sort/deliver Messages.
Messages include a delivery address and some Agent Information
(pointer, actual Agent object, or perhaps other descriptors )
Each Environment must take three actions per Step
– ReceiveAgents (Take Messages in Inbox and distribute to the
appropriate AgentLists)
– UpdateAgents (Update sub-Environments first, then update all
AgentLists)
– SendAgents (Take any Messages placed in the Outbox during the
Step and deliver it to the appropriate Inboxes)
Some Caveats
– The Simulation Object only has an Inbox as it does not generate any
of its own Messages to be delivered.
– SpaceEnvironments would need to know the address of neighboring
SpaceEnvironments
– Addressing convention must be assumed that can correctly route
the Messages to the right AgentList within the right Environment
Order of Operations
•
•
•
•
•
•
•
Simulation
Calls Update on Clock
Delivers Messages to all SpaceEnvironments
Calls Update on all SpaceEnvironments
SpaceEnvironments
ReceiveMessages: Deliver Messages in Inbox to correct PondEnvironment or AgentList
Update:
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Call Update on all PondEnvironments
Call Update on all AgentLists
SendMessages: Send messages in Outbox to correct destinations
PondEnvironments
ReceiveMessages: deliver Messages in Inbox to correct AgentList
Update: Call Update on all AgentLists
Send Messages in Outbox to correct destinations
Agents
Call Update on Strategy/Current State
State
Determine Death
Determine NextState
Send Messages
Update Necessary Statistics
Simulation
Inbox
Address
SE1 : AdultList
Data
AdultMosquito
Global
Clock
Space Environment 1
Inbox
Address
Data
Pond Environment 1
Inbox
Address
SE1 : PE1 : BabyList
List of Agents
Data
AquaticMosquito
List of Agents
Adult Mosquito
Aquatic Mosquito
Adult Mosquito
Aquatic Mosquito
Adult Mosquito
Aquatic Mosquito
Outbox
Outbox
Address
Data
Address
SE1 : AdultList
Data
AdultMosquito