mundo Village

Download Report

Transcript mundo Village

A case study with Malaria Anopheles
reproduction modeling
using an Individual Based Model
(IBM) framework
soundtrack: http://www.youtube.com/watch?v=vgB1XYVxk6k
Epischisto.org
• History
• Projects
2
Definition of a Cellular Automaton
Cellular automaton A is a set of four objects
A = <G, Z, N, f>, where
• G – set of cells
• Z – set of possible cells states
• N – set, which describes cells neighborhood
• f – transition function, rules of the automaton:
– Z|N|+1Z (for automaton, which has cells “with memory”)
– Z|N|Z (for automaton, which has “memoryless” cells)
Cellular automata generic models for complex systems
ΥC i ,j, C k ,l represents an interaction
coefficient that controls all possible
interactions between a cell Ci,j and its global
neighborhood Gi,j.
A function of inter-cell distance and cell
population density.
Definition of a Fuzzy Set
Neighborhood of cell Ci,j is global SCA
Gi,j := {(Ck,l, ΥC i ,j, C k ,l) |for all Ck,l Є C, 0 ≤ Υ Ci,j, Ck,l ≤ 1}
C is a set of all cells in the CA.
Two-Dimensional Grids
Cells that have a common edge with the involved
are named as “main neighbors” of the cell (are
showed with hatching)
The set of actual neighbors of the cell a, which can
be found according to N, is denoted as N(a)
Definition of the Rings
Formally, if R(a, i) is a set of cells of i-th ring of
cell a, then if N describes cells neighborhood
as the set of its nearest neighbors, following
formula will take place
Rings for Grid of …
Different
rings
are
showed
with hatching
or color
Definition of the Metrics
Distance function D(a, b) for retrieving
remoteness between cells a and b can be
denoted as follows
It is proved that this function satisfies to all metrics
properties
The notion of ring may be generalized for multidimensional grids and the distance function,
given by last formula, will remain the same
Difference Between ABM & CA
• Cellular automata (CAs) are always
homogeneous and uniformly densely
populated on the grid (all cells are identical),
whereas in ABM the agents are
heterogeneous and do not necessarily occupy
all spaces within the grid.
• CAs frequently won’t interact with agents
outside their immediate ‘neighborhood’
9
Agent Based Modeling
• Computer simulation that represents
individual actors in a dynamic social system.
• ‘Agents’ represent heterogeneous individuals
who interact with each other and/or their
environment based on set rules.
• From these interactions, macro-scale
behaviors may emerge.
10
Agents
Agents have:
 Internal data representations
(memory or state)
 Means for modifying their internal
data representations (perceptions)
 Means for modifying their
environment (behaviors)
Copyright © 2000 by Swarm Development Group
11
Excel-Example
CA Diffusion Model with ‘Seeds’
-2 1 1
1 -2 1
-1 1 -2
Influence Level = -2
Indifference Point = 0
SUM (Surrounding Squares) = 2(-2 ) + 5(1) –1 = 0
Therefore: cell remains negative
12
Netlogo http://ccl.northwestern.edu/netlogo/
This particular cellular automaton
is called the Parity Model. There is
only one rule, which all the cells
follow. The rule is that each cell
looks at its four neighbours (the
ones immediately to its left, right,
above and below) and if an odd
number of them (that is, 1 or 3) of
them are 'on', it switches itself 'on'.
If there are an even number 'on' (2
or 4), it switches itself off.
by Nigel Gilbert (Submitted: 9/15/2002 )
13
Ascape
www.brook.edu/dybdocroot/es/dynamics/models/ascape
In Ascape, agent objects
exist within scapes;
collections of agents such as
arrays and lattices. These
scapes are themselves
agents, so that typical
Ascape models are made up
of "collections of collections"
of agents. Ascape manages
graphical views and
collection of statistics for
scapes and provides
mechanisms for controlling
and altering parameters for
scape models.
14
Starlogo/Sugarscape
http://education.mit.edu/starlogo/
www.brook.edu/SUGARSCAPE
StarLogo is a programmable modeling environment for exploring the
workings of decentralized systems -- systems that are organized
without an organizer, coordinated without a coordinator. With
StarLogo, you can model (and gain insights into) many real-life
phenomena, such as bird flocks, traffic jams, ant colonies, and
market economies.
15
RePast/Sugarscape
The name RePast is an
acronym for REcursive
Porous Agent Simulation
Toolkit. Our goal with RePast
is to move beyond the
representation of agents as
discrete, self-contained
entities in favor of a view of
social actors as permeable,
interleaved and mutually
defining, with cascading and
recombinant motives. We
intend to support the
modeling of belief systems,
agents, organizations and
institutions as recursive
social constructions.
16
SWARM www.swarm.org/
Swarm is a software
package for multi-agent
simulation of complex
systems, originally
developed at the Santa Fe
Institute. Swarm is
intended to be a useful
tool for researchers in a
variety of disciplines. The
basic architecture of
Swarm is the simulation
of collections of
concurrently interacting
agents: with this
architecture, we can
implement a large variety
of agent based models.
17
AgentSheets
http://agentsheets.com/
AgentSheets is an authoring tool
that allows non-programmers to
create agents with behaviors and
missions, teach agents to react to
information and process it in
personalized ways, and combine
agents to create sophisticated
interactive simulations and
models. Our customers use
AgentSheets to create interactive
games, virtual worlds, training
simulations, information
gathering and personalizing
agents, and other interactive
content.
18
Why Python?
http://www.levenez.com/lang/
Timeline of General Purpose Programming
Languages…
2012 programming languages in progress…
19
Python…
http://www.python.org/
• Simple
– Python is a simple and minimalistic language in nature
– Reading a good python program should be like reading English
– Its Pseudo-code nature allows one to concentrate on the problem
rather than the language
• Easy to Learn
• Free & Open source
– Freely distributed and Open source
– Maintained by the Python community
• High Level Language –memory management
• Portable – *runs on anything c code will
• PyCUDA - parallel programming using CUDA
20
What is Parallel Programming?
Single
Multiple
Data Stream Data Stream
Single
Instruction
Stream
Multiple
Instruction
Stream
SISD
SIMD
uniprocessors
Processor arrays
MISD
MIMD
Systolic arrays
Multiprocessors
multicomputers
https://computing.llnl.gov/tutorials/parallel_comp/
21
A Framework for Megascale Agent
Based Model Simulations on GPU
http://jasss.soc.surrey.ac.uk/11/4/10.html
Journal of Artificial Societies and Social Simulation vol. 11, no. 4 10
22
Installing Python, Packages, CUDA
• NVIDIA hardware
• Python
– packages
• CUDA
• Windows X Linux? Bill Gates!!!!
http://200.17.137.109:8081/xiscanoe/projeto/ibm-caproject-mosimbio/python-for-scientific-computing
23
Malaria Vector - Life Cycle
[http://www.ocvcd.org]
Malaria Vector – life periods
Egg
• 2-3 days
• 2-3 weeks
in colder
climates
Larvae
(four
stages)
• Min 4 days
(1
day/stage)
• 7-14 days in
four stages
• 9 days typical
Pupa
Young
Adult
• 2-4 weeks
• “several
weeks”
• 5 minutes
(0,003 day)
• 7-30 days
• Eckhooff Malaria Journal 2011, 10:303
• S.J. de Almeida et al. Environmental Modeling & Software 25(2010), 1490-1507
• Silver, John B. Mosquito Ecology – Field Sampling Methods. Springer, 3rd Edition, 2008.
•
Mosquito – individual as an object in
Python
A python object
http://docs.python.org/reference/datamodel.html
“Objects are Python’s abstraction for data. All data in a Python program is represented by objects
or by relations between objects. (In a sense, and in conformance to Von Neumann’s model of
a “stored program computer,” code is also represented by objects.)”
•
class mosquito:
def __init__(self, sex, eggstate, stage, state, energy, fertility, positionX,
positionY):
self.sex = sex
#sex of the mosquito
self.eggs = eggstate
#level of development of eggs
self.stage = stage
#stage of life of the mosquito
self.state = state
#state of a mosquito
self.energy = energy
#energy level of the mosquito
self.fertility = fertility
#fertility of the mosquito
self.positionX = positionX #coordinate X at the world
self.positionY = positionY #coordinate Y at the world
26
Mosquito – IBM Parameters
INDIVIDUAL
•
states_of_a_mosquito = 5
(females), 4- hatching (females)
•
stages_of_life_cycle = 5
•
energy_level_of_a_mosquito = 4
•
sex_of_a_mosquito = 2
•
fertility_of_a_mosquito = 2
•
development_of_eggs_of_a_mosquito = 4
•
size_of_mosquito_population = 3500000
ENVIRONMENT
•
#states_of_a_human = 4
•
human_population = (500)
•
time_to_simulate = 43200
a year...
•
n-dimensional world x,y,...
–
•
•
•
#Mosquito Status: 0- mating, 1- feeding, 2- digesting, 3- ovoposition
#Mosquito Stage: 0- egg, 1- larva, 2- pupa, 3- young, 4- adult
#Energy level: 0- no energy (dead), 1- low, 2- medium, 2- high, 3- full
#Sex: 0- male, 1- female
#fertility: 0- sterile, 1- fertile
#Eggs: 0-no eggs (males), 1- incomplete, 2- in process, 3- complete
#total mosquitoes in the world
#SEIR: 0-susceptible, 1-exposed, 2-infected, 3-recovered
#total humans in the world
# 1440 minutes in a day, 43200 minutes in a month, 518400 minutes in
tam_world_y = tam_world_y = 10
states_of_a_cell = 2
#water: 0-no water, 1-water
max_human_population_per_cell = (5) #max amount of humans in a cell of the world
max_animal_population_per_cell = (4) #max amount of animals in a cell of the world
27
Mosquito – IBM Parameters (cont.)
•
•
•
•
•
Days_between_feeds = 3
Female_eggs_per_female_oviposition = 100
Adult_life_expectancy = 10
Duration_of_immature = 4
Temperature_of_cell = [12..34]
28
Mosquito – Functionalities 
•
•
•
•
•
•
def grow_up(self) #birth … death
def feed(self) #adult state
def digest(self) #adult state
def mate(self) #adult state
def lay_eggs(self) #female no sterile state
def hatch(self) #eggs state
29
Computation of the individuals
Cell of the world
Composition of the
N-dimensional
matrices of parameters
.
animals
.
human .
water
N-dimensional
parameters of a cell
30
------------------- The World of the Mosquitoes ----------------- dimensional parameters: water, human,
animal, indoor/outdoor
[array([[1, 0, 0, 0, 0, 0, 0, 1, 1, 1],
[0, 0, 1, 0, 1, 1, 0, 1, 0, 0],
[0, 0, 1, 1, 1, 1, 1, 0, 1, 0],
[1, 1, 1, 1, 0, 0, 1, 1, 0, 0],
2999961 : Hola! Yo soy un(a) mosquito joven y
[1, 0, 0, 0, 0, 0, 0, 1, 1, 0],
soy varon y fertile y estoy en la cell ( 6 , 3 ) del
[0, 0, 0, 1, 1, 0, 1, 1, 1, 1],
mundo de Jones!
[1, 1, 0, 0, 1, 0, 0, 1, 1, 0],
2999962 : Hola! Yo soy un(a) pupa y soy
[0, 0, 1, 0, 1, 1, 1, 0, 0, 1],
hembra y sterile y estoy en la cell ( 2 , 5 ) del
[0, 1, 1, 0, 0, 1, 0, 1, 1, 1],
mundo de Jones!
[0, 0, 1, 1, 0, 1, 0, 0, 1, 1]]), array([[3, 1, 2,
2999963 : Hola! Yo soy un(a) egg y fertile y
estoy en la cell ( 2 , 6 ) del mundo de Jones! 2, 4, 1, 4, 3, 3, 4],
[3, 0, 4, 0, 1, 0, 0, 3, 4, 4],
2999964 : Hola! Yo soy un(a) egg y sterile y
[0, 2, 2, 2, 4, 0, 0, 2, 1, 0],
estoy en la cell ( 8 , 7 ) del mundo de Jones!
[0, 2, 0, 1, 2, 1, 1, 3, 4, 0],
2999965 : Hola! Yo soy un(a) mosquito adulto
[3, 3, 4, 3, 4, 4, 2, 0, 4, 1],
y soy hembra y fertile y estoy a poner ovos en
[4, 0, 0, 2, 3, 2, 0, 1, 2, 0],
la cell ( 9 , 9 ) del mundo de Jones!
[2, 2, 0, 4, 3, 1, 2, 1, 1, 0],
[3, 4, 1, 2, 4, 4, 1, 4, 4, 1],
[3, 3, 4, 1, 4, 2, 2, 4, 4, 3],
[3, 4, 0, 4, 1, 4, 0, 4, 0, 2]]), array([[1, 31
2, 2,
0, 2, 3, 0, 3, 0, 3],
Works…
Simulations
• Reproduction cycle:
– Water and no water
– Indoor and outdoor
– Fertile and no fertile
– Temperature varying
– ??????? To talk to THE
entomologist…
32
Comparing results…
WATER RESOURCES RESEARCH, VOL. 44,
W12445, doi:10.1029/2008WR006917, 2008
Hydrology of malaria: Model development and
application to a Sahelian village
33
Some results
Comparing mosquito
quantity (temperature
varying in 0,5) simulated
With
WATER RESOURCES
RESEARCH, VOL. 44, W12445,
doi:10.1029/2008WR006917,
2008
Do we need real
experiment…?
34
GPU vs CPU running IBM´s simple problems
3
2.5
SpeedUp =
2
Speedup
Exec time CPU
--------------------Exec time GPU
Baseline 1CPU
OpenMP 1CPU
OpenMP 2CPU
1.5
1
GPU 2Processors
2.12 faster than CPU!
In a SONY VAIO CORE i5
NVIDIA GEFORCE
SpeedUp superlinear!!
Pero…
0.5
0
20000
70000
120000
170000
220000
270000
320000
370000
420000
470000
Particle #
35
Considerations
•
•
•
•
CUDA is simple, cheap and easy!  2 months
Python is simple, free, easy  2 months
Environment configuration is complex 
Mosquito behavior is more complex!
36