Opinion Dynamics: Friedkin-Johnsen Model - Basic
Model was written in NetLogo 6.3.0
•
Viewed 7 times
•
Downloaded 0 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
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 7 hours 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 7 hours ago, by Mutian Zhao | Download |
This model does not have any ancestors.
This model does not have any descendants.