simulation de phénomènescollectifs - loria

48
1 V. Chevrier Simulation de phénomènes collectifs Concevoir et programmer une simulation de phénomène collectif Mise en oeuvre avec Netlogo

Upload: others

Post on 16-Jun-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Simulation de phénomènescollectifs - LORIA

1

V. Chevrier

Simulation de phénomènes collectifs

Concevoir et programmer une simulation de phénomène collectif

Mise en oeuvre avec Netlogo

Page 2: Simulation de phénomènescollectifs - LORIA

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..

Ø …

Page 3: Simulation de phénomènescollectifs - LORIA

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

Page 4: Simulation de phénomènescollectifs - LORIA

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)

Page 5: Simulation de phénomènescollectifs - LORIA

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

Page 6: Simulation de phénomènescollectifs - LORIA

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 »

Page 7: Simulation de phénomènescollectifs - LORIA

7

V. Chevrier

Ø Code • Observing code• Turtles code• Variables

Ø « Programmingoriented »

Component of the netlogo platform

Page 8: Simulation de phénomènescollectifs - LORIA

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

Page 9: Simulation de phénomènescollectifs - LORIA

9

V. Chevrier

Page 10: Simulation de phénomènescollectifs - LORIA

10

V. Chevrier

Toy exampleopinion dynamics

Page 11: Simulation de phénomènescollectifs - LORIA

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.

Page 12: Simulation de phénomènescollectifs - LORIA

12

V. Chevrier

Basic principles

Ø Agents • Have an opinion

Ø Interaction• 2 agents with close opinions will move their opinions closer

Page 13: Simulation de phénomènescollectifs - LORIA

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

Page 14: Simulation de phénomènescollectifs - LORIA

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

Page 15: Simulation de phénomènescollectifs - LORIA

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 ?

Page 16: Simulation de phénomènescollectifs - LORIA

16

V. Chevrier

A small demo

Page 17: Simulation de phénomènescollectifs - LORIA

17

V. Chevrier

Other works

Ø And agents are not sincere ?Ø Reputational effect, preferences falsification

Page 18: Simulation de phénomènescollectifs - LORIA

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

Page 19: Simulation de phénomènescollectifs - LORIA

19

V. Chevrier

InitializationØ Primitive

• Clear-all• Crt/create-turtles number [ commands ]

• Reset-ticksØ Interface

• Setup/ go buttons• Slider nb turtles

Page 20: Simulation de phénomènescollectifs - LORIA

20

V. Chevrier

Page 21: Simulation de phénomènescollectifs - LORIA

21

V. Chevrier

Traveling

Ø Primitive• forward number• random-float number

Page 22: Simulation de phénomènescollectifs - LORIA

22

V. Chevrier

Dynamics of opinion

Ø Individual model• "attribute" opinion • (initially random)

Kesako?

Page 23: Simulation de phénomènescollectifs - LORIA

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

Page 24: Simulation de phénomènescollectifs - LORIA

24

V. Chevrier

Code

Page 25: Simulation de phénomènescollectifs - LORIA

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

Page 26: Simulation de phénomènescollectifs - LORIA

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

Page 27: Simulation de phénomènescollectifs - LORIA

27

V. Chevrier

Page 28: Simulation de phénomènescollectifs - LORIA

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)

Page 29: Simulation de phénomènescollectifs - LORIA

29

V. Chevrier

A tutorial on netlogo

Page 30: Simulation de phénomènescollectifs - LORIA

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

Page 31: Simulation de phénomènescollectifs - LORIA

31

V. Chevrier

MAS modeling with netlogo

Ø EnvironmentØ AgentsØ DynamicsØ System loop/initialization

Page 32: Simulation de phénomènescollectifs - LORIA

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

Page 33: Simulation de phénomènescollectifs - LORIA

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, ….)

Page 34: Simulation de phénomènescollectifs - LORIA

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

Page 35: Simulation de phénomènescollectifs - LORIA

35

V. Chevrier

Basic elements in netlogo

Ø Creating turtles at random positionsØ Making them move

Page 36: Simulation de phénomènescollectifs - LORIA

36

V. Chevrier

Page 37: Simulation de phénomènescollectifs - LORIA

37

V. Chevrier

Page 38: Simulation de phénomènescollectifs - LORIA

38

V. Chevrier

Page 39: Simulation de phénomènescollectifs - LORIA

39

V. Chevrier

Makes turtles move randomly

Page 40: Simulation de phénomènescollectifs - LORIA

40

V. Chevrier

Basic elements in netlogo

Ø Creating turtlesØ Making them moveØ Defining procedures/global variablesØ Creating a basic graphical interfaceØ Simulating a model

Page 41: Simulation de phénomènescollectifs - LORIA

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

Page 42: Simulation de phénomènescollectifs - LORIA

42

V. Chevrier

Page 43: Simulation de phénomènescollectifs - LORIA

43

V. Chevrier

Page 44: Simulation de phénomènescollectifs - LORIA

44

V. Chevrier

Ø Putting all together• Merge initializations• Let’s rabbits eat, spend energy and die/reproduce• Provide a “loop” function

Ø Providing statistics

Page 45: Simulation de phénomènescollectifs - LORIA

45

V. Chevrier

initialization

Page 46: Simulation de phénomènescollectifs - LORIA

46

V. Chevrier

Procedure in code

Page 47: Simulation de phénomènescollectifs - LORIA

47

V. Chevrier

Rabbits behavior

Page 48: Simulation de phénomènescollectifs - LORIA

48

V. Chevrier

To be continued …

Ø See rabbit grass weeds in netlogo library