HistoryOfCollaboration
Model was written in NetLogo 5.3.1
•
Viewed 308 times
•
Downloaded 24 times
•
Run 0 times
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] ;;; Это описание пород агентов, которые есть в программе - к каждой породе ее собственные переменные;; ;; Это у нас программа для анализа данных домена http://edu.crowdexpert.ru/ ;; Actions: Upload, Create, View breed [users user] ; breed [pages page] ; users-own [agentname gender pages_list votes_list comments_list ] ; ;; Имя, Пол, Страницы, которые создал, проголосовал, прокомментировал ;; Что еще в системе связей с другими? pages-own [pagename my_author http votes_for votes_against comments_list ] ; ;; ID объекта во внешней таблице, id автора, перечень тех, кто голосовал за и против, тех кто комментировал ;; Связи в системе Субъект - Объект directed-link-breed [bonds bond] ; создание directed-link-breed [votebonds votebond] ; голосование directed-link-breed [comments comment] ; комментирование bonds-own [edits] ; votebonds-own [mark] ; ;;;; Запасные связи для использованию по выбору - если захотим использовать ненаправленные связи undirected-link-breed [unbonds unbond] ; создание undirected-link-breed [unvotebonds unvotebond] ; голосование undirected-link-breed [uncomments uncomment] ; комментирование unbonds-own [edits] ; unvotebonds-own [mark] ; ;; Связи в системе Субъект - Субъект undirected-link-breed [unsselinks unsselink] ; - связи, основанные на том, что оценивал undirected-link-breed [unssvlinks unssvlink] ; - связи, основанные на том, что комментировал unsselinks-own [colpages] unssvlinks-own [colpages] globals [wikihistory male female expert_list user_list step ] ; ;;; Очистили, закрыли и обнулили все, to startup clear-all ; set-default-shape users "person" ; set-default-shape pages "square" ; set-default-shape votebonds "vote" ; set-default-shape comments "comment" ; file-close; set wikihistory [] ; set male [] ; set female [] ; if (file-exists? "go_ban3.gif" ) [import-drawing "go_ban3.gif" ] set expert_list ["20" "34" "35" "36" "39" "41" "60" "68" "85" "116" "141" "145" "152" "182" "184" "185" "190" "191" "200" "202" "211" "290" "343" "447" "633" "642" "1342" "1471" "1502" "1626" "2196" "2310" "2776" "5259" "5680"] end ;; ;; Загрузили данные to load_file file-open user-file while [ not file-at-end? ] [ ;; fput потому что в другом порядке ??? set wikihistory lput csv:from-row file-read-line wikihistory ] file-close end to load_users file-open user-file while [ not file-at-end? ] [ let user csv:from-row file-read-line ifelse last user = "female" [set female lput first user female] [set male lput first user male] ] file-close end ;;;;;;;;; to present reset-ticks set step max-pxcor / (length remove-duplicates map [first ?] wikihistory) let imnamber 1 foreach wikihistory [ if ticks > 1000 [stop] visual ? tick ; if 0 = (ticks mod 4) [ repeat 3 [layout-spring turtles links 0.1 1 0.3] ;; export-view word imnamber ".png" ;; это если под запись set imnamber imnamber + 1 ] ] end to visual [flist] let agent_name first flist ;; это мы просто считали имена агентов и страниц let page_name first bf flist ;; это имя страницы let action_name first bf bf flist let http_a last flist ;; это адрес страницы if (not any? pages with [pagename = page_name]) [ create-ordered-pages 1 [ set size 0.8 set votes_for [] ; set votes_against [] ; set comments_list [] ; set pagename page_name ; set http http_a ; set color 95 ] ] if (not any? users with [agentname = agent_name]) [ create-ordered-users 1 [ set size 1.4 set pages_list [] ; set votes_list [] ; set comments_list [] ; set agentname agent_name ; ifelse member? agentname female [set shape "girl" set gender "female" set color 25] [set shape "person" set gender "male" set color 27] rt random 360 fd step * count users if member? (word "" agent_name "") expert_list [set size 1.7 set shape "person graduate"] ] ] let who_user [who] of one-of users with [agentname = agent_name] ; let who_page [who] of one-of pages with [pagename = page_name] ; ;; А теперь в зависимости от действия создаем разные связи между агентом и страницей if action_name = "createidea" [ ask page who_page [set my_author who_user move-to user who_user rt random 360 fd 0.2 ] ; ask user who_user [ create-bond-to page who_page set pages_list lput who_page pages_list ] ; stop ; ] if action_name = "vote_for" [ ask user who_user [ if (empty? pages_list) and (empty? votes_list) [face page who_page move-to page who_page fd 1] create-votebond-to page who_page set votes_list lput who_page votes_list ] ask page who_page [set votes_for lput who_user votes_for] ask votebond who_user who_page [set mark 1] ; stop ] if action_name = "vote_against" [ ask user who_user [create-votebond-to page who_page set votes_list lput who_page votes_list ] ask page who_page [set votes_against lput who_user votes_against] ask votebond who_user who_page [set mark 0 ]; stop ] if action_name = "comment" [ ask user who_user [create-comment-to page who_page set comments_list lput who_page comments_list ] ask page who_page [set comments_list lput who_user comments_list] stop ] end ;; это версия, когда связи ненаправленные и учитываются только редактирования ;;; to table_output ;; проверить контекст ;; nw:set-context (turtle-set users with [member? agentname map [first ?] user_list ] pages ) (link-set bonds editbonds) ;; nw:set-context (turtle-set users with [member? agentname map [first ?] user_list ] pages ) links ;; let legalusers users with [member? agentname map [first ?] user_list ] ;; nw:set-context users uulinks nw:set-context turtles links file-open user-new-file file-print "General information" ; file-print csv:to-row (list "Num_agents" "Num_objects" "Num_links" ) ; file-print csv:to-row (list count users count pages count links ) ; file-print "Agents" ; file-print csv:to-row (list "Agentname" "userID" "Gender" "PagesCreates" "VotesDone" "CommentsDone" "MyLinks" "Norm-Betweenness" "PageRank" ) ; foreach reverse sort-on [nw:page-rank] users [file-print csv:to-row (list [agentname] of ? [who] of ? [gender] of ? [length pages_list] of ? [length votes_list] of ? [length comments_list] of ? [count my-links ] of ? [norm-betweenness] of ? precision [nw:page-rank] of ? 3 ) ] ;; Ideas ;; file-print "Objects" ; file-print csv:to-row (list "PageName" "PageID" ;; "Author" "VotesFor" "VotesAgainst" "Comments" "Norm-Betweenness" "PageRank" ) ; foreach reverse sort-on [nw:page-rank] pages [file-print csv:to-row (list [pagename] of ? [who] of ? ;; [agentname] of user [my_author] of ? [length votes_for] of ? [length votes_against] of ? [length comments_list ] of ? [norm-betweenness] of ? [nw:page-rank] of ? ) ] file-close end to users_output nw:set-context users links file-open user-new-file file-print csv:to-row (list "Agentname" "userID" "Gender" "PagesCreates" "VotesDone" "CommentsDone" "MyLinks" "Norm-Betweenness" "PageRank" "Clustering-coefficient" ) ; foreach sublist reverse sort-on [norm-betweenness] users 0 500 [ file-print csv:to-row (list [agentname] of ? [who] of ? [gender] of ? [length pages_list] of ? [length votes_list] of ? [length comments_list] of ? [count my-links ] of ? [norm-betweenness] of ? precision [nw:page-rank] of ? 3 precision [nw:clustering-coefficient] of ? 3 ) ] file-close end ;;; to-report page-authors [list1] report remove-duplicates map [[my_author] of page ?] list1 end ;;;;;;; ;;;; ;;; Нормированная центральности to-report norm-betweenness if count turtles > 4 [report precision (nw:betweenness-centrality / ((count turtles - 1) * (count turtles - 2) / 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 [mx - ?] [nw:betweenness-centrality] of turtles ) / znm end ;;; ==== Это у нас часть, где из двудольного графа создаем однодольный ;; Расписано пока для направленных связей to users_clusters ask pages [ let page_id [who] of self ; let MyEditors (turtle-set in-votebond-neighbors ;; in-comment-neighbors - убрано, чтобы не мучиться с тем, что он свои страницы может комментить ) ask MyEditors [ ;; если связь уже существует, то добавить к ней в переменную страницу ifelse is-unsselink? unsselink [who] of self [my_author] of myself [ ask unsselink [who] of self [my_author] of myself [set colpages lput page_id colpages ]] [ if ([my_author] of myself ) = 0 [stop ] create-unsselink-with user [my_author] of myself [set colpages lput page_id [] ] ] ] die ] end to test_clusters ask page 0 [ let page_id [who] of self ; let MyEditors (turtle-set in-votebond-neighbors ;; in-comment-neighbors - убрано, чтобы не мучиться с тем, что он свои страницы может комментить ) ask MyEditors [ ifelse is-unsselink? unsselink [who] of self [my_author] of myself [ ask unsselink [who] of self [my_author] of myself [set colpages lput page_id colpages ]] [ create-unsselink-with user [my_author] of myself [set colpages lput page_id [] ] ] ] ;; die ] end to see_Btw ask turtles [ht] ;; ask links [hide-link] foreach sublist reverse sort-on [norm-betweenness] users 0 9 [ask ? [st set size 2 set color 15 set label-color black 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 [if (count ?) > 2 [ let BigCliq ? 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] 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 central_cliques let Mcentr sublist reverse sort-on [norm-betweenness] users 0 10 ask turtles [ht] ask links [hide-link] foreach nw:maximal-cliques [ if ((count ?) > 12) and (any? ? with [member? one-of ? Mcentr]) ;; and (member? user SomeUser ?) [ let BigCliq ? let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliq [st] ask BigCliqLinks [show-link] ;; layout-spring BigCliq BigCliqLinks 1 7 1 ]] layout-circle users with [hidden? = false] 20 end ;;; мы умеем извлекать клики, в которые входит заданный участник to Mcliq_user [SomeUser] ask turtles [ht] ask links [hide-link] foreach nw:maximal-cliques [ if ((count ?) > 5) and (member? user SomeUser ?) [ let BigCliq ? let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliq [st] ask BigCliqLinks [show-link] layout-spring BigCliq BigCliqLinks 1 7 1 ]] 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] ;; let Centr max-one-of users [nw:page-rank] layout-radial users links Centr export-view (word "../edu_results/public/" [who] of Centr ".png" ) ;; ask max-one-of users [nw:betweenness-centrality] [die] ask users with [count my-links = 0] [die] ask Centr [die] ask users with [count my-links = 0] [die] end to clustP nw:set-context turtles links let Centr max-one-of pages [nw:betweenness-centrality] layout-radial turtles with [norm-betweenness > 0.1] links Centr ;; export-view (word "../sber_results/u325/clusters/" [who] of Centr ".png" ) ;; ask Centr [die] ;;; ask users with [count my-links = 0] [die] 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
There is only one version of this model, created almost 9 years ago by Evgeny Patarakin.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
HistoryOfCollaboration.png | preview | Preview for 'HistoryOfCollaboration' | almost 9 years ago, by Evgeny Patarakin | Download |
This model does not have any ancestors.
This model does not have any descendants.