Emperor's Dilemma (optional coloring)

Emperor's Dilemma (optional coloring) preview image

1 collaborator

Default-person Artem Serdyuk (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 41 times • Downloaded 4 times • Run 0 times
Download the 'Emperor's Dilemma (optional coloring)' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [believers believer]
breed [disbelievers disbeliever]
breed [recovers recover]
globals [infected_per infected_mean infected_list

  ]
turtles-own [
  Beliefs ; B = 1 if believes; B = -1 if doesn't believe;
  Strength  ; strength of belief varies from 0 to 1
  Compliance ; binary; 1 if complies/enforces norm, and 0 otherwise.
  Enforcement ; 1 if enforces norm; -1 if enforces deviance.
  Enforcement_Need ; Wi = 1-(Bi/Ni)SumCj / 2
       ;; is just the proportion of i's neighbors whose behavior does not conform with it's Beliefs B
  Enforcement_Need_2  ;; same # but divided by 2; as used in the article.
  N_Neighbors
  Convert

]

;; CODE:
;; BELIEVERS = arrow, DISBELIEVERS = default shape
;; COMPLIANCE = RED, DEVIANCE = BLUE
;; ENFORCEMENT = HEADING TO THE RIGHT (90) ; NO ENFORCEMENT = HEADING TO THE LEFT (270)


;; Basic MODEL of ED:  1.  agents observe neighbors compliance and enforcement.  2.  Each agent then makes two decisions:
;; (i) whether to comply with the norm, and (ii) whether to enforce the norm.

to setup
  clear-all
  let IB initial_believers
  let ID population - IB

    ;if Condition = "Local Random" OR Condition = "Global"  [
     create-believers IB [
     set size 1 set color yellow
      setxy random-pxcor random-pycor
      while [any? other turtles-here] [ let empty_patch one-of patches with [any? turtles-here = false] move-to empty_patch ]
    ]

 if Condition = "Local Clustered" [
      let a 20
      let b 12
      let p patch 20 12

      let d (list believers)
      foreach d [ ?1 ->
       ask ?1 [move-to p
       set p patch-at-heading-and-distance 45 1]
      ]

      ]

 ask believers[
         set Beliefs 1
         set Strength 1 ;; by default all true believers initially comply!
         set compliance 1
         set convert 0

         set shape "circle"
         set color yellow
         ;set heading 90  ; NO INITIAL ENFORCEMENT
 ]

   create-disbelievers ID [
         set shape "circle"
         set size 1 set color blue; BLUE COLOR BECAUSE NOT COMPLYING WITH
         setxy random-pxcor random-pycor
         while [any? other turtles-here] [ let empty_patch one-of patches with [any? turtles-here = false] move-to empty_patch ]
         set Beliefs -1
         set Strength random-float 0.38
         set convert 0

         set compliance -1
         ;set heading 90 ; NO INITIAL ENFORCEMENT
   ]

   ask turtles [setup-map]

reset-ticks
end 

to START!
  ED
  update-plots
  tick
end 

to setup-map

    if Condition = "Global" [set N_Neighbors Other Turtles]
    if Condition = "Local Clustered" OR Condition = "Local Random" [
      set N_Neighbors turtle-set turtles-on neighbors

      if small_worlds? = true [
        small-worlds
      ]
    ]
end 

to ED
  ask turtles [

      if small_worlds? = true AND Continuous-Rewiring? = true AND Condition != "Global" [
        small-worlds
      ]


   let Ni_list (list N_Neighbors)
   let Ni count N_Neighbors
   if Ni = 0 [set Ni 1]
   let Bi [Beliefs] of self
   let NCi count N_Neighbors with [Compliance = Bi]

    set Enforcement_Need 1 - (NCi / Ni)
    set Enforcement_Need_2 Enforcement_Need / 2
   ; output-print Enforcement_Need_2

COMPLY?
ENFORCE?
  ]
end 


TO COMPLY?
  ;; disbeliever complies if the proportion of neighbors enforcing compliance is greater than the strength of disbeliever's belief;
   let S [strength] of self
   let Bi [Beliefs] of self
   let Ej count N_Neighbors with [Enforcement = -1 * Bi] ;; neighbors enforcing opposite belief
   let Ni count N_Neighbors
   if Ni = 0 [set Ni 1]

  ifelse (Ej / Ni) > S [set compliance -1 * Bi] [set compliance Bi]

  if (Compliance = 1 and Bi = 1) [set color yellow] ;; true believer
  if (Compliance = 1 and Bi = -1) [set color green] ;; false believer
  if (Compliance = -1 and Bi = -1) [set color blue] ;; true disbeliever
  if (Compliance = -1 and Bi = 1) [set color cyan] ;; false disbeliever
end 

to ENFORCE?

   let S [strength] of self
   let Bi [Beliefs] of self
   let Ci [Compliance] of self
   let Ej count N_Neighbors with [Enforcement = -1 * Bi] ;; neighbors enforcing opposite belief
   let Ni count N_Neighbors
   if Ni = 0 [set Ni 1]
   let Wi Enforcement_Need_2

     ifelse (Ej / Ni) > (S + K) AND Bi != Ci [set Enforcement -1 * Bi]
     ; Enforcement is opposite of belief if:
     ; a) the proportion of enforcement against belief is greater than the strength of belief plus the cost of enforcement, AND
     ; b) agent already complies against agent's own belief; violates one's own belief already.
     ;; THIS MEANS THAT AGENTS CANNOT ENFORCE COMPLIANCE UNLESS THEY HAVE ALREADY COMPLIED.
  [
     ifelse S * Wi > K AND Bi = Ci [set Enforcement Bi]
     [set Enforcement 0]
  ]
  if (Enforcement = 1 and Bi = 1) [set color red] ;; true believe enforcer
  if (Enforcement = 1 and Bi = -1) [set color orange]  ;; false believe enforcer
  if (Enforcement = -1 and Bi = -1) [set color brown] ;; true disbelief enforcer
  if (Enforcement = -1 and Bi = 1) [set color magenta] ;; false disbelief enforcer

 if conversion? = true [CV]
end 

to CV
  let a conversion / 10000   ; 1 will equal .0001 - the learning parameter set in the article

  if Enforcement != Beliefs [
   set convert convert - (a * Enforcement * Beliefs)

   if convert > Strength AND Beliefs != compliance [
     hatch-believers 1 [set shape "circle" set color yellow set Beliefs 1 set compliance 1 set convert 0
         ;set heading 90
     ];;  NOTICE THAT I AM NOT RESETTING THE STRENGTH OF THEIR CONVICTIONS.  THESE NEW CONVERTS ARE A LESS CONVINCED GROUP OF BELIEVERS THAN THE ORIGINAL!
     die ;; THE ORIGINAL DISBELIVER DIES
     ]

  ]
end 

to small-worlds

let a self
let N_list []
let h turtle-set turtles-on neighbors
let g turtle-set N_Neighbors
; ask N_Neighbors [set color yellow]
ask N_Neighbors [

      ;; whether to rewire it or not?
      ifelse (random-float 1) < rewiring-probability
      [


      let b  (turtle-set a h g) ; a = self, original turtle; N_neighbors list here includes this turtle replacing itself with another random turtle
      let c one-of turtles
      while [member? c b = true] [set c one-of turtles]  ; keeps changing the turtle until it isn't itself or a neighbor

          ask a [set N_list fput c N_list]
          ;  set N_list replace-item (? - 1) N_list c
          ;show N_list
          ask c [set color brown]
            ]
      [ask a [set N_list fput myself N_list]] ;;myself or self?
]
        ;; must be ? - 1 to replace the correct turtle

   ask a [set N_Neighbors turtle-set N_list] ; must go back and ask original turtle to do this!
end 

to-report prcnt_comply
  let comply count turtles with [compliance = 1]
  let Ni count turtles
  if Ni = 0 [set Ni Ni + 1]
  report (comply / Ni) * 100
end 

to-report prcnt_enforce
  let enforce count turtles with [enforcement = 1]
  let Ni count turtles
  if Ni = 0 [set Ni Ni + 1]
  report (enforce / Ni) * 100
end 

to-report prcnt_believe
  let B count believers
  let Ni count turtles
  if Ni = 0 [set Ni Ni + 1]
  report (B / Ni) * 100
end 

to-report false_comply ;; proportion of disbelievers who falsely comply
  let D count disbelievers
  if D = 0 [set D D + 1]
  let F count disbelievers with [Compliance = 1]
  report (F / D) * 100
end 

to-report false_enforce
let D count disbelievers
if D = 0 [set D D + 1]
let F count disbelievers with [Enforcement = 1]
report (F / D) * 100
end 

to-report false_comply_disbelief ;; proportion of believers who falsely comply
  let D count believers
  if D = 0 [set D D + 1]
  let F count believers with [Compliance = -1]
  report (F / D) * 100
end 

to-report false_enforce_disbelief
let D count believers
if D = 0 [set D D + 1]
let F count believers with [Enforcement = -1]
report (F / D) * 100
end 

There are 3 versions of this model.

Uploaded by When Description Download
Artem Serdyuk about 1 month ago added new monitors - false believers compliance and enforcement Download this version
Artem Serdyuk about 1 month ago Updated view, added tick counter Download this version
Artem Serdyuk about 1 month ago Initial upload Download this version

Attached files

File Type Description Last updated
Emperor's Dilemma (optional coloring).png preview Preview for 'Emperor's Dilemma (optional coloring)' about 1 month ago, by Artem Serdyuk Download

This model does not have any ancestors.

This model does not have any descendants.