WaningMirrorTeamReflexivity

WaningMirrorTeamReflexivity preview image

1 collaborator

Patarakin_m Evgeny Patarakin (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 268 times • Downloaded 16 times • Run 0 times
Download the 'WaningMirrorTeamReflexivity' 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

extensions [nw csv]

directed-link-breed  [bonds bond] ; создание
patches-own [pagenum]

breed [users user]

users-own [
agentname
  t-pagenum
   community-n ;;
  degree
  in-degree
  out-degree
  betweenness
  eigenvector
  closeness
  clustering
  page-rank
  community
  phi
  visits
  rank
  new-rank
  infected
  typ
]

links-own [weight]

globals [
   diameter ;
  wikihistory ;
  wikilog ;
  pages ;; перечень созданных страниц
  communities-n ;; перечень сообществ
  Mdl ; модулярность текущего сообщества


  ]


;;; Очистили,  закрыли и обнулили все,

to setup
clear-all ;
file-close;
 ;;  set-default-shape users "person" ;
    set-default-shape users "circle" ;
   set-default-shape bonds "default" ;
  set wikihistory [] ;
  set wikilog [] ;
  set pages [] ;
end 

to wood
  ask patches

  [ set pagenum 0  if random-float 100 < Chipsdensity [ set pcolor yellow ]    ]



  create-users TNumber [ set color white setxy random-xcor random-ycor set size 2 set agentname who

  ]
end 

to go

  if length wikilog > Turns [stop] ;; ограничитель числа ходов
  search-for-chip
  find-new-pile
  put-down-chip
end 

to search-for-chip  ;; turtle procedure -- "picks up chip" by turning orange
  ifelse pcolor = yellow [
    ;; Если это палочка, которую не брали, то надо записать в журнал, что я создал эту новую палочку
     ifelse 0 = [pagenum] of patch-here [
       let newpage 1 + length pages set pages lput newpage pages
       set t-pagenum newpage ;; это номер палочки, которую создал
            set wikilog lput (se [who] of self newpage "create" ) wikilog
       ]
     [set t-pagenum [pagenum] of patch-here ;; а если палочка, которую уже кто-то создал, то я записал себе номер этой палочки
       ]
    ;;
    set pcolor black  set color orange  fd 20 ] ;; взял палочку, и с этой палочкой пошел
  [ wiggle     search-for-chip ]  ;; а если ты не нашел, то продолжай поиск
end 

to find-new-pile  ;; turtle procedure -- look for yellow patches
  ;; это он ищет новую палочку, как только найдет - остановится и запустится put-down-chip
  if pcolor != yellow
  [ wiggle find-new-pile ]
end 

to put-down-chip  ;; turtle procedure -- finds empty spot & drops chip
  ;;; смотри - вот я нашел место, где могу положить палочку - я сюда положил палочку и ушел.
  ;; И записал в журнале, что я палочку положил
  ifelse pcolor = black   ;; в первой проверке это не так, потому что я только что нашел новую палочку, я теперь покручусь вокруг, найду новое пустое место и там палочку положу
  [
    ;; Передаю пятну номер статьи, которая тут теперь лежит

    ask patch-here [set pagenum [t-pagenum] of myself]
   set wikilog lput (se [who] of self [t-pagenum] of self "edit" ) wikilog
  ;;
    set pcolor yellow
    set color white
    set t-pagenum 0
    get-away ]
  [ rt random 360
    fd 1
    put-down-chip ]
end 

to get-away  ;; turtle procedure -- escape from yellow piles
  rt random 360
  fd 20
  if pcolor != black
    [ get-away ]
end 

to wiggle ; turtle procedure
  fd 1
  rt random 50
  lt random 50
end 

to load_file
   file-open user-file
           while [ not file-at-end? ]     [
         let newline  csv:from-row file-read-line
    if not member? newline  wikihistory  [set wikihistory  lput newline wikihistory]
            ]
             file-close
foreach wikihistory [ [?1] ->
    let username item 0 ?1
    let pagename item 1 ?1
    if count users with [agentname = username] = 0 [create-ordered-users 1 [set agentname username] ] ;;; Может быть и список агентов вести
    let who_user [who] of one-of users with [agentname = username] ;
        ifelse not member? pagename pages
    [ set pages lput pagename pages
      set wikilog lput (list  who_user pagename "create") wikilog ]
    [set wikilog  lput (list  who_user pagename "edit") wikilog  ]
  ]
end 

to logs_to_sociogram
ask patches [set pcolor 0]
  ;; пока связи идут только от редакторов к автору статьи
  foreach edits [ [?1] ->
    let friend1 item 0 ?1
    let p1 item 1 ?1
    let friend2 first first filter [ [??1] -> (p1 = item 1 ??1) and ("create" = item 2 ??1) ] wikilog
    if friend1 != friend2 [
    ask turtle friend1 [ create-bond-to turtle friend2 ]
    ]

    ]

  repeat 8 [layout-spring  turtles links 1 5 7 ]
end 

to-report edits
report filter [ [?1] -> "edit" = item 2 ?1 ] wikilog
end 




;;;   Нормированная центральности

to-report norm-betweenness
;;  if count turtles > 4 [
    report nw:betweenness-centrality /  ((count turtles - 1) *  (count turtles - 2) / 2 )
;;]
;;  report 0
end 

to-report centralization-btw
 let znm ((count turtles - 1) * (count turtles - 1) *  (count turtles - 2)) / 2 ;
 let mx  max [nw:betweenness-centrality] of turtles ;
report (sum map [ ?1 -> mx - ?1 ] [nw:betweenness-centrality] of turtles ) / znm
end 


;; Посмотреть тех, у кого максимальная центральность

to see_Btw
  ask turtles [ht]
 ;; ask links [hide-link]
 foreach sublist reverse sort-on [norm-betweenness] users 0 9
 [ ?1 -> ask ?1 [st set size 2 set label-color red set label norm-betweenness ] ]
end 


;;; Посмотреть на 1 максимальную клику
;; Только для ненаправленного графа

to see_Bcliq
  ask turtles [ht]
  ask links [hide-link]
 let BigCliq one-of nw:biggest-maximal-cliques

  ask BigCliq [st]
  let BigCliqLinks links with [(member? end1 BigCliq) and  (member? end2 BigCliq) ]
  ask BigCliqLinks [show-link]
layout-spring  BigCliq BigCliqLinks 1 10 1
end 

;;; Это мы извлекаем из графа отдельные группировки и на них смотрим

to see_Mcliq
  ask turtles [ht]
  ask links [hide-link]
   foreach nw:maximal-cliques [ ?1 -> if  (count ?1) > 12
      [
  let BigCliq ?1
    let BigCliqLinks links with [(member? end1 BigCliq) and  (member? end2 BigCliq) ]
      ask BigCliq [st set size 1.2]
       ask BigCliqLinks [show-link]
       layout-circle BigCliq  20

       ] ]
      layout-circle users with [hidden? = false]  20
end 


 ;; Региональные группы

to see_Group [CL]
 ;; show CL
  ask turtles [ht]
  ask links [hide-link]
  let NewGroup users with [color = CL]

  let GroupLinks links with [(member? end1 NewGroup) and  (member? end2 NewGroup) ]
        ask  NewGroup  [st]
       ask GroupLinks [show-link]
   layout-spring  NewGroup GroupLinks  1 10 1
end 

to shadow_group
  let ShadowCliq users with [hidden? = true]
  let shadowLink links with [hidden? = true]
  ask turtles with [hidden? = false] [ht]
  ask links with [hidden? = false] [hide-link]
     ask ShadowCliq  [st]
      ask shadowLink [show-link]
      layout-spring  ShadowCliq  shadowLink 1 10 15
end 

to-report global-clustering-coefficient
  let closed-triplets sum [ nw:clustering-coefficient * count my-links * (count my-links - 1) ] of turtles
  let triplets sum [ count my-links * (count my-links - 1) ] of turtles
  report closed-triplets / triplets
end 

;;;

to clustC
  nw:set-context users links
let Centr max-one-of users [nw:betweenness-centrality]

layout-radial users links Centr
  ask Centr [set label-color 9.9 set label agentname]
end 

to NewClustC
    nw:set-context users links
let Centr max-one-of users [nw:betweenness-centrality]
ask Centr  [die]
ask users with [count my-links = 0] [die]
set Centr max-one-of users [nw:betweenness-centrality]
  layout-radial users links Centr
  ask Centr [set label-color 9.9   set label agentname]
end 



 ;;;

to biggestClust

  ask turtles [ht]
  ask links [hide-link]
    let BigCliq one-of   nw:bicomponent-clusters
  ask BigCliq [st]
  let BigCliqLinks links with [(member? end1 BigCliq) and  (member? end2 BigCliq) ]
  ask BigCliqLinks [show-link]
layout-circle users with [hidden? = false]  20
end 

to ColorCommunity
  ask users [home st set label "" set color 9.9]
  ask links [hide-link]
  set communities-n nw:louvain-communities
   set communities-n filter [x1 -> count x1 > 2] communities-n
  set communities-n sort-by [[ x1 x2] -> count x1 > count x2] communities-n
  if length communities-n > 14 [set communities-n sublist communities-n  0 13 ]
  let colors sublist  base-colors 0 (length communities-n)
  let radius max-pxcor * 3 / 4
  let dist  n-values length communities-n [ i -> i ]

  ask turtles [set heading 0]
  let angle 360 / length colors

  (foreach reverse communities-n reverse colors dist [ [community1 col dist1] ->
  ask community1 [      set color col set label ""

    rt angle * dist1
      fd (radius   )
   ;;   rt random 360
    ]
;; let Centr max-one-of community1 [nw:betweenness-centrality]

    ask links with [(member? end1 community1) and  (member? end2 community1) ] [show-link]
 repeat 3 [layout-spring community1 links with [(member? end1 community1) and  (member? end2 community1) ]  0.5 0.1 0.2 ]
    ;; попробуй ставить их в точки, зависящие от col
])
end 

to CentralCommunity
    ask users [home st set color 9.9 set label ""]
  ask links [hide-link]
  set communities-n nw:louvain-communities
   set communities-n filter [x1 -> count x1 > 2] communities-n
  set communities-n sort-by [[ x1 x2] -> count x1 > count x2] communities-n
  if length communities-n > 14 [set communities-n sublist communities-n  0 14 ]
  let colors sublist  base-colors 0 (length communities-n)
  let radius max-pxcor - 30
  ask turtles [set heading 0]
 let angle 360 / length colors
  (foreach communities-n colors [ [community1 col] ->
    ask community1 [
     set color col
    ]
 let Centr max-one-of community1 [nw:betweenness-centrality]
     layout-radial community1  links with [(member? end1 community1) and  (member? end2 community1) ] Centr
    ask links with [(member? end1 community1) and  (member? end2 community1) ] [show-link]
  ])
end 

to See_Community [group]
 ;; show CL
  ask turtles [ht set label "" set size 1]
  ask links [hide-link]
  let NewGroup group

  let GroupLinks links with [(member? end1 NewGroup) and  (member? end2 NewGroup) ]
        ask  NewGroup  [
    st set size 0.8
    set label agentname
 ;;  set label who
  ]
       ask GroupLinks [show-link
  ]
;;  repeat 7 [ layout-spring  NewGroup GroupLinks  1 10 7 ]
end 

to comm_output

  file-open user-new-file

  foreach  communities-n [
     ?1 ->
set Mdl nw:modularity (list ?1 ?1 )
    file-print csv:to-row
    (list
      count  ?1
   precision   Mdl  3

    )
    ]

 file-close
end 

to tmm
  show nw:modularity (list (turtles with [ color = 5 ])
    (turtles with [ color = 15 ]) (turtles with [ color = 25 ])  (turtles with [ color = 35 ]) (turtles with [ color = 45 ])  (turtles with [ color = 55 ]) (turtles with [ color = 65 ])
    (turtles with [ color = 75 ])
   (turtles with [ color = 85 ])
    (turtles with [ color = 95 ])
   (turtles with [ color = 105 ])
  (turtles with [ color = 115 ])
 ;;   (turtles with [ color = 9.9 ])
  )
end 



; Auxiliary reports to split a string using a substring

to-report split-aux [s s1]
  ifelse member? s1 s
  [ let p position s1 s
    report (list (substring s 0 p) (substring s (p + (length s1)) (length s)))
  ]
  [ report (list s "")
  ]
end 

to-report split [s s1]
  ifelse member? s1 s
  [
    let sp split-aux s s1
    report (fput (first sp) (split (last sp) s1))
  ]
  [ report (list s) ]
end 

to-report join [s c]
  report reduce [[s1 s2] -> (word s1 c s2)] s
end 

to-report replace [s c1 c2]
  report join (split s c1) c2
end 

to-report store [val l]
  report lput val l
end 

to inspect-user
  if mouse-down? [
    ask users [stop-inspecting self]
    let selected min-one-of users [distancexy mouse-xcor mouse-ycor]
    if selected != nobody [
      ask selected [
        if distancexy mouse-xcor mouse-ycor < 1 [inspect self]
      ]
    ]
    wait .2
  ]
end 

to plotTable [Lx Ly]
  set-current-plot "General"
  clear-plot
  set-plot-x-range (min Lx) (max Lx)
  set-plot-y-range (min Ly) (max Ly)
  (foreach Lx Ly
    [ [x y] ->
      plotxy x y
    ])
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Centrality Measures
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; Takes a centrality measure as a reporter task, runs it for all users
;; and set labels, sizes and colors of turtles to illustrate result

to compute-centralities
  nw:set-context users links
  ask users [
    set degree (count my-links)
    set in-degree (count my-in-links)
        set out-degree (count my-out-links)
  ;; set betweenness nw:betweenness-centrality
 set betweenness norm-betweenness
    set eigenvector nw:eigenvector-centrality
    set closeness nw:closeness-centrality
    set clustering nw:clustering-coefficient
    set page-rank nw:page-rank
  ]
  update-plots
end 

to plot-degree
  Let Dk [degree] of users
  let M max Dk
  set-current-plot "Degree Distribution"
  set-plot-x-range 0 (M + 1)
  set-plot-y-range 0 1
  histogram Dk
end 

to plot-page-rank
  Let Dk [page-rank] of users
  let M max Dk
  set-current-plot "PageRank Distribution"
  set-plot-x-range 0 (M + M / 100)
  set-plot-y-range 0 1
  set-histogram-num-bars 100
  histogram Dk
end 

to plot-betweenness
;; Let Dk [nw:betweenness-centrality] of users
  Let Dk [norm-betweenness] of users
  let M max Dk
  set-current-plot "Betweenness Distribution"
  set-plot-x-range 0 (ceiling M)
  set-plot-y-range 0 1
  set-histogram-num-bars 100
  histogram Dk
end 

to plot-eigenvector
  Let Dk [nw:eigenvector-centrality] of users
  let M max Dk
  set-current-plot "Eigenvector Distribution"
  set-plot-x-range 0 (ceiling M)
  set-plot-y-range 0 1
  set-histogram-num-bars 100
  histogram Dk
end 

to plot-closeness
  Let Dk [nw:closeness-centrality] of users
  let M max Dk
  set-current-plot "Closeness Distribution"
  set-plot-x-range 0 (ceiling M)
  set-plot-y-range 0 1
  set-histogram-num-bars 100
  histogram Dk
end 

to plot-clustering
  Let Dk [nw:clustering-coefficient] of users
  let M max Dk
  set-current-plot "Clustering Distribution"
  set-plot-x-range 0 (ceiling M)
  set-plot-y-range 0 1
  set-histogram-num-bars 100
  histogram Dk
end 

to plots
  clear-all-plots
  compute-centralities
  carefully [plot-page-rank][]
  carefully [plot-degree][]
  carefully [plot-betweenness][]
  carefully [plot-eigenvector][]
  carefully [plot-closeness][]
  carefully [plot-clustering][]
 carefully [set diameter compute-diameter 1000][]
end 

;; We want the size of the turtles to reflect their centrality, but different measures
;; give different ranges of size, so we normalize the sizes according to the formula
;; below. We then use the normalized sizes to pick an appropriate color.

to normalize-sizes-and-colors [c]
  if count users > 0 [
    let sizes sort [ size ] of users ;; initial sizes in increasing order
    let delta last sizes - first sizes ;; difference between biggest and smallest
    ifelse delta = 0 [ ;; if they are all the same size
      ask users [ set size 1 ]
    ]
    [ ;; remap the size to a range between 0.5 and 2.5
     ask users [ set size ((size - first sizes) / delta) * 10.5 + 0.4
     ;   ask users [ set size ((size - first sizes) / delta) * 5.5 + 0.4

      ]
    ]
    ask users [ set color c ]
  ;;  lput 200 extract-rgb scale-color c size 3.8 0
  ;; ] ; using a higher range max not to get too white...
  ]
end 

; The diameter is cpmputed from a random search on distances between users

to-report compute-diameter [n]
  let s 0
  repeat n [
    ask one-of users [
      set s max (list s (nw:distance-to one-of other users))
    ]
  ]
  report s
end 

to-report Average-Path-Length
  report nw:mean-path-length
end 

to-report Average-Clustering
  report mean [clustering] of users
end 

to-report Average-Betweenness
  report mean [betweenness] of users
end 

to-report Average-Closeness
  report mean [closeness] of users
end 

to-report Average-PageRank
  report mean [page-rank] of users
end 

to-report Average-Eigenvector
  report mean [eigenvector] of users
end 

to-report Average-Degree
  report mean [count my-links] of users
end 

to-report Number-users
  report count users
end 

to-report Number-Links
  report count Links
end 

to-report Density
  report 2 * (count links) / ( (count users) * (-1 + count users))
end 

to-report All-Measures
  report (list Number-users
               Number-Links
               Density
               Average-Degree
               Average-Path-Length
               Diameter
               Average-Clustering
               Average-Betweenness
               Average-Eigenvector
               Average-Closeness
               Average-PageRank
               )
end 

to post-process
  ask links [
    ;set color black
    set color [100 100 100 100]
  ]
  set diameter compute-diameter 1000
end 

;; Mutual Links

to-report Mutual
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Page Rank
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to PRank [n]
  let damping-factor 0.85
  ;ask links [ set color gray set thickness 0 ]
  ask users [
    set rank 1 / count users
    set new-rank 0 ]
  repeat N [
    ask users
    [
      ifelse any? link-neighbors
      [
        let rank-increment rank / count link-neighbors
        ask link-neighbors [
          set new-rank new-rank + rank-increment
        ]
      ]
      [
        let rank-increment rank / count users
        ask users [
          set new-rank new-rank + rank-increment
        ]
      ]
    ]
    ask users
    [
      ;; set current rank to the new-rank and take the damping-factor into account
      set rank (1 - damping-factor) / count users + damping-factor * new-rank
    ]
  ]

  let total-rank sum [rank] of users
  let max-rank max [rank] of users
  ask users [
    set size 0.2 + 2 * (rank / max-rank)
  ]
end 

to spring_all
    let factor sqrt count turtles

  repeat 15 [layout-spring turtles links (1.5 / factor) (7 / factor) (1 / factor)]
 ;; repeat 50 [ layout-spring (turtles with [any? link-neighbors]) links 0.4 6 1 ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

There is only one version of this model, created about 7 years ago by Evgeny Patarakin.

Attached files

File Type Description Last updated
WaningMirrorTeamReflexivity.png preview Preview for 'WaningMirrorTeamReflexivity' about 7 years ago, by Evgeny Patarakin Download

This model does not have any ancestors.

This model does not have any descendants.