# Spatial Opinion Dynamics with Two Types of Mixing

Model was written in NetLogo 6.0.1
•
Viewed 216 times
•
Downloaded 10 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

extensions [rnd] globals [ fizz ; measures the frequency of attitudes that change at each step L2 ;frequency of -2 attitudes L1 ;frequency of -1 attitudes R1 ;frequency of 1 attitudes R2 ;frequency of 2 attitudes interface-density relocate-timer telephone-timer num-turtles last-cross ;this is the last time step where the centers cross (1 if they never did) last-op-cross ; this is the last time step where the opinions cross (1 if they never did) higher-center ; this keeps track of which center has the higher frequency higher-op ] turtles-own [ old-attitude new-attitude ] to setup clear-all ask patches [set pcolor gray] set-default-shape turtles "square" make-turtle-distribution ask turtles [ set size 1.2 set old-attitude new-attitude set color 5 - ((old-attitude / max-entrench) * 4.9) ] ; in order to do synchronous updating, we need to delay when agents update their attitudes, so we separate attitudes into new and old set fizz 0 measure-frequency-over-time set num-turtles count turtles ifelse L1 > R1 [set higher-center "L1"] [set higher-center "R1"] ifelse (L1 + L2) > (R1 + R2) [set higher-op "L"] [set higher-op "R"] set last-cross 1 if measure-interface-density [measuring-interface-density] reset-ticks end to go if not any? turtles with [old-attitude >= 1] or not any? turtles with [old-attitude <= -1] [stop] ask turtles [ local-interactions ] if relocation [ relocate ] if telephone? [ ifelse telephone-timer = 0 [set telephone-timer telephone-freq] [set telephone-timer telephone-timer - 1 ] ] set fizz (count turtles with [old-attitude != new-attitude]) / count turtles ask turtles [ set old-attitude new-attitude set color 5 - ((old-attitude / max-entrench) * 4.9) ] measure-frequency-over-time check-last-cross if measure-interface-density [measuring-interface-density] tick end to local-interactions let j nobody ; j will be the other agent, which we initially set as nobody ifelse influence = "max-inf" or influence = "min-inf" [ if influence = "max-inf" [ set j max-one-of turtles-on neighbors [abs old-attitude] ] if influence = "min-inf" [ set j min-one-of turtles-on neighbors [abs old-attitude] ] ] [ ifelse telephone? and telephone-timer = 0 and random-float 1 < frac-to-telephone [ set j one-of turtles ] [ set j rnd:weighted-one-of (turtles-on neighbors) [abs influence-function [old-attitude] of self] ] ] if is-turtle? j [ ;it is possible that no agent ends up getting picked in the line above, so this checks that someone has ifelse random-float 1 < opinion-amplification [ if [old-attitude] of j > 0 [ if abs old-attitude < max-entrench [ ifelse old-attitude = -1 [set new-attitude 1] [ set new-attitude old-attitude + 1 ]] ] if [old-attitude] of j < 0 [ if abs old-attitude < max-entrench [ ifelse old-attitude = 1 [set new-attitude -1] [set new-attitude old-attitude - 1 ]] ]] [ if [old-attitude] of j > old-attitude [ ifelse old-attitude = -1 [set new-attitude 1] [ set new-attitude old-attitude + 1]] if [old-attitude] of j < old-attitude [ ifelse old-attitude = 1 [ set new-attitude -1][set new-attitude old-attitude - 1 ]] ] ] end to relocate ; much faster then using "ask turtles []" let allagents [self] of n-of (floor (frac-to-relocate * num-turtles)) turtles ; create a list of all agents let total ((length allagents) - 1) let i 0 while [i < total] ; for each 2 agents in a list [ let tempx [xcor] of item i allagents let tempy [ycor] of item i allagents ask (item i allagents) [ set xcor [xcor] of item (i + 1) allagents set ycor [ycor] of item (i + 1) allagents] ask (item (i + 1) allagents) [set xcor tempx set ycor tempy] set i (i + 2) ; increment index by 2 ] end to-report influence-function [item1] if influence = "linear" [ ifelse item1 = 0 [report 1] [report item1] ] ; this is the linear update function if influence = "square" [ ifelse item1 = 0 [report 1] [report (item1 ^ 2)]] ; this weighs extreme attitudes more than moderate ones if influence = "uniform" [ if item1 < 0 [report -1] if item1 > 0 [report 1] ] if influence = "co-linear" [ ifelse item1 = 0 [report 1] [report (max-entrench + 1 - abs item1) ] ] if influence = "co-square" [ ifelse item1 = 0 [report 1] [report (max-entrench + 1 - abs item1) ^ 2 ] ] end to make-turtle-distribution ifelse rnd-initial [ ask patches [;; every patch will either have a positive or negative attitude placed on them. The probability of one over the other is set by polluter-to-nonpolluter-ratio ifelse random-float 1 < positive-to-negative-ratio [ sprout 1 [ set new-attitude (random init-attitude) + 1 ] ] [ sprout 1 [ set new-attitude 0 - (random init-attitude) - 1 ] ] ] ][;;otherwise, the positive attitudes are arranged to form a circle, with a radius set by radius-size ask patches [ ifelse (abs pxcor) ^ 2 + (abs pycor) ^ 2 <= radius-size ^ 2 [ sprout 1 [ set new-attitude max-entrench ] ] [ sprout 1 [ set new-attitude (0 - max-entrench) ] ] ] ] end to check-last-cross let hc "" ifelse L1 > R1 [set hc "L1"] [set hc "R1"] if higher-center != hc [ set higher-center hc set last-cross ticks ] let ho "" ifelse (L1 + L2) > (R1 + R2) [set ho "L"] [set ho "R"] if higher-op != ho [ set higher-op ho set last-op-cross ticks ] end to measuring-interface-density let g [] ask turtles [ let d 0 ask turtles-on neighbors [ if ([old-attitude] of self * [old-attitude] of myself) < 0 [set d d + 1] ] set g fput (d / 8) g ] set interface-density mean g end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; STATISTICS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to measure-frequency-over-time set L2 count turtles with [old-attitude = -2] / count turtles set L1 count turtles with [old-attitude = -1] / count turtles set R1 count turtles with [old-attitude = 1] / count turtles set R2 count turtles with [old-attitude = 2] / count turtles end ;; Copyright Bert Baumgaertner ;; See info tab for credits

There are 3 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

rnd.jar | extension | Copy this extension into a folder you create called "rnd" in the extensions folder. | 10 months ago, by Bert Baumgaertner | Download |

Spatial Opinion Dynamics with Two Types of Mixing.png | preview | Preview for 'Spatial Opinion Dynamics with Two Types of Mixing' | over 2 years ago, by Bert Baumgaertner | Download |

This model does not have any ancestors.

This model does not have any descendants.