In my meager attempts to get an idea of agent based modeling, I have recently had a chance to play a bit with Netlogo. I wanted to build a simple model where information is diffused in an interpersonal network of people, and where each one has a different taste for some kind of news. Netlogo is an easy entry into the agent based modeling world since it provides a nice interace and a easy language. Wikipedia says about NetLogo:
“It was designed in the spirit of the Logo programming language to be “low threshold and no ceiling,” that is to enable easy entry by novices and yet meet the needs of high powered users. The NetLogo environment enables exploration of emergent phenomena. It comes with an extensive models library including models in a variety of domains such as economics, biology, physics, chemistry, psychology, system dynamics and many other natural and social sciences. Beyond exploration, NetLogo enables the quick and easy authoring of models.”
The software comes with an abundance of already existing models from Art, Sociology, Network Theory, Mathematics, Biology…. and countless more domains. My purpose was to come up with some model that represents a bit of the communication theory. So after doing the great tutorials provided here everybody should be able to come up with his first attempt.
As a basis for mine I have chosen the SIR model (Stonedahl, F. and Wilensky, U. (2008)) from epidemiology: In its description it says:
This model demonstrates the spread of a virus through a network. Although the model is somewhat abstract, one interpretation is that each node represents a computer, and we are modeling the progress of a computer virus (or worm) through this network. Each node may be in one of three states: susceptible, infected, or resistant. In the academic literature such a model is sometimes referred to as an SIR model for epidemics.
I have only chosen to change a few of the details and have come up with this message theory driven model, which is build around a few loose thoughts.
The model itsself, is not an attempt to create something rigorous, but just get to know how netlogo works.
The good thing about netlogo is that you can compile your model into a java applet and put it online. So here is mine. Feel free to experiment with it.
turtles-own [ broadcasted? ;; nodes reached by broadcasting infected? ;; if true, the turtle is infectious genre ;; has some sort of preference for a specific genre personal_threshold ;; threshold an agent has ] to setup ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) __clear-all-and-reset-ticks setup-nodes setup-spatially-clustered-network ask n-of initial-outbreak-size turtles [ become-infected ] ask links [ set color white ] update-plot end to broadcast_to_turtle ask n-of initial-outbreak-size turtles [ become-infected_by_broadcast ] end to setup-nodes set-default-shape turtles "circle" crt number-of-nodes [ ; for visual reasons, we don't put any nodes *too* close to the edges setxy (random-xcor * 0.95) (random-ycor * 0.95) become-susceptible ] end to setup-spatially-clustered-network let num-links (average-node-degree * number-of-nodes) / 2 while [count links < num-links ] [ ask one-of turtles [ let choice (min-one-of (other turtles with [not link-neighbor? myself]) [distance myself]) if choice != nobody [ create-link-with choice ] ] ] ; make the network look a little prettier repeat 10 [ layout-spring turtles links 0.3 (world-width / (sqrt number-of-nodes)) 1 ] end to go if all? turtles [infected?] [ stop ] spread-virus if broadcast [broadcast_to_turtle] tick update-plot end to become-infected ;; turtle procedure set infected? true set color red end to become-infected_by_broadcast ;; turtle procedure set infected? true set broadcasted? true set color red end to become-susceptible ;; turtle procedure set infected? false set broadcasted? false let my_genre (random number_of_genres) * 10 set personal_threshold global_personal_threshold set genre my_genre set color 32 + my_genre end to spread-virus ask turtles with [infected?] [ ask link-neighbors with [(not infected?) and (genre = message_genre)] [ if random-float 100 < message-spread-chance [ let personal_value message_value + 5 if personal_value > personal_threshold [ become-infected ] ] ] ask link-neighbors with [(not infected?) and (genre != message_genre)] [ if random-float 100 < message-spread-chance [ if message_value > personal_threshold [ become-infected ] ] ] ] end to update-plot set-current-plot "Network Status" set-current-plot-pen "susceptible" plot (count turtles with [not infected?]) / (count turtles) * 100 set-current-plot-pen "infected" plot (count turtles with [infected?]) / (count turtles) * 100 set-current-plot-pen "broadcasted" plot (count turtles with [broadcasted?]) / (count turtles) * 100 end ; Copyright 2008 Uri Wilensky. All rights reserved. ; The full copyright notice is in the Information tab.
I find it quite interesting how hard it is to use some of the “viral” network effects once you assume that people are quite lazy and and forward only their own stuff. Also the less heterogenous (less number of people with different genres) the easier it is for the message to find a path and propagate.
@krittina had posted a small pdf from Duncan Watts about the nonexisting holy grail of marketing. (Check it out here ). I would be very interested what you think about it. Tell me on twitter.