simulation de phénomènescollectifs - loria
Post on 16-Jun-2022
2 Views
Preview:
TRANSCRIPT
1
V. Chevrier
Simulation de phénomènes collectifs
Concevoir et programmer une simulation de phénomène collectif
Mise en oeuvre avec Netlogo
2
V. Chevrier
Thèmes
Ø Propagation de maladie dans une population• Avec ou sans vaccin
Ø Théorie de l’evolution• Les plus adaptés finissent par être les plus nombreux
Ø Dynamique de population• Lapin, renard, herbe etc..
Ø …
3
V. Chevrier
Etapes
Ø Choisir un thème (!)• Définir la question qui sera répondue• Faire des hypotheses (choix de modélisation)
Ø Proposer une première modélisation simplissime• Objectif prendre en main l’outil et cibler les comportements de
base• Evaluer sa réponse à la question
Ø Incrémentalement, complexifier le modèle pour mieuxrépondre à la question
4
V. Chevrier
Netlogo platform
Ø http://ccl.northwestern.edu/netlogo/Ø Interpreted languageØ Dedicated to complex system simulationØ Individual centered (logo turtle)Ø Fonctionnalities
• 2D (/3D) model • GUI builder with slider, button, reporter,,• Graphs wizard (various possbilities: min,max, min, …)• Concurrent programming
Ø Free (possibility of online (simplified) version)
5
V. Chevrier
Netlogo
Ø Components of a model • Environnment :
– Discrete 2D torous grid– Cell = patch
• attributes, visual aspect (color)
• Turtles (agents) micro level– Situated (x,y + orientation) in environment– Actions: movements, modification of patch/other agents
• Observation macro level– Global variables– Global processing (init., patch evolution, stats, …)– Execution management
6
V. Chevrier
Component of the netlogo platform
Ø Graphical interface: • Visual view of the model
– Agent positions• User interface
– Parameter, execution(start …)
• Observing– Graphs, reporters
Ø « execution oriented »
7
V. Chevrier
Ø Code • Observing code• Turtles code• Variables
Ø « Programmingoriented »
Component of the netlogo platform
8
V. Chevrier
Netlogo
Ø Numerous (!) documented examplesØ Very easy to learn (even for non programmers)Ø Conection to JAVA, scala code ; applet possibilitiesØ Parameters space exploration Ø Fast (!)butØ Be caution with syntax (eg: dont forget white space)Ø Not so easy when advanced programming concepts are
needed
9
V. Chevrier
10
V. Chevrier
Toy exampleopinion dynamics
11
V. Chevrier
Opinion dynamics(a first glance on a well known model)
G. DEFFUANT, G., NEAU, D., AMBLARD, F. and WEISBUCH, G. 2000.
Mixing beliefs among interacting agents. Advances in Complex Systems, 3, 87-98.
12
V. Chevrier
Basic principles
Ø Agents • Have an opinion
Ø Interaction• 2 agents with close opinions will move their opinions closer
13
V. Chevrier
Model
Ø Agent i defined by it opinion • Float xi
Ø Close opinions ó• | xi-xj| < d
Ø Opinions move closer• Xi = xi + k (xj-xi)• And symetrically forxj
• K : convergence factor (between 0 and0.5)
Ø Mathematical model is possible
14
V. Chevrier
Numerical simulation
Ø Initialisation• Create N agents• Provide themwith an initial (random) opinion
Ø Simulation (loop)• Pick two agents• If they are “close” then update
• Demo with Netlogo
15
V. Chevrier
Variations
Ø Interaction• 2 agents with close opinions will move their opinions closer
Ø Interaction• 2 agents with close opinions will move their opinions closer
Move closer instead of « fusion »
Influence ???
What if distance is not symetrical ?
16
V. Chevrier
A small demo
17
V. Chevrier
Other works
Ø And agents are not sincere ?Ø Reputational effect, preferences falsification
18
V. Chevrier
A step-by-step example
Ø Dynamics of opinion• Rather than meeting "at random", agents travel and "discuss" with
their neighbours
Ø Steps Random movement• Meet/convince each other• Visualization
• ExtensionS
19
V. Chevrier
InitializationØ Primitive
• Clear-all• Crt/create-turtles number [ commands ]
• Reset-ticksØ Interface
• Setup/ go buttons• Slider nb turtles
20
V. Chevrier
21
V. Chevrier
Traveling
Ø Primitive• forward number• random-float number
22
V. Chevrier
Dynamics of opinion
Ø Individual model• "attribute" opinion • (initially random)
Kesako?
23
V. Chevrier
Dynamics of opinion
Ø Individual model• "attribute" Opinion • (initially random)
Ø Collective properties• Threshold Factor (slider)
Ø Dynamics• To know if agents meet each other• Update of opinion
Ø Graphical interface• Each step, opinion diagram
24
V. Chevrier
Code
25
V. Chevrier
Ø One-of • Takes at random one from a list
Ø Turtles-on• Set of turtles in a patch set
Ø Neighbors• Patches around the current patch
26
V. Chevrier
Dynamics of opinion
Ø Individual model• "attribute" Opinion • (initially random)
Ø Collective properties• Threshold Factor (slider)
Ø Dynamics• To know if agents meet each other• Update of opinion
Ø Graphical interface• Each step, opinion diagram
27
V. Chevrier
28
V. Chevrier
Extension
Ø There are three categories of populations• Each with a different threshold• Each with a different factor
Ø New agents can be created during the simulationØ agents move in groups according to their opinion (+/-
close)
29
V. Chevrier
A tutorial on netlogo
30
V. Chevrier
A step by step example
Ø Rabbit grass: population dynamics
• Rabbit are wandering in a “garden”• Grass growths regularly• Rabbits can eat grass and reproduce• If rabbits cannot eat for a while, they die
31
V. Chevrier
MAS modeling with netlogo
Ø EnvironmentØ AgentsØ DynamicsØ System loop/initialization
32
V. Chevrier
Environment modeling
Ø 2D grids of patchesØ Patch
• Featured by grass quantity (the resource)Ø Dynamics
• Grass grows each cycle• Grass can be eaten (by rabbits) and decreases
Ø Initially: random quantity
Ø Display• According to grass quantity: the more grass the greener
33
V. Chevrier
Modeling of agents (turtles)
Ø Internal state• Energy
Ø Behavior• Random movements• Eat grass• Live (spent energy, die or reproduce)
Ø Initially• Random position and energy
Ø Display (opt.)• Use/design a specific icon (turtle shape editor, ….)
34
V. Chevrier
Modeling of dynamics
Ø Each cycle• Ask every rabbit to:
– Move– Eat– Live (spend energy, reproduce or die)
• Ask every patch to:– grow grass
• Provide some statistical information
35
V. Chevrier
Basic elements in netlogo
Ø Creating turtles at random positionsØ Making them move
36
V. Chevrier
37
V. Chevrier
38
V. Chevrier
39
V. Chevrier
Makes turtles move randomly
40
V. Chevrier
Basic elements in netlogo
Ø Creating turtlesØ Making them moveØ Defining procedures/global variablesØ Creating a basic graphical interfaceØ Simulating a model
41
V. Chevrier
Ø Clearing the world (reset all)Ø Putting grass
• define patch feature• Initialize the feature
Ø Making grass growing• Define a method to make grass grow
Ø Provide a visual display
42
V. Chevrier
43
V. Chevrier
44
V. Chevrier
Ø Putting all together• Merge initializations• Let’s rabbits eat, spend energy and die/reproduce• Provide a “loop” function
Ø Providing statistics
45
V. Chevrier
initialization
46
V. Chevrier
Procedure in code
47
V. Chevrier
Rabbits behavior
48
V. Chevrier
To be continued …
Ø See rabbit grass weeds in netlogo library
top related