The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.
Here you have an explanatory report about the work.
powered by NetLogo
view/download model file: network_of_opinions.nlogo
The project's purpose is to observe how a human-like network reacts to the diffusion of news. The simulation takes into account a small set of parameters (editable by user), then plots at each time step, the system's opinion (in form of an hystogram) depending on all the parameters.
The set of parameters includes:
number-of-agents: the number of nodes that will be created, at the beginning of the simulations, to obtain a network
news: the data that will be available to each agent in the system. From the agents' point of view there will be 3 news, with the same value of this parameter, but tagged in 3 different ways to simulate the coexistence of 3 political parties
information-mean: the mean value that will be used to construct a normal distribution from which random normal values will be estracted and given to each agent, to set their "Information level" (the ability to autonomously get the news from system)
information-stdev: the standard deviaton of the above mentioned normal distibution
knowledge-mean: the mean value that will be used to construct a normal distribution from which random normal values will be estracted and given to each agent, to set their "Knowledge level" (the ability to correctly understand the obtained news)
knowledge-stdev: the standard deviaton of the above mentioned normal distibution
leverage-mean: the mean value that will be used to construct a normal distribution from which random normal values will be estracted and given to each agent, to set their "Leverage level" (the tendency of each agent to assume an opinion similar to the opinion of his neighbors)
leverage-stdev: the standard deviaton of the above mentioned normal distibution
The network is created using a preferential attachment algorithm, like the one proposed by Barabasi-Albert (Emergence of scaling in random networks; Albert-Laszlo Barabasi ? Reka Albert), then the nodes are arranged to obtain a "user friendly" layout. Each time a node is created, the program sets all the parameters needed to run the sumulation using the data shown on the sliders (like information-mean, information-stdev, etc.).
Once the network is complete it's possible to start the simulation:
The first operation made by the program, is to check if the agents receive (or not) the informations (news) available in the system.
One random value in the [0,1) range is generated and confronted with the information level of the agent: if the random value was less than or equal to the information level, the agent successfully receives the news. This operation is repeated for each agent in the network, and for each of the 3 tipes of news (3 tags)
The second operation is to check if the agents have understood correctly the news, or if their level of knowledge introduced an error. To do this, a new check is made, using the same operation explained above. This time, if the check is successful, the agents copy the exact news into their private variables. If the check is not successful, an error is introduced: the lower the knowledge level of the agents, the bigger the error that will be introduced.
The third step involves political orientation. With another check the program determine if the agents agree with the news they get. Each agent compute its own level of confidence in each one of the political parties present in the system (3 for now). This computation is based upon its political orientation. Then this "confidence" is used to check if the agents believe o simply agree, with the news acconding to their sources.
For expample an agent member of the party "-1" (possible parties -1,0,1), has a higher probability to agree with a news coming from a source, that is also member of the same party, and, of course, a lower probability to agree with the news coming from the other sources.
The fourth step involves comunication between agents: after all the agents that received a news in the step one, have completed the above steps, it's time for the other, less informed agents, to become part of the process.
Each agent asks all its neighbors for their own opinion (news received and alterated by knowledge level or political orientation), then weighs all these opinion according to its confidence in the source (determined by political orientation) and according to its own leverage level (the tendency to imitate others). Finally the agent assumes a final opinion taking into account all these elements.
The fourth step is then repeated until a stationary state is reached or until the user stops the simulation. At each tick a histogram, showing the opinion distribution of the system, is updatad, allowing the user to understand what is happining iside the network.
-set the number of agents (number of nodes in the network)
-set the news (the information that will be available to agents during simulation)
-set the sliders for Information, Knowledge, Leverage level (mean & stdev)
-create network (a network is created with all the paramaters set)
-go (the agent start to complete all the steps expalined above)
-color by "selection" & update colors (filters to get more visual info on the network)
-Information Level
-Knowledge Level
-Social Leverage
-Political orientation
For these 4 filters similar colors correspond to similar opinions
-Party
Color code: -1 = red ; 0 = yellow ; 1 = cian
-News Received
Color code: 0 = red ; 1 = orange ; 2 = yellow ; 3 = green
-Agreement
Color code: 0 = red ; 1 = orange ; 2 = yellow ; 3 = green
-It's possible to modify the values of the parameters used to create te network, also after the creation process, using sliders al clicking on the corresponding set button
Width and average of the Histogram of opinons.
Time needed to get to a stationary state or at least to make all the opinons set near the value of the news.
The distibution of the agents using the color filters.
Try moving the sliders controlling the system parameters and se how they influence the outcome of the opinion distribution on the system
There are a lot of possible steps that could be taken in the analisys of this kind of networks.
First of all, mainly for lack of time, it’s not been possible to investigate the agreement of the agents concerning the news received: a couple of variable are taking this into account, but this informations, for now, are not used to study the system.
Another interesting development could be the evolution of the network on two different levels:
on a microscopic level, we could have agents able to learn from experience and change not only their opinions, but also the parameters used to get the news from the system or from other agents.
On a macroscopic level we could develop a network evolving in time, with agents borning and dying (at a given rate) during the simulation and observe how the experience made by the agents can pass on to the new generations.
It could also be interesting to see how this kind of network would react to the coexistence of totally different news.
Finally we have the feeling that the software created could be investigated in a deeper way trying to find analitical expression for the opinion distribution obtained, or simply getting other informations from the system, getting to a more complete characterization of the diffusion and reception of news into a real-like network.
For the part concerning the creation of the network and its layout this model is based upon the "Preferential Attachment" model already present in the NetLogo models library
- Copyright 2005 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/PreferentialAttachment for terms of use.
globals [n-times info-counter knowledge-counter political-counter] breed [people person] breed [spreaders spreader] people-own [ information-level knowledge-level political-orientation leverage-level info-L-received info-C-received info-R-received info-n data-L data-C data-R news-weighted news-indirect news-final confidence-L confidence-C confidence-R weight-L weight-C weight-R agreement-L agreement-C agreement-R agreement-n party comp-err pol-err ] spreaders-own [party] to reset-network clear-all end to create-network initialize evolve plot-info end to set-initial-conditions reset-vars set-information-level2 set-knowledge-level2 set-political-orientation2 set-confidence2 set-leverage2 end to go check-info check-knowledge check-political check-friends set-opinion plot-opinions update-colors end ;; END OF MAIN OPERATIONS: DEFINING SUB-FUNCTIONS to initialize ifelse ticks = 0 [ set-default-shape turtles "circle" make-node nobody ask turtles [ set color white set political-orientation precision (random-float 2 - 1) 2 ] make-node turtle 0 ask turtle 1 [ set color white set-political-orientation turtle 0 ] set n-times number-of-people - 2 ] [set n-times number-of-people] end to evolve repeat n-times [ ask links [ set color gray ] make-node find-partner layout tick ] end to make-node [old-node] create-people 1 [ set color red if old-node != nobody [ create-link-with old-node [ set color green ] move-to old-node fd 8 set-leverage set-political-orientation old-node set-information-level set-knowledge-level set-confidence ] ] end to-report find-partner let total random-float sum [count link-neighbors] of turtles let partner nobody ask turtles [ set color white let nc count link-neighbors if partner = nobody [ ifelse nc > total [ set partner self ] [ set total total - nc ] ] ] report partner end to layout ;; the number 3 here is arbitrary; more repetitions slows down the ;; model, but too few gives poor layouts repeat 3 [ ;; the more turtles we have to fit into the same amount of space, ;; the smaller the inputs to layout-spring we'll need to use let factor sqrt count turtles ;; numbers here are arbitrarily chosen for pleasing appearance layout-spring turtles links (1 / factor) (7 / factor) (1 / factor) display ;; for smooth animation ] ;; don't bump the edges of the world let x-offset max [xcor] of turtles + min [xcor] of turtles let y-offset max [ycor] of turtles + min [ycor] of turtles ;; big jumps look funny, so only adjust a little each time set x-offset limit-magnitude x-offset 0.1 set y-offset limit-magnitude y-offset 0.1 ask turtles [ setxy (xcor - x-offset / 2) (ycor - y-offset / 2) ] end to-report limit-magnitude [number limit] if number > limit [ report limit ] if number < (- limit) [ report (- limit) ] report number end to reset-vars ask people [ set info-L-received false set info-C-received false set info-R-received false set data-L 0 set data-C 0 set data-R 0 set news-weighted 0 set news-indirect 0 set news-final 0 set weight-L 0 set weight-C 0 set weight-R 0 set agreement-L 0 set agreement-C 0 set agreement-R 0 set party 0 set comp-err 0 set pol-err 0 ] set info-counter 0 set knowledge-counter 0 set political-counter 0 end to set-information-level let counter 0 while [counter != 1] [ set information-level (precision (random-normal information-mean information-stdev) 2) if (information-level >= 0 and information-level < 1.00) [set counter 1] ] end to set-information-level2 reset-information ask people [ let counter 0 while [counter != 1] [ set information-level (precision (random-normal information-mean information-stdev) 2) if (information-level >= 0 and information-level < 1.00) [set counter 1] ] ] set-current-plot "Information" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [information-level] of people update-colors end to set-knowledge-level let counter 0 while [counter != 1] [ set knowledge-level (precision (random-normal knowledge-mean knowledge-stdev) 2) if (knowledge-level >= 0 and knowledge-level < 1.00) [set counter 1] ] end to set-political-orientation2 reset-political ask people [ let target (max-one-of link-neighbors [count link-neighbors]) ifelse ((precision (random-float 1) 2) < leverage-level) [ if ([party] of target = -1) [set political-orientation precision ((random-float -0.66) - 0.33) 2] if ([party] of target = 0) [set political-orientation precision ((random-float 0.66) - 0.33) 2] if ([party] of target = 1) [set political-orientation precision ((random-float 0.66) + 0.33) 2] ] [set political-orientation precision ((random-float 2) - 1) 2] if (political-orientation <= -0.33) [set party (- 1)] if (political-orientation > -0.33 and political-orientation < 0.33) [set party 0] if (political-orientation >= 0.33) [set party 1] ] set-current-plot "Politics" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [political-orientation] of people update-colors end to set-political-orientation [target] ifelse ((precision (random-float 1) 2) < leverage-level) [ if ([party] of target = -1) [set political-orientation precision ((random-float -0.66) - 0.33) 2] if ([party] of target = 0) [set political-orientation precision ((random-float 0.66) - 0.33) 2] if ([party] of target = 1) [set political-orientation precision ((random-float 0.66) + 0.33) 2] ] [set political-orientation precision ((random-float 2) - 1) 2] if (political-orientation <= -0.33) [set party (- 1)] if (political-orientation > -0.33 and political-orientation < 0.33) [set party 0] if (political-orientation >= 0.33) [set party 1] end to set-confidence let counter 0 while [counter != 1] [ set confidence-L (precision (0.50 - 0.50 * political-orientation) 2) if (confidence-L >= 0 and confidence-L <= 1.00) [set counter 1] ] set counter 0 while [counter != 1] [ set confidence-C (precision (1 - abs(0.50 * political-orientation) )2) if (confidence-C >= 0 and confidence-C <= 1.00) [set counter 1] ] set counter 0 while [counter != 1] [ set confidence-R (precision (0.50 + 0.50 * political-orientation) 2) if (confidence-R >= 0 and confidence-R <= 1.00) [set counter 1] ] end to plot-info set-current-plot "Information" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [information-level] of people set-current-plot "Knowledge" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [knowledge-level] of people set-current-plot "Social Leverage" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [leverage-level] of people set-current-plot "Politics" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [political-orientation] of people update-colors end to set-knowledge-level2 reset-knowledge ask people [ let counter 0 while [counter != 1] [ set knowledge-level (precision (random-normal knowledge-mean knowledge-stdev) 2) if (knowledge-level >= 0 and knowledge-level < 1.00) [set counter 1] ] ] set-current-plot "Knowledge" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [knowledge-level] of people update-colors end to set-confidence2 ask people [ let counter 0 while [counter != 1] [ set confidence-L (precision (0.50 - 0.50 * political-orientation) 2) if (confidence-L >= 0 and confidence-L <= 1.00) [set counter 1] ] set counter 0 while [counter != 1] [ set confidence-C (precision (1 - abs(0.50 * political-orientation) )2) if (confidence-C >= 0 and confidence-C <= 1.00) [set counter 1] ] set counter 0 while [counter != 1] [ set confidence-R (precision (0.50 + 0.50 * political-orientation) 2) if (confidence-R >= 0 and confidence-R <= 1.00) [set counter 1] ] ] end to set-leverage2 reset-leverage ask people [ let counter 0 while [counter != 1] [ set leverage-level (precision (random-normal leverage-mean leverage-stdev) 2) if (leverage-level >= 0 and leverage-level < 1.00) [set counter 1] ] ] set-current-plot "Social Leverage" set-current-plot-pen "People" set-histogram-num-bars 50 set-plot-y-range 0 5 histogram [leverage-level] of people update-colors end to set-leverage let counter 0 while [counter != 1] [ set leverage-level (precision (random-normal leverage-mean leverage-stdev) 2) if (leverage-level >= 0 and leverage-level < 1.00) [set counter 1] ] end to check-info if (info-counter = 0) [ ask people [ ifelse (precision (random-float 1) 2 <= information-level) [ set info-L-received true set info-n info-n + 1 ] [set info-L-received false] ifelse (precision (random-float 1) 2 <= information-level) [ set info-C-received true set info-n info-n + 1 ] [set info-C-received false] ifelse (precision (random-float 1) 2 <= information-level) [ set info-R-received true set info-n info-n + 1 ] [set info-R-received false] ] set info-counter 1 ] end to check-knowledge if (knowledge-counter = 0) [ ask people [ ifelse (info-L-received = true) [ ifelse (precision (random-float 1) 2 <= knowledge-level) [set data-L news] [ set comp-err (precision (1 - knowledge-level) 2) let epsilon (random-float (comp-err * 2) - comp-err) * news set data-L (precision (news + epsilon) 2) ] ] [ set data-L 0 ] ifelse (info-C-received = true) [ ifelse (precision (random-float 1) 2 <= knowledge-level) [set data-C news] [ set comp-err (precision (1 - knowledge-level) 2) let epsilon (random-float (comp-err * 2) - comp-err) * news set data-C (precision (news + epsilon) 2) ] ] [ set data-C 0 ] ifelse (info-R-received = true) [ ifelse (precision (random-float 1) 2 <= knowledge-level) [set data-R news] [ set comp-err (precision (1 - knowledge-level) 2) let epsilon (random-float (comp-err * 2) - comp-err) * news set data-R (precision (news + epsilon) 2) ] ] [ set data-R 0 ] ifelse(data-L = 0) [set weight-L 0] [set weight-L confidence-L] ifelse(data-C = 0) [set weight-C 0] [set weight-C confidence-C] ifelse(data-R = 0) [set weight-R 0] [set weight-R confidence-R] ifelse(weight-L = 0 and weight-C = 0 and weight-R = 0) [set news-weighted 0] [set news-weighted precision ((data-L * weight-L + data-C * weight-C + data-R * weight-R) / (weight-L + weight-C + weight-R)) 2] ] set knowledge-counter 1 ] end to check-political if (political-counter = 0) [ ask people [ if (info-L-received = true) [ ifelse (precision random-float 1 2 <= confidence-L) [ set agreement-L true set agreement-n (agreement-n + 1) ] [set agreement-L false] ] if (info-C-received = true) [ ifelse (precision random-float 1 2 <= confidence-C) [ set agreement-C true set agreement-n (agreement-n + 1) ] [set agreement-C false] ] if (info-R-received = true) [ ifelse (precision random-float 1 2 <= confidence-R) [ set agreement-R true set agreement-n (agreement-n + 1) ] [set agreement-R false] ] ] set political-counter 1 ] end to check-friends ask people [ let friends sort link-neighbors let friends-news map [[news-weighted] of ?] friends let friends-party map [[party] of ?] friends let friends-weight (map [check ?1 ?2] friends-news friends-party) set friends-news (map [precision (?1 * ?2) 2] friends-news friends-weight) let weights sum friends-weight let info sum friends-news ifelse (weights != 0) [set news-indirect precision (info / weights) 2] [set news-indirect 0] ] end to-report check [i j] if (i = 0) [report 0] if (j = -1) [report confidence-L] if (j = 0) [report confidence-C] if (j = 1) [report confidence-R] end to set-opinion ask people [ ifelse (news-weighted != 0) [ set news-final precision (news-indirect * leverage-level + news-weighted * (1 - leverage-level)) 2 set news-weighted news-final ] [ set news-final news-indirect set news-weighted news-final ] ] end to plot-opinions set-current-plot "Opinions" set-current-plot-pen "People" set-histogram-num-bars 75 set-plot-y-range 0 5 histogram [news-final] of people with [news-final != 0] end to update-colors-alternative ask people [ set size 1 if color-by = "Information Level" [set color (information-level * 140)] if color-by = "Knowledge Level" [set color (knowledge-level * 140)] if color-by = "Political Orientation" [set color (political-orientation * 140)] ] end to update-colors ask people [ set size 1 if color-by = "Information Level" ;; [set color (information-level * 140)] [ if information-level < 0.1 [ set color 15 ] if information-level >= 0.1 and information-level < 0.2[ set color 25 ] if information-level >= 0.2 and information-level < 0.3[ set color 35 ] if information-level >= 0.3 and information-level < 0.4[ set color 45 ] if information-level >= 0.4 and information-level < 0.5[ set color 55 ] if information-level >= 0.5 and information-level < 0.6[ set color 65 ] if information-level >= 0.6 and information-level < 0.7[ set color 75 ] if information-level >= 0.7 and information-level < 0.8[ set color 85 ] if information-level >= 0.8 and information-level < 0.9[ set color 95 ] if information-level >= 0.9 [ set color 105 ] ] if color-by = "Knowledge Level" [ if knowledge-level < 0.1 [ set color 15 ] if knowledge-level >= 0.1 and knowledge-level < 0.2[ set color 25 ] if knowledge-level >= 0.2 and knowledge-level < 0.3[ set color 35 ] if knowledge-level >= 0.3 and knowledge-level < 0.4[ set color 45 ] if knowledge-level >= 0.4 and knowledge-level < 0.5[ set color 55 ] if knowledge-level >= 0.5 and knowledge-level < 0.6[ set color 65 ] if knowledge-level >= 0.6 and knowledge-level < 0.7[ set color 75 ] if knowledge-level >= 0.7 and knowledge-level < 0.8[ set color 85 ] if knowledge-level >= 0.8 and knowledge-level < 0.9[ set color 95 ] if knowledge-level >= 0.9 [ set color 105 ] ] if color-by = "Social Leverage" [ if leverage-level < 0.1 [ set color 15 ] if leverage-level >= 0.1 and leverage-level < 0.2[ set color 25 ] if leverage-level >= 0.2 and leverage-level < 0.3[ set color 35 ] if leverage-level >= 0.3 and leverage-level < 0.4[ set color 45 ] if leverage-level >= 0.4 and leverage-level < 0.5[ set color 55 ] if leverage-level >= 0.5 and leverage-level < 0.6[ set color 65 ] if leverage-level >= 0.6 and leverage-level < 0.7[ set color 75 ] if leverage-level >= 0.7 and leverage-level < 0.8[ set color 85 ] if leverage-level >= 0.8 and leverage-level < 0.9[ set color 95 ] if leverage-level >= 0.9 [ set color 105 ] ] if color-by = "Political Orientation" [ if political-orientation < 0.1 [ set color 15 ] if political-orientation >= 0.1 and political-orientation < 0.2[ set color 25 ] if political-orientation >= 0.2 and political-orientation < 0.3[ set color 35 ] if political-orientation >= 0.3 and political-orientation < 0.4[ set color 45 ] if political-orientation >= 0.4 and political-orientation < 0.5[ set color 55 ] if political-orientation >= 0.5 and political-orientation < 0.6[ set color 65 ] if political-orientation >= 0.6 and political-orientation < 0.7[ set color 75 ] if political-orientation >= 0.7 and political-orientation < 0.8[ set color 85 ] if political-orientation >= 0.8 and political-orientation < 0.9[ set color 95 ] if political-orientation >= 0.9 [ set color 105 ] ] if color-by = "Information Received" [ if info-n = 0 [set color red] if info-n = 1 [set color orange] if info-n = 2 [set color cyan] if info-n = 3 [set color green] ] if color-by = "Party" [ if party = (- 1) [set color red ] if party = 0 [set color yellow] if party = ( 1) [set color cyan] ] if color-by = "Agreement" [ if agreement-n = 0 [set color red] if agreement-n = 1 [set color orange] if agreement-n = 2 [set color cyan] if agreement-n = 3 [set color green] ] ] end to reset-information ask people [ set info-L-received false set info-C-received false set info-R-received false set info-n 0 set data-L 0 set data-C 0 set data-R 0 set news-weighted 0 set news-indirect 0 set news-final 0 set weight-L 0 set weight-C 0 set weight-R 0 set agreement-L 0 set agreement-C 0 set agreement-R 0 set agreement-n 0 ] set info-counter 0 set knowledge-counter 0 set political-counter 0 end to reset-knowledge ask people [ set data-L 0 set data-C 0 set data-R 0 set news-weighted 0 set news-indirect 0 set news-final 0 set weight-L 0 set weight-C 0 set weight-R 0 set agreement-L 0 set agreement-C 0 set agreement-R 0 set agreement-n 0 set comp-err 0 set pol-err 0 ] set knowledge-counter 0 set political-counter 0 end to reset-political ask people [ set news-weighted 0 set news-indirect 0 set news-final 0 set weight-L 0 set weight-C 0 set weight-R 0 set agreement-L 0 set agreement-C 0 set agreement-R 0 set agreement-n 0 set comp-err 0 set pol-err 0 ] set knowledge-counter 0 set political-counter 0 end to reset-leverage ask people [ set news-indirect 0 set news-final 0 set agreement-n 0 ] set knowledge-counter 0 set political-counter 0 end