Dialogue tool of the INCITE-DEM

Dialogue tool of the INCITE-DEM preview image

1 collaborator

Default-person Shaoni Wang (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.3.0 • Viewed 45 times • Downloaded 1 time • Run 0 times
Download the 'Dialogue tool of the INCITE-DEM' 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

; this is a version of HUMAT which works for observable behaviours; for unobservable behaviours the knowledge about alters
; in the social networks will have to be represented differently, and this has an impact on dissonance reduction strategies
; (how do you calculate social satisfaction?, how do you choose who to get information from? and how do you choose who to try to convince?)
extensions [ palette ]

breed [humats humat]
breed [influencers influencer]
undirected-link-breed [connections connection]  ;connections among citizens
directed-link-breed [relations relation]   ;relations between citizens and authorites

globals [
  behavioural-alternatives
  exp-satisfaction-A
  soc-satisfaction-A
  val-satisfaction-A
  exp-satisfaction-B
  soc-satisfaction-B
  val-satisfaction-B
  supporters
  opponents
  A-supporters
  B-supporters
  A-value+       ; opponents with satisfaction
  A-value-       ; opponents with dissatisfaction
  A-value
  B-value+
  B-value-
  B-value
  group-number
  num-removed    ; number of groups that have been removed
  setup?         ; being setted up or not
  %enhancing-experiential-satisfation
  %enhancing-value-satisfaction
  num-authority
  norm-influence
]

influencers-own [
  influence     ;for now random < 0 ; 1 > the higher, the less-or-more-vocalful
  endorsement   ; endorsing an alternative
]

connections-own [
  link-color
]
humats-own [
  behaviour
  ses   ;socio-economic status ; for now random < 0 ; 1 > the higher, the less-or-more-vocalful
  group-id
  tendency-for-change
  vocie-being-heard

;;;dissonance-related variables;;; ;variables calculated for all BAs;
  experiential-importance
  social-importance
  values-importance
  non-social-importance

  experiential-satisfaction-A
  social-satisfaction-A
  values-satisfaction-A
  non-social-evaluation-A

  experiential-satisfaction-B
  social-satisfaction-B
  values-satisfaction-B
  non-social-evaluation-B

  experiential-evaluation-A ; evaluation of A (behavioural alternative i) with respect to experiential group of needs for HUMAT j <-1;1>
  social-evaluation-A ; evaluation of A (behavioural alternative i) with respect to social group of needs for HUMAT j <-1;1>
  values-evaluation-A ; evaluation of A (behavioural alternative i) with respect to values for HUMAT j <-1;1>
  experiential-evaluation-B ; evaluation of B (behavioural alternative ~i) with respect to experiential group of needs for HUMAT j <-1;1>
  social-evaluation-B ; evaluation of B (behavioural alternative ~i) with respect to social group of needs for HUMAT j <-1;1>
  values-evaluation-B ; evaluation of B (behavioural alternative ~i) with respect to values for HUMAT j <-1;1>

  evaluations-list-A
  evaluations-list-B

  evaluations-A
  evaluations-B

  satisfaction-A
  satisfaction-B

  satisfaction ;the satisfaction of the decision
  support      ;the degreen of the support
  satisfying-A ; the sum of satisfying evaluations of A over three groups of needs <0;1,5>
  satisfying-B ; the sum of satisfying evaluations of B over three groups of needs <0;1,5>
  dissatisfying-A ; the sum of dissatisfying evaluations of A <0;1,5>
  dissatisfying-B ; the sum of dissatisfying evaluations of B over three groups of needs <0;1,5>

  dissonance-A ; the level of cognitive dissonance a behavioural alternative i (A) evokes in HUMAT j at time tn [Dij tn] <0;1>
  dissonance-B ; the level of cognitive dissonance a behavioural alternative i (B) evokes in HUMAT j at time tn [Dij tn] <0;1>
  dissonance-tolerance ; individual difference in tolerating dissonances before they evoke dissonance reduction strategies [Tj] normal trunc distribution with mean = 0.5, sd = 0.14 trunc to values <0;1>, this is the threshold determining if a reduction strategy is forgetting/distraction or if action has to be taken
  dissonance-strength-A ; individually perceived strength of cognitive dissonance a behavioural alternative i (A) evokes in HUMAT j at time tn [Fij tn]; F because it's a fraction of maximum dissonance HUMAT j can possibly experience <0;1>
  dissonance-strength-B ; individually perceived strength of cognitive dissonance a behavioural alternative i (B) evokes in HUMAT j at time tn [Fij tn]; F because it's a fraction of maximum dissonance HUMAT j can possibly experience <0;1>
  dissonance-strength ; individually perceived strength of cognitive dissonance a chosen behavioural alternative evokes in HUMAT j at time tn [Fij tn]; either dissonance-strenght-A or dissonance-strength-B, depending on chosen behavioural alternative

  ;variables only calculated for the chosen BA, not for all BAs;
  experiential-dilemma? ; the existence of an experiential dilemma e a chosen behavioural alternative i evokes in HUMAT j at time tn [Dije tn = {0,1}, where 0 donotes no dilemma and 1 denotes existence of dilemma]
  social-dilemma? ; the existence of an social dilemma s a chosen behavioural alternative i evokes in HUMAT j at time tn [Dije tn = {0,1}, where 0 donotes no dilemma and 1 denotes existence of dilemma]
  values-dilemma? ; the existence of an values dilemma v a chosen behavioural alternative i evokes in HUMAT j at time tn [Dije tn = {0,1}, where 0 donotes no dilemma and 1 denotes existence of dilemma]

;;;alter-representation variables;;;
  alter-representation-list
  inquiring-list
  signaling-list
  inquired-humat  ; the list belongs to ego and contains information about the alter who the ego inquires with
  inquiring-humat ; the list belongs to an inquired alter and contains information about the ego who is inquiring
  signaled-humat  ; the list belongs to ego and contains information about the alter who the ego signals to
  signaling-humat ; the list belongs to a signaled alter and contains information about the ego who is signaling

  inquiring? ; boolean positive [1] if the ego is inquiring at a given tick
  #inquiring ; the number of times humat inquired with alters
  #inquired  ; the number of times humat was inquired with by egos
  signaling? ; boolean positive [1] if the ego is signaling at a given tick
  #signaling ; the number of times humat signaled to alters
  #signaled  ; the number of times humat was signaled to

;;;;interaction record
  conn-freq ;the frequence of interaction between the humat and others
]

;;;;;;;;;;;;;;;;;;
;;; Procedures ;;;
;;;;;;;;;;;;;;;;;;

to reset
  clear-all
  reset-ticks
  resize-world 0 200 0 200

  ;import-pcolors filename
  ask patches [set pcolor white]
  ;import-drawing "Picture 2.png"  ;world map
  set group-number 1
  set num-removed 0
  set setup? false
end 


;;;;;;;;;;;;;;;;;;;;;;;;
;;; Create the community ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to add-agents
 ifelse (group-number - num-removed) > num-groups
   [ user-message word (group-number - 1) " groups have been created!"]
   [ make-HUMATS
     to-show-labels?
   ]
  set norm-influence 0
end 

to make-HUMATS
   random-seed 400  ;;300
   let color-face 0
   create-humats num-agents
    [
    ; set size 8 * (less-or-more-vocal + 1)
     set size 4 * (less-or-more-vocal + 2)
     set group-id group-number
     ;set label [who] of self
     set label group-id
     set label-color black
     set color-face [color] of self
     set dissonance-tolerance random-normal-trunc 0.5 0.14 0 1                  ;0.5 0.14 0 1
     set tendency-for-change random-normal-trunc against-or-for-change 0.14 0 1 ;0.14 0 1
     set vocie-being-heard random-normal-trunc less-or-more-vocal 0.14 0 1      ;0.14 0 1
     set ses 1 * vocie-being-heard
    ]
  output-print (word "GROUP " group-number ":" color-face)
  output-print word "num-agents = " num-agents
  output-print word "less-or-more-vocal ≈ " less-or-more-vocal
  output-print word "against-or-for-change ≈ " against-or-for-change
  output-print "+++++++++++++++++++++++++"

  set group-number group-number + 1
  set-noun-social-need
  set-intra-networks               ;;intra group links
  set-social-satisfactions

  ask humats with [group-id = group-number - 1] [
   evaluate-satisfaction-support   ;; evaluate the support and satisfaction
   setxy (support * 37 + random 50)  (100 * satisfaction)
  ]
end 

to to-show-labels?
  ask humats [
    ifelse show-labels?
       [
        set label group-id
        ;set label [who] of self
        set label-color black
       ]
       [set label ""]
   ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all-plots
  reset-ticks
  set setup? true
  ask influencers [die]
  set %enhancing-experiential-satisfation 0
  set %enhancing-value-satisfaction 0
  set num-authority 0
  set-default-shape influencers "star"
  random-seed 300  ;;300
  create-influencers num-authority [   ;create superspreaders
    setxy random-xcor (random-float (world-height - 1) / 4) + (world-height - 1) * 3 / 4
    set endorsement one-of (list "A" "B" )
    ifelse endorsement = "B"
      [set color green]
      [set color magenta]
    set size 10
    set influence [ycor] of self
  ]
  to-show-labels?
  set-inter-networks
  set-social-satisfactions
end 

;;;;;;;;;;;;;;;;;;;;;;;
;;; Social networks ;;;
;;;;;;;;;;;;;;;;;;;;;;;

to set-intra-networks                           ;; within the groups
  ask HUMATS with [group-id = group-number - 1] [
    let topological-neighbours other HUMATS with [group-id = group-number - 1]
    let #topological-neighbours count topological-neighbours

    create-connections-with n-of round (0.2 * #topological-neighbours) topological-neighbours
    if count connection-neighbors = 0
      [create-connection-with min-one-of other HUMATS [distance myself]]
     ]

  ask connections
    [set link-color 7
     set color link-color
     set thickness 0.01
     ]

  ifelse show-links?
    [ ask connections [set hidden? false]]
    [ ask connections [set hidden? true]]
end 

to set-inter-networks                            ;; between the groups
 ask HUMATS [
    let self-group-id group-id
    let topological-neighbours other HUMATS with [group-id != self-group-id]
    let #topological-neighbours count topological-neighbours

    create-connections-with n-of round (0.05 * #topological-neighbours) topological-neighbours
             [ set link-color 7
               set color link-color
               set thickness  0.01
               set shape "inter-groups"
              ]
    set conn-freq n-values count humats [0]      ;; set-up the list of connections of humat and other humats
    ]

  ask influencers [
    let topological-neighbours other HUMATS with [distance myself <= 150]
    let #topological-neighbours count topological-neighbours
    let link-color [color] of self + 3.5
    create-relations-to n-of (0.3 * #topological-neighbours) topological-neighbours
       [set color link-color
        set thickness  0.01]
    ]

  ifelse show-links?
    [ask relations [set hidden? false]
     ask connections [set hidden? false]
    ]
    [ask relations [set hidden? true]
     ask connections [set hidden? true]
    ]
end 

to update-networks
  ask humats[
    let my-connections-with-other-humats my-connections with [[other-end] of myself != nobody]
    let other-humats [other-end] of my-connections-with-other-humats
    set other-humats turtle-set other-humats    ;;should distinguish intra or inter-group links from here!!!
    let other-humats-ids sort [who] of other-humats
    let conn-freq-temp conn-freq

    let id1 [who] of self
    let groupID1 [group-id] of self
;    print "groupID1"
;    print groupID1
    let i 0
    while [ i < length other-humats-ids]
      [let id2 item i other-humats-ids
       let groupID2 [group-id] of (humat id2)
;        print "groupID2"
;        print groupID2
       ask connection id1 id2 [
       let greyscale item id2 conn-freq-temp

       let time-fading 0
       ifelse groupID1 = groupID2
          [set time-fading  time-voting * 0.8]
          [set time-fading  time-voting * 0.4]

       ifelse greyscale >= 0            ; existing interactions
          [
           set link-color 7 / e ^ (0.2 * greyscale)
           ]
          [
           ifelse greyscale > (- time-fading) ;(- time-for-vote * 0.8)
              [set link-color 3.9 / e ^ (0.2 * (greyscale + time-fading)) + 6]  ;link-color is 5, if no(greyscale = 0) interaction
              [set link-color 9.9
               set hidden? true
               ]
           ]

        set color link-color
        set thickness 0.05
        ]
       set i i + 1
       ]
     ]
end 

to update-humats
 if (ticks > 0) and (ticks mod 5 = 0) and (norm-influence <= 0.8)
    [set norm-influence precision (norm-influence + 0.05) 2]

 ask humats [
    set evaluations-list-A (list (experiential-evaluation-A) (values-evaluation-A))
    set evaluations-list-B (list (experiential-evaluation-B) (values-evaluation-B))

    set non-social-evaluation-A sum evaluations-list-A / 2  ;;non-social satisfaction for the support
    set non-social-evaluation-B sum evaluations-list-B / 2

    set conn-freq (map [x -> x - 1 ] conn-freq)             ;;update the overall connections-frequency
    ifelse norm-influence > 0
      [set social-importance random-normal-trunc norm-influence 0.14 0 1]    ;;;
      [set social-importance 0]

    evaluate-satisfaction-support
  ]
move-humats
end 

to move-humats
  ask humats [
     setxy (support * 37 + random 50)  (100 * satisfaction)
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Needs-and-satisfactions ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to set-noun-social-need
; in step 1, HUMATS set their initial behavior with the esclusion of social influence, i.e. on the basis their experiential and value satisfactions
  ask HUMATS with [group-id = group-number - 1][
  ; STEP 1
    ; set importances
    set experiential-importance random-normal-trunc 0.5 0.14 0 1
    set values-importance random-normal-trunc 0.5 0.14 0 1

    ifelse norm-influence > 0
      [set social-importance random-normal-trunc norm-influence 0.14 0 1]
      [set social-importance 0]

    ;either opposing or supporting
    let aver-vocal-change (less-or-more-vocal + 3 * against-or-for-change) / 4  ;against or for change can be more Decisive at the beginning
    let support-value normalized-min-max aver-vocal-change 0 1 -1 1


    ; A opposing the plan
    set experiential-satisfaction-A random-normal-trunc 0 0.5 -1 1
    set values-satisfaction-A random-normal-trunc 0 0.5 -1 1

    ; B supporting the plan
    set experiential-satisfaction-B random-normal-trunc (support-value + %enhancing-experiential-satisfation / 100) 0.50 -1 1
    set values-satisfaction-B random-normal-trunc (support-value + %enhancing-value-satisfaction / 100) 0.50 -1 1

    ; set evaluations = importances * satisfactions ; excluding social dimension
    ; A
    set experiential-evaluation-A experiential-importance * experiential-satisfaction-A
    set values-evaluation-A values-importance * values-satisfaction-A
    ; B
    set experiential-evaluation-B experiential-importance * experiential-satisfaction-B
    set values-evaluation-B values-importance * values-satisfaction-B

    set evaluations-list-A (list (experiential-evaluation-A) (values-evaluation-A))
    set evaluations-list-B (list (experiential-evaluation-B) (values-evaluation-B))

    ;;non-social satisfaction for the support
    set non-social-evaluation-A precision (sum evaluations-list-A / 2) 4  ;[-1,1]
    set non-social-evaluation-B precision (sum evaluations-list-B / 2) 4

    ;;people's behavior based on experiential need and value (initial opinion)
    ifelse non-social-evaluation-A < non-social-evaluation-B
      [ set behaviour "B" ]
      [ set behaviour "A"]
 ]
end 

to set-social-satisfactions
; in step 2, HUMATS add the social satisfaction to the calculation of satisfactions from various behavioural alternatives
  ask HUMATS [
    ; STEP 2 based on cognition, not on interaction (中文)
    ; create alter representation lists for each alter  ; to do:if behaviours unobservable - here add the guessing parameter
    set-alter-representations
    alter-similarity
    calculate-dissonance
    calculate-dilemmas
 ]
end 

to set-alter-representations
  ask HUMATS [
    set alter-representation-list []

    foreach sort connection-neighbors [x ->
      let working-list ( list
        [who] of x                              ;item 0 who
        0                                       ;item 1 inquired? 0 for not inquired with, 1 for inquired with already
        0                                       ;item 2 signaled? 0 for not signaled to, 1 for signaled to already
        [behaviour] of x                        ;item 3 behaviour ; to do: as known for observable and as guessed for non-observable behaviours
        same-BA? behaviour [behaviour] of x     ;item 4 1 for same behaviour; 0 for different behaviour ; used for inquiring
        ifelse-value (same-BA? behaviour [behaviour] of x  = 1) [0] [1] ; item 5  1 for different behaviour and 0 for same behaviour; used for signaling - coding is the other way around for the purpose of using the same reporter for sorting lists as in the case of inquiring
        0                                       ;item 6 [experiential-importance] of x
        0                                       ;item 7 [social-importance] of x
        0                                       ;item 8 [values-importance] of x
        0                                       ;item 9 [experiential-satisfaction-A] of x
        0                                       ;item 10 [social-satisfaction-A] of x
        0                                       ;item 11 [values-satisfaction-A] of x
        0                                       ;item 12 [experiential-satisfaction-B] of x
        0                                       ;item 13 [social-satisfaction-B] of x
        0                                       ;item 14 [values-satisfaction-B] of x
        0                                       ;item 15 similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego
        0                                       ;item 16 simiarity-A-values-importance
        0                                       ;item 17 similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego
        0                                       ;item 18 similarity-B-experiential-importance
        0                                       ;item 19 relative-aspiration-influenced-ego - relative social appeal/status (aspiration characteristic) in case of inquiring
        0                                       ;item 20 relative-aspiration-influenced-alter - relative social appeal/status (aspiration characteristic) in case of signaling
        0                                       ;item 21 inquiring-persuasion-A-experiential
        0                                       ;item 22 inquiring-persuasion-A-values
        0                                       ;item 23 inquiring-persuasion-B-experiential
        0                                       ;item 24 inquiring-persuasion-B-values
        0                                       ;item 25 signaling-persuasion-A-experiential
        0                                       ;item 26 signaling-persuasion-A-values
        0                                       ;item 27 signaling-persuasion-B-experiential
        0                                       ;item 28 signaling-persuasion-B-values
        0                                       ;item 29 inquiring-persusasion
        0                                       ;item 30 signaling-persuasion
      )
      set alter-representation-list lput working-list alter-representation-list
    ]

    ;inquiring-list sorted:
     ;(1) ascendingly by inquired? (not inquired with first), and
     ;(2) descendingly by same-BA? (same behaviour first),
     ;(3) descendingly by persuasion (strongest persuasion first)
    set inquiring-list sort-list alter-representation-list 1 4 29

    ;signaling-list sorted:
     ;(1) ascendingly by signaled? (not signaled to first), and
     ;(2) descendingly by not the same-BA? (different behaviour first).
    set signaling-list sort-list alter-representation-list 2 5 30

    set inquired-humat []
    set inquiring-humat []
    set signaled-humat []
    set signaling-humat []

  ]
end 

to update-dissonances
 ; each tick, all humats recalculate their social satisfactions and final satisfactions, and dissonances, not only the one that changed his mind
 ; update social satisfaction on the basis of alter-representation list;update social evaluation;update satisfaction from BAs
 ; update social dimension: social satisfaction from BAs, evaluations of BAs
   alter-similarity
   calculate-dissonance
   calculate-dilemmas
end 

to alter-similarity  ;;relates to social need
    ; go through alter-representation-list and count the alters, who behave similarily
    let #similar 0
    foreach alter-representation-list [x -> if item 4 x = 1 [set  #similar  #similar + 1]]

    ; go through alter-representation-list and count the alters, who behave dissimilarily
    let #dissimilar 0
    foreach alter-representation-list [x -> if item 5 x = 1 [set  #dissimilar  #dissimilar + 1]]

    let #alters count connection-neighbors
    let %similar #similar / #alters
    let %dissimilar #dissimilar / #alters

    ; set social dimension: social satisfaction from BAs, evaluations of BAs
    ifelse behaviour = "A"
    [
      set social-satisfaction-A normalized-min-max %similar 0 1 -1 1
      set social-satisfaction-B normalized-min-max %dissimilar 0 1 -1 1
    ]
    [
      set social-satisfaction-B normalized-min-max %similar 0 1 -1 1
      set social-satisfaction-A normalized-min-max %dissimilar 0 1 -1 1

    ]

    set social-evaluation-A social-importance * social-satisfaction-A
    set social-evaluation-B social-importance * social-satisfaction-B
    set evaluations-list-A (list (experiential-evaluation-A) (social-evaluation-A) (values-evaluation-A))
    set evaluations-list-B (list (experiential-evaluation-B) (social-evaluation-B) (values-evaluation-B))

    ; set final satisfactions from BAs at setup stage
    set evaluations-A precision (sum evaluations-list-A / 3) 4
    set evaluations-B precision (sum evaluations-list-B / 3) 4
    set satisfaction-A sum (list experiential-satisfaction-A social-satisfaction-A values-satisfaction-A) / 3
    set satisfaction-B sum (list experiential-satisfaction-B social-satisfaction-B values-satisfaction-B) / 3
end 

to calculate-dissonance
    set dissatisfying-A dissatisfying-status-BA evaluations-list-A
    set satisfying-A satisfying-status-BA evaluations-list-A
    set dissatisfying-B dissatisfying-status-BA evaluations-list-B
    set satisfying-B satisfying-status-BA evaluations-list-B

    set dissonance-A dissonance-status-A satisfying-A dissatisfying-A
    set dissonance-B dissonance-status-B satisfying-B dissatisfying-B

   ; calculating the need for dissonance reduction - a BA invokes the need to reduce dissonance if the level of dissonance for BA exceeds the dissonance-threshold
   set dissonance-strength-A (dissonance-A - dissonance-tolerance) / (1 - dissonance-tolerance)
    if dissonance-strength-A < 0
     [set dissonance-strength-A 0] ; if the dissonance level a behavioural alternative i (A) [Dij tn] does not exceed the individual tolerance threshold of HUMAT j [Tj], HUMAT j does not experience any dissonance: [Dij tn] < [Tj] -> [Fij tn] = 0
   set dissonance-strength-B  (dissonance-B - dissonance-tolerance) / (1 - dissonance-tolerance)
    if dissonance-strength-B < 0    ;the greater the dissonance, the more unsatisfied with the choice.
     [set dissonance-strength-B 0]  ;when dissonance approaches to 0 or smaller than the dissonance-tolerance, the more satisfied with the choice

   ; setting dissonance strength and colours
   ifelse behaviour = "A"  ;;example, opposing the plan
    [
     set dissonance-strength dissonance-strength-A
    ]
    [
     set dissonance-strength dissonance-strength-B
    ]
end 

to calculate-dilemmas
;;calculating dilemmas does not inlcude 0 (< / >), therefore the same situation cannot evoke two different dilemmas
   ifelse behaviour = "A"
    [
     if (experiential-evaluation-A > 0 and social-evaluation-A < 0 and values-evaluation-A < 0)  or
        (experiential-evaluation-A <= 0 and social-evaluation-A >= 0 and values-evaluation-A >= 0)
        [set experiential-dilemma? 1]
     if (social-evaluation-A > 0 and experiential-evaluation-A < 0 and values-evaluation-A < 0)  or
        (social-evaluation-A <= 0 and experiential-evaluation-A >= 0 and values-evaluation-A >= 0)
        [set social-dilemma? 1]
     if (values-evaluation-A > 0 and experiential-evaluation-A < 0 and social-evaluation-A < 0)  or
        (values-evaluation-A <= 0 and experiential-evaluation-A >= 0 and social-evaluation-A >= 0)
        [set values-dilemma? 1]
    ]
    [
     if (experiential-evaluation-B > 0 and social-evaluation-B < 0 and values-evaluation-B < 0)  or
        (experiential-evaluation-B <= 0 and social-evaluation-B >= 0 and values-evaluation-B >= 0)
        [set experiential-dilemma? 1]
     if (social-evaluation-B > 0 and experiential-evaluation-B < 0 and values-evaluation-B < 0)  or
        (social-evaluation-B <= 0 and experiential-evaluation-B >= 0 and values-evaluation-B >= 0)
        [set social-dilemma? 1]
     if (values-evaluation-B > 0 and experiential-evaluation-B < 0 and social-evaluation-B < 0)  or
        (values-evaluation-B <= 0 and experiential-evaluation-B >= 0 and social-evaluation-B >= 0)
        [set values-dilemma? 1]
    ]
end 

to evaluate-satisfaction-support
  ;initial opinon
 if num-authority = 0
   [ ifelse evaluations-A < evaluations-B   ;;people's behavior based on three need satisfaction
      [ set behaviour "B" ]
      [ set behaviour "A"]
    ]

  if ticks > 0
    [choose-action]

  let abs-satisfaction 0
  if behaviour = "A"
     [set color magenta
      set dissonance-strength dissonance-strength-A
      set support normalized-min-max non-social-evaluation-A -1 1 0 2
      set satisfaction normalized-min-max satisfaction-A -1 1 0 2
      set abs-satisfaction satisfaction-A
      ]

  if behaviour = "B"
     [set color green
      set dissonance-strength dissonance-strength-B
      set support normalized-min-max non-social-evaluation-B -1 1 2 4
      set satisfaction normalized-min-max satisfaction-B -1 1 0 2
      set abs-satisfaction satisfaction-B
      ]                                ;; eveluate if they support or resist the plan

   let smile word "smile " group-id
   let sad word "sad " group-id
   let neutral word "neutral " group-id
   set abs-satisfaction abs abs-satisfaction

  ifelse abs-satisfaction <= 0.02      ;; middle/moderate area;;;three types of face
     [set shape neutral]
     [ifelse satisfaction > 1          ;; nomalized satisfaction
       [set shape smile]
       [set shape sad ]
      ]
end 

to choose-action ; HUMAT-oriented
 ; The BA comparison dimensions include:
 ;* overall satisfaction - if similarly satisfying (+/- 0.2 = 10% of the theoretical satisfaction range <-1;1>), then
 ;* dissonance level - if similarily dissonant (+/- 0.1 = 10% of the theoretical dissonance range <0;1>), then
 ;* satisfaction on experiential need - if similarly satisfying on experiantial need (+/- 0.2 = 10% of the theoretical experiantial satisfaction range <-1;1>), then
 ;* random choice.
  random-seed 200
  ask HUMATS[
    let num-A 0  ;umber of humats who choose "open"
    let num-B 0  ;choose "close"
    ask connection-neighbors [
      ifelse behaviour = "A"
      [set num-A num-A + 1]
      [set num-B num-B + 1]
    ]

   let norm-test (random-float 1)
   let stubb-test (random-float 1)
   ifelse  norm-influence * 2 > norm-test  ;;norm-influence is more dominant
   [ifelse num-A <=  num-B
      [set behaviour "B"]
      [set behaviour "A"]
    ]
   [ifelse tendency-for-change  <=  stubb-test
      [choose-habit
      ]
      [ifelse further-comparison-needed? evaluations-A evaluations-B 2
        [compare-dissonances]
        [ifelse evaluations-A < evaluations-B
          [set behaviour "B"]   ; make color a reporter and set color to reporter
          [set behaviour "A"]
         ]
       ]
     ]
  ]
end 

to compare-dissonances   ; HUMAT-oriented
  (ifelse further-comparison-needed? dissonance-A dissonance-B 1
    [compare-experiential-needs]
    [ifelse dissonance-A > dissonance-B
     [set behaviour "A"] ; make color a reporter and set color to reporter
     [set behaviour "B"]
    ]
  )
end 

to compare-experiential-needs ; HUMAT-oriented
  (ifelse further-comparison-needed?  experiential-satisfaction-A  experiential-satisfaction-B 0.001  ; original 2
    [choose-randomly]
    [ifelse  experiential-satisfaction-A > experiential-satisfaction-B
     [set behaviour "A"]      ; make color a reporter and set color to reporter
     [set behaviour "B"]]
  )
end 

to choose-randomly
   set behaviour one-of (list "A" "B")
end 

to choose-habit ; in such situation humat stays with the previous behaviour (habit formation)
   set behaviour behaviour ;"A"  ;; A represents opposing the plan
end 

;;;;;;;;;;;;;;;;;;;;;;;
;;; Go Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;

to go
ifelse not setup?
  [ user-message " SETUP-COMMUNITY at First!"]
[every 0.2  ;set the speed of running
  [
  if ticks >= time-voting [ stop ]  ;100000; time for implementing the plan
  inquire
  signal
  if num-authority > 0
    [follow-authority]
  update-humats
  eveluation
  tick
  ]
  ]
end 

to inquire
  ;here conceptualising dissonance reduction strategies depending on dilemmas a HUMAT is experiencing
  ;during inquiring information flows uni-directionally from the alter, who was giving advice to the ego, who was asking for advice
  ;activating dissonance reduction strategies - this is pre-action dissonance reduction; post action dissonnace reduction is when the action is taken
  ;- in Groningen case this is a longer process of making up your mind before the vote; its after the vote when post-action dissonance reduction will have to take place if the vote did not go your way
; INQUIRING
  ;inquire strategy - seek information in social network to reduce cognitive dissonance via altering EGO’s knowledge structures
  ;update ego's representation of the inquired alter
  ask humats [
   set inquiring? 0
   if dissonance-strength > 0 and (values-dilemma? = 1 or experiential-dilemma? = 1)  [
    set inquiring? 1
    set #inquiring #inquiring + inquiring?
    set inquired-humat item 0 inquiring-list
    set inquired-humat replace-item 1 inquired-humat 1
    set inquired-humat replace-item 6 inquired-humat [experiential-importance] of humat item 0 inquired-humat
    set inquired-humat replace-item 7 inquired-humat [social-importance] of humat item 0 inquired-humat
    set inquired-humat replace-item 8 inquired-humat [values-importance] of humat item 0 inquired-humat
    set inquired-humat replace-item 9 inquired-humat [experiential-satisfaction-A] of humat item 0 inquired-humat
    set inquired-humat replace-item 10 inquired-humat [social-satisfaction-A] of humat item 0 inquired-humat
    set inquired-humat replace-item 11 inquired-humat [values-satisfaction-A] of humat item 0 inquired-humat
    set inquired-humat replace-item 12 inquired-humat [experiential-satisfaction-B] of humat item 0 inquired-humat
    set inquired-humat replace-item 13 inquired-humat [social-satisfaction-B] of humat item 0 inquired-humat
    set inquired-humat replace-item 14 inquired-humat [values-satisfaction-B] of humat item 0 inquired-humat

    ; need-similarity is symmetric - if ego influences alter to the degree of 40% (max), alter also influences ego to the degree of 40%
    set inquired-humat replace-item 15 inquired-humat need-similarity experiential-evaluation-A [experiential-evaluation-A] of humat item 0 inquired-humat experiential-importance [experiential-importance] of humat item 0 inquired-humat ;similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego[experiential-satisfaction-A] of humat item 0 inquired-humat
    set inquired-humat replace-item 16 inquired-humat need-similarity values-evaluation-A [values-evaluation-A] of humat item 0 inquired-humat values-importance [values-importance] of humat item 0 inquired-humat
    set inquired-humat replace-item 17 inquired-humat need-similarity experiential-evaluation-B [experiential-evaluation-B] of humat item 0 inquired-humat experiential-importance [experiential-importance] of humat item 0 inquired-humat ;similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego
    set inquired-humat replace-item 18 inquired-humat need-similarity values-evaluation-B [values-evaluation-B] of humat item 0 inquired-humat values-importance [values-importance] of humat item 0 inquired-humat                                       ;similarity-B-experiential-importance

    ; relative-aspiration is not symmetric
    set inquired-humat replace-item 19 inquired-humat relative-aspiration ses [ses] of humat item 0 inquired-humat         ; relative social appeal/status (aspiration characteristic) in case of inquiring


    ; persuasion is a multiplication of need-similatiry and relative-aspiration, and is not symmetric (different values for inquiring and signaling)
    set inquired-humat replace-item 21 inquired-humat (item 15 inquired-humat * item 19 inquired-humat) ; inquiring-persuasion-experiential-A = relative social appeal/status * similarity-A-experiential (similarity of needs activated by a BA)
    set inquired-humat replace-item 22 inquired-humat (item 16 inquired-humat * item 19 inquired-humat) ; inquiring-persuasion-values-A
    set inquired-humat replace-item 23 inquired-humat (item 17 inquired-humat * item 19 inquired-humat) ; inquiring-persuasion-experiential-B
    set inquired-humat replace-item 24 inquired-humat (item 18 inquired-humat * item 19 inquired-humat) ; inquiring-persuasion-values-B

    set inquired-humat replace-item 29 inquired-humat (item 21 inquired-humat + item 22 inquired-humat + item 23 inquired-humat + item 24 inquired-humat) ; inquiring persuasion = sum of inquiring persuasions
    ; here not seting the signaling persuasion, not to disturb the sorting process artificially by choosing the alter already inquired with for signaling, without going through the entire list of alters
    ; to do: describe the effect this has on the dynamics?  this is to do with sorting and the 3rd prio - it has to stay 0 for the ego to go through the entire list of alters before going for the most persuasive one over and over again

    ;update satisfactions
    set experiential-satisfaction-A new-need-satisfaction-inquiring experiential-satisfaction-A 21 9  ; 不被劝服*ego's satisfaction+劝服*alter's satisfaction
    set values-satisfaction-A new-need-satisfaction-inquiring values-satisfaction-A 22 11
    set experiential-satisfaction-B new-need-satisfaction-inquiring experiential-satisfaction-B 23 12
    set values-satisfaction-B new-need-satisfaction-inquiring values-satisfaction-B 24 14

    ; to do: for non-observable behaviours, set item 3 , item 4 and item 5 to the actual behaviour, not to a guessed one
    update-experiential-and-values-evaluations
    update-dissonances

    ;update the interaction frequency among humats,交互主体与客体之间的连接
    set conn-freq replace-item (item 0 inquired-humat) conn-freq ((item (item 0 inquired-humat) conn-freq) + 2)  ;交互双方+2
    ; update alter's representation of the inquiring ego
    ; please note that alter's representation of the inquiring ego is only updated to the extent of the ego's new decision about the BA (items 3,4,5)
    ask humat item 0 inquired-humat [
     foreach alter-representation-list
        [ x ->
          if item 0 x = [who] of myself
          [set inquiring-humat item position x alter-representation-list alter-representation-list]
         ]
     set inquiring-humat replace-item 3 inquiring-humat [behaviour] of myself
     set inquiring-humat replace-item 4 inquiring-humat same-BA? behaviour [behaviour] of myself
     set inquiring-humat replace-item 5 inquiring-humat ifelse-value (same-BA? behaviour [behaviour] of myself  = 1) [0] [1]

     foreach alter-representation-list
        [ x ->
          if item 0 x = [who] of myself
          [set alter-representation-list replace-item position x alter-representation-list alter-representation-list inquiring-humat]
         ]
     set inquiring-humat[]
     set #inquired #inquired + 1

     ;update the interaction frequency among humats, 更新交互客体与主体之间的连接
     set conn-freq replace-item ([who] of myself) conn-freq ((item ([who] of myself) conn-freq) + 2)

     update-dissonances
     update-networks
    ]

    ;update inquiring-list
    set inquiring-list replace-item 0 inquiring-list inquired-humat

    ;update alter-representation-list by replacing the old representation (of alter the ego inquired with) with a new representation that has accurate knowledge about alters action, motives and status of alteady having been inquired with
    foreach alter-representation-list
      [x ->
        if item 0 x = item 0 item 0 inquiring-list
        [set alter-representation-list replace-item position x alter-representation-list alter-representation-list item 0 inquiring-list]
       ]

    ; inquiring-list sorted:
     ;(1) ascendingly by inquired? (not inquired with first), and
     ;(2) descendingly by same-BA? (same behaviour first).
    set inquiring-list sort-list alter-representation-list 1 4 29
    set inquired-humat []
      ;ask alter [set inquiring-humat []]
    ]
  ]
end 

to signal
; SIGNALING
  ;signaling strategy - seek information in social network to reduce cognitive dissonance via altering ALTER’s knowledge structures
  ;during signaling information flows uni-directionally from the ego, who was giving advice to the alter, who was made to listed
  ;signaled-humat - the list belongs to ego and contains information about the alter who the ego signals to
  ;signaling-humat - the list belongs to a signaled alter and contains information about the ego who is signaling

 ask humats [
   set signaling? 0
   if dissonance-strength > 0 and social-dilemma? = 1  [
     set signaled-humat item 0 signaling-list ;ego's representation of an alter as a temporary list

     ;update alter's representation of ego
     ask humat item 0 signaled-humat [
        set #signaled #signaled + 1
        foreach alter-representation-list
        [ x ->
          if item 0 x = [who] of myself
          [set signaling-humat item position x alter-representation-list alter-representation-list]
         ]
        set signaling-humat replace-item 3  signaling-humat [behaviour] of myself
        set signaling-humat replace-item 4  signaling-humat same-BA? behaviour [behaviour] of myself
        set signaling-humat replace-item 5  signaling-humat ifelse-value (same-BA? behaviour [behaviour] of myself  = 1) [0] [1]
        set signaling-humat replace-item 6  signaling-humat [experiential-importance] of myself
        set signaling-humat replace-item 7  signaling-humat [social-importance] of myself
        set signaling-humat replace-item 8  signaling-humat [values-importance] of myself
        set signaling-humat replace-item 9  signaling-humat [experiential-satisfaction-A] of myself
        set signaling-humat replace-item 10 signaling-humat [social-satisfaction-A] of myself
        set signaling-humat replace-item 11 signaling-humat [values-satisfaction-A] of myself
        set signaling-humat replace-item 12 signaling-humat [experiential-satisfaction-B] of myself
        set signaling-humat replace-item 13 signaling-humat [social-satisfaction-B] of myself
        set signaling-humat replace-item 14 signaling-humat [values-satisfaction-B] of myself

        ; need similarity (same values for inquiring and signaling)
        set signaling-humat replace-item 15 signaling-humat need-similarity experiential-evaluation-A [experiential-evaluation-A] of myself experiential-importance [experiential-importance] of myself ;similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego[experiential-satisfaction-A] of humat item 0 signaled-humat
        set signaling-humat replace-item 16 signaling-humat need-similarity values-evaluation-A [values-evaluation-A] of myself values-importance [values-importance] of myself
        set signaling-humat replace-item 17 signaling-humat need-similarity experiential-evaluation-B [experiential-evaluation-B] of myself experiential-importance [experiential-importance] of myself ;similarity-A-experiential-importance - similarity between he importance of needs; only > 0 if the given BA satisfies that group of needs in a similar direction for the alter and for the ego
        set signaling-humat replace-item 18 signaling-humat need-similarity values-evaluation-B [values-evaluation-B] of myself values-importance [values-importance] of myself                             ;similarity-B-experiential-importance

        ; relative aspiration is not symmetric (different values for inquiring and signaling)
        set signaling-humat replace-item 20 signaling-humat relative-aspiration [ses] of myself ses         ; relative social appeal/status (aspiration characteristic) in case of signaling

        ; persuasion is a multiplication of need-similatiry and relative-aspiration, and is not symmetric (needs different values for inquiring and signaling)
        set signaling-humat replace-item 25 signaling-humat (item 15 signaling-humat * item 20 signaling-humat) ; signaling-persuasion-experiential-A = relative social appeal/status * similarity-A-experiential (similarity of needs activated by a BA)
        set signaling-humat replace-item 26 signaling-humat (item 16 signaling-humat * item 20 signaling-humat) ; signaling-persuasion-values-A
        set signaling-humat replace-item 27 signaling-humat (item 17 signaling-humat * item 20 signaling-humat) ; signaling-persuasion-experiential-B
        set signaling-humat replace-item 28 signaling-humat (item 18 signaling-humat * item 20 signaling-humat) ; signaling-persuasion-values-B

        ; seting new experiential and values satisfaction
        set experiential-satisfaction-A new-need-satisfaction-signaling experiential-satisfaction-A 25
        set values-satisfaction-A new-need-satisfaction-signaling values-satisfaction-A 26
        set experiential-satisfaction-B new-need-satisfaction-signaling experiential-satisfaction-B 27
        set values-satisfaction-B new-need-satisfaction-signaling values-satisfaction-B 28

        ; update alter's representation of the inquiring ego
        ; long-term memory - please note that alter's representation of the signaling ego only influences the update on social satisfaction, storing information other than about the BA (items 3, 4 aand 5) does not influence anything
        foreach alter-representation-list
          [x ->
            if item 0 x = [who] of myself
            [set alter-representation-list replace-item position x alter-representation-list alter-representation-list signaling-humat]
           ]

    ;update the interaction frequency among humats
    set conn-freq replace-item ([who] of myself) conn-freq ((item ([who] of myself) conn-freq) + 2)

 ; to do: sort the names and updating dissonances
        update-experiential-and-values-evaluations
        update-dissonances
      ]

    ;update the interaction frequency among humats
    set conn-freq replace-item (item 0 signaled-humat) conn-freq ((item (item 0 signaled-humat) conn-freq) + 2)

    ; update ego's representation of the signaled alter
    ; please note that alter's representation of the signaled alter is only updated to the extent of the alter's new decision about the BA (items 3,4,5)
    set signaled-humat replace-item  2 signaled-humat 1 ;representing the fact that alter was signaled to
    set signaled-humat replace-item  3 signaled-humat [behaviour] of humat item 0 signaled-humat
    set signaled-humat replace-item  4 signaled-humat same-BA? behaviour [behaviour] of humat item 0 signaled-humat
    set signaled-humat replace-item  5 signaled-humat ifelse-value (same-BA? behaviour [behaviour] of humat item 0 signaled-humat = 1) [0] [1]
    set signaled-humat replace-item 30 signaled-humat (item 25 [signaling-humat] of humat item 0 signaled-humat + item 26 [signaling-humat] of humat item 0 signaled-humat + item 27 [signaling-humat] of humat item 0 signaled-humat + item 28 [signaling-humat] of humat item 0 signaled-humat) ; gullibility (the willingness to be persuaded by the ego) of the alter is stores as the ego representation and is used later for sorting the signaling-list

    ask humat item 0 signaled-humat [
         set signaling-humat []
      ]

    ; update signaling-list
    set signaling-list replace-item 0 signaling-list signaled-humat

    ;update alter-representation-list by replacing the old representation (of alter the ego signaled to) with a new representation that has accurate knowledge about alters action and status of alteady having been signaled to
    foreach alter-representation-list
      [x ->
        if item 0 x = item 0 item 0 signaling-list
        [set alter-representation-list replace-item position x alter-representation-list alter-representation-list item 0 signaling-list]
       ]

    ; signaling-list sorted:
     ; (1) ascendingly by signaled? (not signaled to first),
     ; (2) descendingly by not the same-BA? (different behaviour first), and
     ; (3) descendingly by gullibility (the most easily persuaded first; sum of aspiration*similarity over experiential and values for both BAs; please note that ego will signal to all alters in its social network and then will focus on the most easily persuaded until that one changes its mind)
    set signaling-list sort-list alter-representation-list 2 5 30
    set signaled-humat []
    set signaling? 1
    set #signaling #signaling + 1
    update-dissonances
    update-networks
    ]
  ]
end 

to follow-authority
  ;;the possibility of humats following the authority's endorsement
  ask humats [
     let num-influencer count relation-neighbors
     let influence-test (random 10)
     let idol 0
     ifelse num-influencer > 1
      [ let max-influence 0
        let influence-list []
        ask relation-neighbors [
           set influence-list lput influence influence-list
        ]
        set max-influence max influence-list
        set idol influencers with [influence = max-influence]
        if max-influence * 10 > influence-test
          [set behaviour [endorsement] of idol]
       ]
      [ let influence-temp 0
        ask relation-neighbors [ set influence-temp influence]
        set idol relation-neighbors
        if influence-temp * 10 > influence-test
         [set behaviour [endorsement] of idol
         ]
       ]
    set behaviour item 0 behaviour
   ]
end 

to update-experiential-and-values-evaluations
  ; update evaluations = importances * satisfactions ; excluding social dimension
  ; A
  set experiential-evaluation-A experiential-importance * experiential-satisfaction-A
  set values-evaluation-A values-importance * values-satisfaction-A
  ; B
  set experiential-evaluation-B experiential-importance * experiential-satisfaction-B
  set values-evaluation-B values-importance * values-satisfaction-B
end 

to-report random-normal-trunc [mid dev mmin mmax]
  ; creating a trunc normal function to be used for tuncating the normal distribution between mmin and mmax values
  ; good for now, but the goeal would be to get to the normal from beta (using gamma as a start)
  ;random-seed 110
  let result random-normal mid dev
  if result < mmin or result > mmax
  [report random-normal-trunc mid dev mmin mmax]
  report result
end 

to-report random-trunc [randfloat mmin mmax]
  let result random-float randfloat * (1 / (0.14 * sqrt (2 * pi)))
  if result < mmin or result > mmax
  [report 1]
  report result
end 

to-report normalized-min-max [norm-variable min-old max-old min-new max-new]
  let norm min-new + (((norm-variable - min-old) * (max-new - min-new)) / (max-old - min-old))
  report precision norm 4
end 

; dissatisfying-status-BA and satisfying-status-BA should be merged into one reposrting procedure, however it seems that operators cannot be inputs in reporting procedures

to-report dissatisfying-status-BA [evaluations-list-BA]
 let dissatisfying-list-BA filter [i -> i < 0] evaluations-list-BA
 let dissatisfying-stat-BA abs sum dissatisfying-list-BA
 report dissatisfying-stat-BA
end 

to-report satisfying-status-BA [evaluations-list-BA]
 let satisfying-list-BA filter [i -> i > 0] evaluations-list-BA
 let satisfying-stat-BA abs sum satisfying-list-BA
 report satisfying-stat-BA
end 

to-report dissonance-status-A [sat-A dis-A] ; sat-A is satisfying-A and dis-A is dissatisfying-A
  let dissonant-A min (list sat-A dis-A)
  let consonant-A max (list sat-A dis-A) ; in case of the same values, it does not matter
  let dissonance-of-A (2 * dissonant-A)/(dissonant-A + consonant-A)
  report dissonance-of-A
end 

to-report dissonance-status-B [sat-B dis-B] ; sat-B is satisfying-B and dis-B is dissatisfying-B
  let dissonant-B min (list sat-B dis-B)
  let consonant-B max (list sat-B dis-B) ; in case of the same values, it does not matter
  let dissonance-of-B (2 * dissonant-B)/(dissonant-B + consonant-B)
  report dissonance-of-B
end 

to-report shading [dissonance-str]
 let shade normalized-min-max (-1 * dissonance-str) -1 0 -5 0
 report shade
end 

to-report further-comparison-needed? [comparison-dimension-A comparison-dimension-B theoretical-range]
  let value 0
  ifelse (comparison-dimension-A > comparison-dimension-B - 0.1 * theoretical-range )
      and (comparison-dimension-A < comparison-dimension-B + 0.1 * theoretical-range )
  [set value true]
  [set value false]
  report value
end 

to-report relative-aspiration [aspiration-influencing aspiration-influenced] ; produces values <0 ; 1 > - weighing of the influenced agent's status
  ; for inquiring the influencing agent is the alter, who is influencing the ego
  ; for signlaing the influencing agent is the ego, who is influencing the alter
  let rel-aspiration 0.4 + aspiration-influencing - aspiration-influenced
  if 0.4 + aspiration-influencing - aspiration-influenced > 1 [set rel-aspiration 1]
  if 0.4 + aspiration-influencing - aspiration-influenced < 0 [set rel-aspiration 0]
  report precision rel-aspiration 3
end 

; to do: relative-ses-signaling [ego-ses alter-ses] ;still???

to-report same-BA? [ego-val alter-val]
  ifelse ego-val = alter-val
  [report 1] ; 1 is the same BA
  [report 0] ; 0 is different BA
end 

;to do: add presuasion to sorting

to-report sort-list [the-list prio-1 prio-2 prio-3] ; the same sorting reporter for inquiring and signaling lists, just used with different priority characteristics
  ; the-list = the nested list you want to sort ; prio-1 = the first prio characteristic; prio-2 = the second prio characteristic; prio-3 - the third prio characteristic
  ; the ego inquires with alters who
  ;a) have not been inquired with yet
  ;b) choose the same behaviour and
  ;c) are the most persuasive (sum of aspiration*similarity over experiential and values for both BAs;
  ;please note that the most persuasive only plays part once ego inquired with all alters in its social network)
  ; the ego signals to alters who a) have not been signaled to yet b) choose a different behaviour
  let sorted sort-by [[?1 ?2] -> item prio-3 ?1 > item prio-3 ?2] the-list
  set sorted sort-by [[?1 ?2] -> item prio-2 ?1 > item prio-2 ?2] sorted
  set sorted sort-by [[?1 ?2] -> item prio-1 ?1 < item prio-1 ?2] sorted
  report sorted
end 

to-report need-similarity [need-evaluation-BA-ego need-evaluation-BA-alter need-importance-ego need-importance-alter] ; weighing of alter's similarity of needs, applicable to each group of needs for each BA
  ; can take a max value of 0,4 - if two agents value the same needs to the same extent, the influencing agent affects the influenced agent to a max degree of 40% (new value is 60% inflenced agent's and 40% influencing agent).
  ; if two agents don't find the same needs important, the influencing agent does not affect the influenced agent
  ifelse
  (need-evaluation-BA-ego > 0 and need-evaluation-BA-alter > 0) or
  (need-evaluation-BA-ego < 0 and need-evaluation-BA-alter < 0)
  [report 0.4 * (1 - abs(need-importance-ego - need-importance-alter))]
  [report 0]
end 

to-report new-need-satisfaction-inquiring [need-satisfaction-BA #item #item2]
  ; the #item refers to the number of item on the list, which designates inquiring persuasion for each need-satisfaction-BA
  ; the #item2 refers to the number of item on the list, which designates need-satisfaction-BA of alter
  ; when humats are persuaded by other humats in their social networks, they change their satisfactions of needs for BAs to the extent that the alter is persuasive (status * similar of needs importances for the BA)
  ; reports a new value of needs satisfaction for a persuaded HUMAT
  ; done for experiential needs and values of both BAs
  let val (1 - item #item inquired-humat) * need-satisfaction-BA + item #item inquired-humat * item #item2 inquired-humat
  report val
end 

; to do: whis is to take into account that signaled-humat is the convincing's humat list and here it assumes to be the convinced's humat list - to change

to-report new-need-satisfaction-signaling [need-satisfaction-BA #item]
  ; the #item refers to the number of item on the list, which designates signaling persuasion for each need-satisfaction-BA
  ; when humats are persuaded by other humats in their social networks, they change their satisfactions of needs for BAs to the extent that the alter is persuasive (status * similar of needs importances for the BA)
  ; reports a new value of needs satisfaction for a persuaded HUMAT
  ; done for experiential needs and values of both BAs
  report (1 - item #item signaling-humat) * need-satisfaction-BA + item #item signaling-humat * [need-satisfaction-BA] of myself
end 

to-report ns [need-satisfaction-BA]
  ;let ns-ego need-satisfaction-BA
  let ns-alter [need-satisfaction-BA] of humat item 0 inquired-humat
  ;let it item #item inquired-humat
  ;report ns-ego
  report ns-alter
  ;report it
end 

to-report consistency             ;clustering, to gauge the consistency between the humat and their neighbors
  let act-behaviour 0
  let nr-same 0
  let nr-neighbors 0
  ask humats [
    set act-behaviour behaviour
    ask connection-neighbors [
      set nr-neighbors nr-neighbors + 1
      if behaviour = act-behaviour
      [set nr-same nr-same + 1]
    ]
  ]
ifelse nr-neighbors = 0
  [report 0]
  [report precision (nr-same / nr-neighbors) 2]
end 

to eveluation
  let list-experiential-A []
  let list-social-A []
  let list-values-A []
  let list-experiential-B []
  let list-social-B []
  let list-values-B []
  let A-supporters-temp 0
  let B-supporters-temp 0

  ask humats [
    set list-experiential-A lput experiential-satisfaction-A list-experiential-A
    set list-social-A lput social-satisfaction-A list-social-A
    set list-values-A lput values-satisfaction-A list-values-A
    set list-experiential-B lput experiential-satisfaction-B list-experiential-B
    set list-social-B lput social-satisfaction-B list-social-B
    set list-values-B lput values-satisfaction-B list-values-B

    set non-social-importance (experiential-importance + values-importance) / 2
    ifelse behaviour = "A"
     [set A-supporters-temp A-supporters-temp + 1]
     [set B-supporters-temp B-supporters-temp + 1]
  ]
  set A-supporters  A-supporters-temp
  set B-supporters  B-supporters-temp
  set A-value+ count humats with [behaviour = "A" and satisfaction-A > 0.02]
  set A-value- count humats with [behaviour = "A" and satisfaction-A < -0.02]
  set A-value count humats with [behaviour = "A" and satisfaction-A <= 0.02 and satisfaction-A >= -0.02]

  set B-value+ count humats with [behaviour = "B" and satisfaction-B > 0.02]
  set B-value- count humats with [behaviour = "B" and satisfaction-B < 0.02]
  set B-value count humats with [behaviour = "B" and satisfaction-B <= 0.02 and satisfaction-B >= -0.02]
end 

There is only one version of this model, created 4 months ago by Shaoni Wang.

Attached files

File Type Description Last updated
Dialogue tool of the INCITE-DEM.png preview Preview for 'Dialogue tool of the INCITE-DEM' 4 months ago, by Shaoni Wang Download

This model does not have any ancestors.

This model does not have any descendants.