Opinion Dynamics: Friedkin-Johnsen Model - Basic
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
globals [ num-agents ;; Number of agents neighbor-radius ;; Radius for neighbor detection step-counter ;; Time step counter ] turtles-own [ opinion ;; Agent's opinion (0-1) self-weight ;; Weight given to self-opinion neighbor-weights ;; List associating neighbors with their weights ] to setup clear-all reset-ticks ;; Parameter initialization set num-agents 200 set neighbor-radius 5 set step-counter 0 ;; Create agents (uniform distribution) create-turtles num-agents [ set shape "circle" set size 1.5 ;; Random position and opinion setxy random-xcor random-ycor set opinion random-float 1 ;; Uniformly distributed initial opinions update-weights ;; Initialize weights update-color ;; Set color based on opinion ] end to update-weights ;; Clear and recalculate all weights set self-weight 0.2 ;; Fixed self-weight at 0.2 set neighbor-weights [] ;; Empty neighbor weights list ;; Get neighbor agents (excluding self) let my-neighbors other turtles in-radius neighbor-radius let neighbor-total-weight 0 let neighbor-list sort my-neighbors ;; Calculate neighbor weights (excluding self) foreach neighbor-list [ n -> let dist distance n let w exp (-5 * dist) ;; Weight calculated using exponential decay set neighbor-weights lput (list n w) neighbor-weights set neighbor-total-weight neighbor-total-weight + w ] ;; Normalize neighbor weights (sum of neighbor weights = 1) let normalized-neighbor-weights [] foreach neighbor-weights [ pair -> let neighbor item 0 pair let weight item 1 pair set normalized-neighbor-weights lput (list neighbor (weight / neighbor-total-weight)) normalized-neighbor-weights ] set neighbor-weights normalized-neighbor-weights end to update-color ;; More positive opinions (near 1) are lighter blue ;; More negative opinions (near 0) are darker blue set color scale-color blue opinion 0 1 end to go if not any? turtles [ stop ] ;; Update weights and calculate new opinions ask turtles [ update-weights let new-op 0 ;; Contribution from self-opinion set new-op new-op + self-weight * opinion ;; Weighted contributions from all neighbors let neighbor-influence 0 foreach neighbor-weights [ pair -> let neighbor item 0 pair let weight item 1 pair set neighbor-influence neighbor-influence + weight * [opinion] of neighbor ] set new-op new-op + (1 - self-weight) * neighbor-influence set opinion new-op update-color ;; Update color mapping ] set step-counter step-counter + 1 tick end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
GIF1.gif | gif | With agents having fixed social interaction ranges, group opinions fragment into several camps, giving rise to localized opinion assimilation. | about 1 month ago, by Mutian Zhao | Download |
Opinion Dynamics: Friedkin-Johnsen Model - Basic.png | preview | Initially, attitudes are uniformly distributed. The lighter a turtle's color, the more positive its opinion; conversely, the darker the color, the more negative its opinion. | about 1 month ago, by Mutian Zhao | Download |
This model does not have any ancestors.
This model does not have any descendants.