globals [ clustering-coefficient clustering-coefficient-of-lattice average-path-length average-path-length-of-lattice infinity acc_change apl_change average_degree density component-size giant-component-size components go? proportion_cooperation_list tolerance_list average_hamming_distance_list cum_duration_fall duration_fall cooperation_history first_emergence_time_all_coop first_emergence_time_all_defect first_emergence_time_either phase cum_duration_rise duration_rise count_rise count_fall mode_tolerance_list_history count_zero_block tol_dependent_degree_list ] turtles-own [ score tag-list tolerance average_hamming_distance dissimilarity_list new_disdissimilarity_list neighbor_list new_neighbor_list temp-score temp-strategy strategy-list node-clustering-coefficient distance-from-other-turtles target explored? ] to setup clear-all set infinity 999 set cum_duration_fall 0 set duration_fall 0 set cum_duration_rise 0 set duration_rise 0 set cooperation_history [ ] set count_rise 0 set count_fall 0 set mode_tolerance_list_history [ ] set count_zero_block 0 set-default-shape turtles "circle" make-nodes-links no-display set clustering-coefficient-of-lattice clustering-coefficient set average-path-length-of-lattice average-path-length ask turtles [ set neighbor_list [ who ] of link-neighbors set new_neighbor_list sort neighbor_list establish-color-setup ] ask turtles [ similarity-perception ] ;;if ( b/c = *** ) and ( network_plasticity = *** ) and ( closure_probability = *** ) [ ;;file-open "E:\\exp***.txt" ;;] update-plot display end to make-nodes-links make-nodes-net if ( erdos_renyi_probability = 0 or erdos_renyi_probability = 1 ) [ stop ] ask turtles [ create-links-with turtles with [self > myself and random-float 1.0 <= erdos_renyi_probability ] [ set color grey - 3 ] ] let success? not any? turtles with [ count my-links = 0 ] set success? do-calculations ifelse average-path-length = 999 [ setup clear-all-plots ] [ ask turtles [ set size ( 0.2 * count my-links ) ] set success? do-calculations ] end to make-nodes-net crt num_of_agents [ set tag-list [ ] let i 0 while [ i < num-of-tag-item ] [ set tag-list fput random 2 tag-list set i i + 1 ] let j 0 while [ j < num_of_agents ] [ let l num-of-tag-item set tolerance random ( l + 2 ) set j j + 1 ] set dissimilarity_list [ ] set new_disdissimilarity_list [ ] set neighbor_list [ ] set new_neighbor_list [ ] set strategy-list [ ] set temp-score [ ] layout-circle (sort turtles) max-pxcor - 1 ] end to establish-color-setup set color 1 + tolerance end to go set go? true ask turtles [ similarity-perception ] ask turtles [ interaction-payoff ] ask turtles [ tag-tolerance-update ] ask turtles [ select present_what ifelse count my-links != 0 [ set size ( 0.2 * count my-links ) ] [ set size 0.4 ] ] tick if layout? [ layout ] let success? do-calculations update-plot end ;;Text files can be exported in the following ways. ;;to write-to-file-network ;;file-print ( word "dl " "n=" num_of_agents " format=nodelist1" ) ;;file-type ( word "data:" ) ;;foreach sort turtles [ ;;.... ;;file-print "" ;;end ;;to write-to-file-attribute ;;file-print " " ;;foreach sort turtles [ ;;... ;;file-print " " ;;end to-report do-calculations ;; set up a variable so we can report if the network is disconnected let connected? true ;; find the path lengths in the network find-path-lengths let num-connected-pairs sum [length remove infinity (remove 0 distance-from-other-turtles)] of turtles ;; In a connected network on N nodes, we should have N(N-1) measurements of distances between pairs, ;; and none of those distances should be infinity. ;; If there were any "infinity" length paths between nodes, then the network is disconnected. ;; In that case, calculating the average-path-length doesn't really make sense. ifelse ( num-connected-pairs != (count turtles * (count turtles - 1) )) [ set average-path-length infinity ;; report that the network is not connected set connected? false ] [ set average-path-length (sum [sum distance-from-other-turtles] of turtles) / (num-connected-pairs) ] ;; find the clustering coefficient and add to the aggregate for all iterations find-clustering-coefficient ;; report whether the network is connected or not report connected? end to-report in-neighborhood? [ hood ] report ( member? end1 hood and member? end2 hood ) end to find-clustering-coefficient ifelse all? turtles [count link-neighbors <= 1] [ set clustering-coefficient 0 ] [ let total 0 ask turtles with [ count link-neighbors <= 1] [ set node-clustering-coefficient "undefined" ] ask turtles with [ count link-neighbors > 1] [ let hood link-neighbors set node-clustering-coefficient (2 * count links with [ in-neighborhood? hood ] / ((count hood) * (count hood - 1)) ) ;; find the sum for the value at turtles set total total + node-clustering-coefficient ] ;; take the average set clustering-coefficient total / count turtles with [count link-neighbors > 1] ] end ;; Implements the Floyd Warshall algorithm for All Pairs Shortest Paths ;; It is a dynamic programming algorithm which builds bigger solutions ;; from the solutions of smaller subproblems using memoization that ;; is storing the results. ;; It keeps finding incrementally if there is shorter path through ;; the kth node. ;; Since it iterates over all turtles through k, ;; so at the end we get the shortest possible path for each i and j. to find-path-lengths ;; reset the distance list ask turtles [ set distance-from-other-turtles [] ] let i 0 let j 0 let k 0 let node1 one-of turtles let node2 one-of turtles let node-count count turtles ;; initialize the distance lists while [i < node-count] [ set j 0 while [j < node-count] [ set node1 turtle i set node2 turtle j ;; zero from a node to itself ifelse i = j [ ask node1 [ set distance-from-other-turtles lput 0 distance-from-other-turtles ] ] [ ;; 1 from a node to it's neighbor ifelse [ link-neighbor? node1 ] of node2 [ ask node1 [ set distance-from-other-turtles lput 1 distance-from-other-turtles ] ] ;; infinite to everyone else [ ask node1 [ set distance-from-other-turtles lput infinity distance-from-other-turtles ] ] ] set j j + 1 ] set i i + 1 ] set i 0 set j 0 let dummy 0 while [k < node-count] [ set i 0 while [i < node-count] [ set j 0 while [j < node-count] [ ;; alternate path length through kth node set dummy ( (item k [distance-from-other-turtles] of turtle i) + (item j [distance-from-other-turtles] of turtle k)) ;; is the alternate path shorter? if dummy < (item j [distance-from-other-turtles] of turtle i) [ ask turtle i [ set distance-from-other-turtles replace-item j distance-from-other-turtles dummy ] ] set j j + 1 ] set i i + 1 ] set k k + 1 ] end to similarity-perception ifelse count link-neighbors = 0 [ set average_hamming_distance 0 ] [ set neighbor_list [ who ] of link-neighbors set new_neighbor_list sort neighbor_list set dissimilarity_list [ ] let i 0 while [ i < count link-neighbors ] [ let b length filter [ ? = true ] ( map [ ?1 = 1 and ?2 = 0 ] [ tag-list ] of self [ tag-list ] of turtle item i new_neighbor_list ) let c length filter [ ? = true ] ( map [ ?1 = 0 and ?2 = 1 ] [ tag-list ] of self [ tag-list ] of turtle item i new_neighbor_list ) set dissimilarity_list lput ( b + c ) dissimilarity_list set i i + 1 ] set new_disdissimilarity_list dissimilarity_list set average_hamming_distance mean new_disdissimilarity_list ] end to interaction-payoff set score 0 set temp-score [ ] set strategy-list [ ] let i 0 while [ i < count link-neighbors ] [ let partner turtle item i new_neighbor_list let ego self let p position [ who ] of ego [ new_neighbor_list ] of partner ask partner [ ifelse [ tolerance ] of partner > item p [ new_disdissimilarity_list ] of partner [ set temp-strategy true ] [ set temp-strategy false ] ] ifelse [ tolerance ] of ego > item i [ new_disdissimilarity_list ] of ego [ set [ temp-strategy ] of ego true set strategy-list lput 1 strategy-list ifelse [ temp-strategy ] of partner = true [ set temp-score fput ( b/c - 1 ) temp-score ] [ set temp-score fput ( - 1 ) temp-score ] ] [ set [ temp-strategy ] of ego false set strategy-list lput 0 strategy-list ifelse [ temp-strategy ] of partner = true [ set temp-score fput b/c temp-score ] [ set temp-score fput 0 temp-score ] ] set i i + 1 ] set score sum temp-score end ;; Things to Notice ;; There are two mutation rates, mu1 and mu2, in this model as below. ;; The mutation rates are controlled as 0.01 for cultural perturbation and network perturbation, ;; Given the codes actually used below, ;; the following values were taken in our Behavior-Space experiments. ;; At p=10, mu1=1/90; mu2=1/10 ;; At p=20, mu1=1/80; mu2=1/20 ;; At p=30, mu1=1/70; mu2=1/30 ;; At p=40, mu1=1/60; mu2=1/40 ;; At p=50, mu1=1/50; mu2=1/50 ;; Without network plasticity, if the mutation rate is 1 given N=100, 1 agent errs in learning. ;; If network plasticity = 50 but the same mutation rate (0.01), ;; the chance of cultural mutation will decrease, which accordingly reduces the emergence of mutant defectors (i.e. Conditional probability). ;; To avoid this issue, regardless of different levels of network plasticity, ;; 1 agent experiences cultural perturbation, and 1 agent experiences network perturbation at every generation. to tag-tolerance-update let p random 100 let m random-float 1.0 ifelse ( p < network_plasticity and p >= 0 ) [ ifelse mu1 > m [ ifelse count link-neighbors != 0 [ random_breaking_making ] [ random_making ] ] [ ifelse count link-neighbors != 0 [ breaking_if_outgroup_making_if_ingroup ] [ making_if_ingroup ] ] ] [ ifelse mu2 > m [ ifelse count link-neighbors != 0 [ set tag-list [ ] let j 0 while [ j < num-of-tag-item ] [ set tag-list fput random 2 tag-list set j j + 1 ] set tolerance random ( num-of-tag-item + 2 ) ] [ stop ] ] [ ifelse count link-neighbors != 0 [ let reference one-of link-neighbors let what-to-compare [score] of reference let self-score [score] of self if what-to-compare > self-score [ set tag-list [ ] set tag-list [ tag-list ] of reference ifelse tolerance > [ tolerance ] of reference [ ifelse tolerance = 0 [ set tolerance tolerance ] [ set tolerance tolerance - 1 ] ] [ ifelse tolerance = [ tolerance ] of reference [ set tolerance [ tolerance ] of reference ] [ ifelse tolerance = num-of-tag-item + 1 [ set tolerance tolerance ] [ set tolerance tolerance + 1 ] ] ] ] ] [ stop ] ] ] end to random_breaking_making let node1 one-of link-neighbors let f [ who ] of node1 let node3 self let g [ who ] of node3 ifelse ( node1 = nobody ) [ stop ] [ let node2 one-of turtles with [ ( not link-neighbor? node3 ) and ( self != node3 )] let h [ who ] of node2 ask node3 [ create-link-with node2 [ set color green - 1 ] ] ask link [ who ] of node3 [ who ] of node1 [ die ] set [ new_neighbor_list ] of self fput h [ new_neighbor_list ] of self set [ new_neighbor_list ] of self sort remove f [ new_neighbor_list ] of self set [ new_neighbor_list ] of node2 sort fput g [ new_neighbor_list ] of node2 set [ new_neighbor_list ] of node1 sort remove g [ new_neighbor_list ] of node1 ] end to random_making let node1 self let b [ who ] of node1 let node2 one-of turtles with [ ( not link-neighbor? node1 ) and ( self != node1 ) ] let a [ who ] of node2 ask node1 [ create-link-with node2 [ set color green - 1 ] ] set [ new_neighbor_list ] of self sort fput a [ new_neighbor_list ] of self set [ new_neighbor_list ] of node2 sort fput b [ new_neighbor_list ] of node2 end to breaking_if_outgroup_making_if_ingroup let node1 one-of link-neighbors let b length filter [ ? = true ] ( map [ ?1 = 1 and ?2 = 0 ] [ tag-list ] of self [ tag-list ] of node1 ) let c length filter [ ? = true ] ( map [ ?1 = 0 and ?2 = 1 ] [ tag-list ] of self [ tag-list ] of node1 ) let dis1 ( b + c ) ifelse dis1 >= [ tolerance ] of self [ let f [ who ] of node1 let node3 self let g [ who ] of node3 ifelse ( node1 = nobody ) [ stop ] [ let q random 100 ifelse ( q < closure_probability and q >= 0 ) [ set target one-of link-neighbors ifelse count [ link-neighbors ] of target >= 2 [ let node2 one-of other [ link-neighbors ] of target let a length filter [ ? = true ] ( map [ ?1 = 1 and ?2 = 0 ] [ tag-list ] of self [ tag-list ] of node2 ) let d length filter [ ? = true ] ( map [ ?1 = 0 and ?2 = 1 ] [ tag-list ] of self [ tag-list ] of node2 ) let dis2 ( a + d ) ifelse ( dis2 < [ tolerance ] of self ) and ( dis2 < [ tolerance ] of node2 ) [ let h [ who ] of node2 ask node3 [ create-link-with node2 [ set color white - 1 ] ] ask link [ who ] of node3 [ who ] of node1 [ die ] set [ new_neighbor_list ] of self sort fput h [ new_neighbor_list ] of node3 set [ new_neighbor_list ] of self sort remove f [ new_neighbor_list ] of self set [ new_neighbor_list ] of node2 sort fput g [ new_neighbor_list ] of node2 set [ new_neighbor_list ] of node1 sort remove g [ new_neighbor_list ] of node1 ] [ stop ] ] [ stop ] ] [ let node2 one-of turtles with [ ( not link-neighbor? node3 ) and ( self != node3 ) and ( not member? self [ link-neighbors ] of link-neighbors ) ] let a length filter [ ? = true ] ( map [ ?1 = 1 and ?2 = 0 ] [ tag-list ] of self [ tag-list ] of node2 ) let d length filter [ ? = true ] ( map [ ?1 = 0 and ?2 = 1 ] [ tag-list ] of self [ tag-list ] of node2 ) let dis2 ( a + d ) ifelse ( dis2 < [ tolerance ] of self ) and ( dis2 < [ tolerance ] of node2 ) [ let h [ who ] of node2 ask node3 [ create-link-with node2 [ set color blue - 1 ] ] ask link [ who ] of node3 [ who ] of node1 [ die ] set [ new_neighbor_list ] of self sort fput h [ new_neighbor_list ] of self set [ new_neighbor_list ] of self sort remove f [ new_neighbor_list ] of self set [ new_neighbor_list ] of node2 sort fput g [ new_neighbor_list ] of node2 set [ new_neighbor_list ] of node1 sort remove g [ new_neighbor_list ] of node1 ] [ stop ] ] ] ] [ stop ] end to making_if_ingroup let node1 self let b [ who ] of node1 let node2 one-of turtles with [ ( not link-neighbor? node1 ) and ( self != node1 ) and ( not member? self [ link-neighbors ] of link-neighbors ) ] let a length filter [ ? = true ] ( map [ ?1 = 1 and ?2 = 0 ] [ tag-list ] of self [ tag-list ] of node2 ) let d length filter [ ? = true ] ( map [ ?1 = 0 and ?2 = 1 ] [ tag-list ] of self [ tag-list ] of node2 ) let dis2 ( a + d ) ifelse ( dis2 < [ tolerance ] of self ) and ( dis2 < [ tolerance ] of node2 ) [ let c [ who ] of node2 ask node1 [ create-link-with node2 [ set color blue - 1 ] ] set [ new_neighbor_list ] of self sort fput c [ new_neighbor_list ] of node1 set [ new_neighbor_list ] of node2 sort fput b [ new_neighbor_list ] of node2 ] [ stop ] end to select [ present ] if ( present = "tolerance" ) [ set color 1 + tolerance set label-color 56 set label tolerance ] if ( present = "strategy" ) [ if count link-neighbors != 0 [ set color 41 + ( 8 * sum strategy-list / count link-neighbors ) ] set label-color 56 set label tolerance ] if ( present = "av-hamming-d" ) [ set color 129 - average_hamming_distance ] end to-report occurrences [x the-list] report reduce [ifelse-value (?2 = x) [?1 + 1] [?1]] (fput 0 the-list) end to find-all-components set components [] set giant-component-size 0 ask turtles [ set explored? false ] ;; keep exploring till all turtles get explored loop [ ;; pick a turtle that has not yet been explored let start one-of turtles with [ not explored? ] if start = nobody [ stop ] ;; reset the number of turtles found to 0 ;; this variable is updated each time we explore an ;; unexplored turtle. set component-size 0 ask start [ explore ] ;; the explore procedure updates the component-size variable. ;; so check, have we found a new giant component? if component-size > giant-component-size [ set giant-component-size component-size ] set components lput component-size components ] end ;; finds all turtles reachable from this turtle to explore ;; turtle procedure if explored? [ stop ] set explored? true set component-size component-size + 1 ask link-neighbors [ explore ] end to update-plot set-current-plot "tolerance distribution" set-plot-x-range 0 num-of-tag-item + 2 set-plot-y-range 0 round ( count turtles / ( num-of-tag-item + 1 ) + 100 ) set-histogram-num-bars ( num-of-tag-item + 2 ) histogram [ tolerance ] of turtles find-all-components set-current-plot "% of agents in the giant component" plotxy ticks (giant-component-size / (count turtles)) let max-degree max [count link-neighbors] of turtles set-current-plot "degree distribution" plot-pen-reset ;; erase what we plotted before set-plot-x-range 1 (max-degree + 1) ;; + 1 to make room for the width of the last bar histogram [count link-neighbors] of turtles set-current-plot "degree distribution (log-log)" plot-pen-reset let degree 1 while [degree <= max-degree] [ let matches turtles with [count link-neighbors = degree] if any? matches [ plotxy log degree 10 log (count matches) 10 ] set degree degree + 1 ] set average_degree ( count links * 2 ) / count turtles set density ( 2 * count links ) / ( ( count turtles ) * ( count turtles - 1 ) ) set apl_change average-path-length / average-path-length-of-lattice set acc_change clustering-coefficient / clustering-coefficient-of-lattice set-current-plot "average dissimilarity distribution" plot-pen-reset ifelse num-of-tag-item = 0 [ set-plot-x-range 0 1 ] [ set-plot-x-range 0 num-of-tag-item ] set-plot-y-range 0 count turtles set-histogram-num-bars 10 histogram [ average_hamming_distance ] of turtles set tolerance_list [ tolerance ] of turtles set average_hamming_distance_list [ average_hamming_distance ] of turtles ifelse member? 0 modes tolerance_list and member? 1 modes tolerance_list [ set mode_tolerance_list_history fput 0 mode_tolerance_list_history ] [ set mode_tolerance_list_history fput ( mean modes tolerance_list ) mode_tolerance_list_history ] if ( length mode_tolerance_list_history > 2 ) [ ifelse item 0 mode_tolerance_list_history = 0 and item 1 mode_tolerance_list_history = 0 and ( item 2 mode_tolerance_list_history != 0 ) [ set count_zero_block count_zero_block + 1 ] [ set count_zero_block count_zero_block ] ] ifelse go? = true [ set proportion_cooperation_list [ ] let j 0 ;; I don't know where there is something wrong.... while [ j < count turtles ] [ ;; not divided by 8 any longer ! if length [ neighbor_list ] of turtle j != 0 [ set proportion_cooperation_list fput ( ( sum [ strategy-list ] of turtle j ) / length [ neighbor_list ] of turtle j ) proportion_cooperation_list ] set j j + 1 ] set-current-plot "proportion of cooperation" plot ( sum proportion_cooperation_list ) / count turtles set cooperation_history fput ( sum proportion_cooperation_list / count turtles ) cooperation_history if ( occurrences 1 cooperation_history = 1 and first cooperation_history = 1 ) [ set first_emergence_time_all_coop ticks - 1 set first_emergence_time_either ticks - 1 set phase 1 set count_fall 1 ] if ( occurrences 0 cooperation_history = 1 and first cooperation_history = 0 ) [ set first_emergence_time_all_defect ticks - 1 set first_emergence_time_either ticks - 1 set phase 0 set count_rise 1 ] if ( sum proportion_cooperation_list / count turtles > 0 and sum proportion_cooperation_list / count turtles < 1 ) and ( first_emergence_time_either = 0 ) [ set phase 2 ] ] [ set proportion_cooperation_list [ ] set cooperation_history [ ] set phase 2 ] ifelse ( phase = 1 ) [ ifelse ( sum proportion_cooperation_list / count turtles != 0 ) and ( ticks > first_emergence_time_either ) [ set phase 1 set cum_duration_fall cum_duration_fall + 1 set duration_fall duration_fall + 1 set count_rise count_rise set cum_duration_rise cum_duration_rise set duration_rise 0 ] [ set phase 0 set cum_duration_fall cum_duration_fall set duration_fall 0 set count_rise count_rise + 1 ] ] [ if ( phase = 0 ) [ ifelse ( sum proportion_cooperation_list / count turtles != 1 ) and ( ticks > first_emergence_time_either ) [ set phase 0 set cum_duration_rise cum_duration_rise + 1 set duration_rise duration_rise + 1 set count_fall count_fall set cum_duration_fall cum_duration_fall set duration_fall 0 ] [ set phase 1 set cum_duration_rise cum_duration_rise set duration_rise 0 set count_fall count_fall + 1 ] ] ] set-current-plot "duration dynamics" set-current-plot-pen "cum_dur_fall" plot cum_duration_fall set-current-plot-pen "dur_fall" plot duration_fall set-current-plot-pen "cum_dur_rise" plot cum_duration_rise set-current-plot-pen "dur_rise" plot duration_rise if num-of-tag-item = 4 [ set-current-plot "evolution of tolerance" let tot 0 set-plot-y-range 0 1 set-current-plot-pen "5" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 5 ] / count turtles ) plot-pen-down plotxy ticks tot set-current-plot-pen "4" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 4 ] / count turtles ) plot-pen-down plotxy ticks tot set-current-plot-pen "3" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 3 ] / count turtles ) plot-pen-down plotxy ticks tot set-current-plot-pen "2" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 2] / count turtles ) plot-pen-down plotxy ticks tot set-current-plot-pen "1" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 1 ] / count turtles ) plot-pen-down plotxy ticks tot set-current-plot-pen "0" plot-pen-up plotxy ticks tot set tot tot + ( count turtles with [ tolerance = 0 ] / count turtles ) plot-pen-down plotxy ticks tot ] let i 0 set tol_dependent_degree_list [ ] while [ i < 6 ] [ let pool turtles with [ tolerance = i ] ifelse ( any? pool with [ length new_neighbor_list != 0 ] ) [ set tol_dependent_degree_list lput mean [ length new_neighbor_list ] of turtles with [ tolerance = i ] tol_dependent_degree_list ] [ set tol_dependent_degree_list lput 0 tol_dependent_degree_list ] set i i + 1 ] set tol_dependent_degree_list tol_dependent_degree_list end to layout if not layout? [ stop ] ;; the number here is arbitrary; more repetitions slows down the model, but too few gives poor layouts repeat 5 [ do-layout ;; so we get smooth animation display ] end to do-layout layout-spring (turtles with [any? link-neighbors]) links 0.2 8 1 end @#$#@#$#@ GRAPHICS-WINDOW 225 33 449 278 17 17 6.1143 1 10 1 1 1 0 0 0 1 -17 17 -17 17 1 1 1 ticks CC-WINDOW 5 546 971 641 Command Center 0 SLIDER 1 46 128 79 num_of_agents num_of_agents 10 100 50 1 1 NIL HORIZONTAL BUTTON 110 12 223 45 go go T 1 T OBSERVER NIL NIL NIL NIL BUTTON 0 12 109 45 setup setup NIL 1 T OBSERVER NIL NIL NIL NIL SLIDER 1 113 129 146 num-of-tag-item num-of-tag-item 0 10 4 1 1 NIL HORIZONTAL SWITCH 131 92 221 125 layout? layout? 1 1 -1000 BUTTON 130 55 221 88 redo layout layout T 1 T OBSERVER NIL NIL NIL NIL MONITOR 456 483 506 532 apl average-path-length 3 1 12 PLOT 1 282 223 410 degree distribution degree # of nodes 1.0 10.0 0.0 10.0 true false PENS "default" 1.0 1 -16777216 true MONITOR 599 432 661 481 NIL density 3 1 12 SLIDER -2 146 130 179 erdos_renyi_probability erdos_renyi_probability 0 1 0.12 0.01 1 NIL HORIZONTAL PLOT 452 154 704 282 tolerance distribution tolerance level # of agents 0.0 11.0 0.0 20.0 true false PENS "default" 1.0 1 -16777216 true CHOOSER 130 128 222 173 present_what present_what "tolerance" "strategy" "av-hamming-d" 1 SLIDER 1 79 129 112 b/c b/c 2 10 4 0.1 1 NIL HORIZONTAL SLIDER 1 248 113 281 mu1 mu1 0 1 0.0125 0.0001 1 NIL HORIZONTAL PLOT 225 282 450 411 proportion of cooperation time proportion 0.0 50.0 0.0 1.0 true false PENS "default" 1.0 0 -4699768 true MONITOR 599 482 661 531 p_coop mean proportion_cooperation_list 4 1 12 PLOT 225 412 451 532 average dissimilarity distribution average hamming distance # of agents 0.0 10.0 0.0 20.0 true false PENS "default" 1.0 1 -16777216 true SLIDER 1 214 223 247 closure_probability closure_probability 0 100 40 1 1 % HORIZONTAL PLOT 0 412 224 532 degree distribution (log-log) log of (degree) log of (# of agents) 0.0 0.3 0.0 1.0 true false PENS "default" 0.5 2 -16777216 true SLIDER 1 180 225 213 network_plasticity network_plasticity 0 100 20 1 1 % HORIZONTAL MONITOR 455 432 506 481 acc clustering-coefficient 17 1 12 MONITOR 508 483 597 532 apl change average-path-length / average-path-length-of-lattice 17 1 12 MONITOR 507 432 597 481 acc change clustering-coefficient / clustering-coefficient-of-lattice 17 1 12 PLOT 451 10 798 156 duration dynamics time rhythm 0.0 50.0 0.0 10.0 true true PENS "cum_dur_fall" 1.0 0 -2674135 true "dur_fall" 1.0 1 -8990512 true "cum_dur_rise" 1.0 0 -11053225 true "dur_rise" 1.0 1 -1664597 true MONITOR 798 108 952 157 1st_emergence_all_coop first_emergence_time_all_coop 17 1 12 MONITOR 799 10 950 59 # of 0 to 1 cycle count_rise 17 1 12 MONITOR 798 59 951 108 # of 1 to 0 cycle count_fall 17 1 12 PLOT 703 156 958 283 % of agents in the giant component time % agents 0.0 50.0 0.0 1.0 true false PENS "default" 1.0 0 -13791810 true PLOT 452 282 962 413 evolution of tolerance time proportion 0.0 50.0 0.0 1.0 true true PENS "5" 1.0 0 -13345367 true "4" 1.0 0 -1184463 true "3" 1.0 0 -4079321 true "2" 1.0 0 -7171555 true "1" 1.0 0 -5298144 true "0" 1.0 0 -16382462 true SLIDER 114 248 223 281 mu2 mu2 0 1 0.05 0.0001 1 NIL HORIZONTAL @#$#@#$#@ @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 4.0.2 @#$#@#$#@ setup repeat 5 [rewire-one] @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 1.0 0.0 0.0 1 1.0 0.0 0.2 0 1.0 0.0 link direction true 0 Line -7500403 true 150 150 30 225 Line -7500403 true 150 150 270 225 @#$#@#$#@