# Collective Action Communities

Model was written in NetLogo 6.0-M5
•
Viewed 409 times
•
Downloaded 23 times
•
Run 0 times

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

## Comments and Questions

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

Click to Run Model

patches-own[ mu ; Mean of the logisitic production function beta ; Steepness of the production function contribution-level ;; How much has been contributed progress ;; Ratio of project complete topics ;; Distribution of topics that a patch is "about" pindex ;; Index of the patch ] globals [ multiplier ; How much the parent patch multiplies the interest patch-gini ; Stores the gini of patch contributions turtle-gini ; Stores the gini of turtles patch-progress-gini ; Gini of patch progress ] turtles-own[ interest ;; Baseline interest in projects resources ;; How much they have to contribute each tick contributions-made ;; How much they have contributed in total top-project ;; Current patch with highest utility topic-interests ;; Distribution of topic interests similarity-list ;; List of cosine similarity to each patch ] to setup ca ;; Set the number of topics to use for topic-based let num-topics 20 set-multiplier 1 ;; Create the production functions for the patches ask patches[ set mu random-normal global-mu 1 set beta abs random-normal global-beta 1 update-patch-progress ] ;; If topic-based, then create topics if topic-based? [ setup-patch-topics num-topics ] ;; Make the new turtles make-new-turtles num-turtles num-topics reset-ticks end to set-multiplier [x] set multiplier x end to make-new-turtles [n num-topics] repeat n [ crt 1 [ ;; Place turtle randomly setxy random-xcor random-ycor ;; Give it resources set resources abs random-normal .2 .05 ;set resources random-float 3 ;; And interest set interest random-float max-interest ;; Create topics, if necessary if topic-based? [ set topic-interests make-topics num-topics make-similarity-list ] ] ] end to go ask turtles[ ; Find the best project find-top-project ; Figure out whether to contribute to it contribute-to-project ;ask-to-die ] ask patches[ recolor-patches ] update-ginis tick end ; Creates topics for the patches, and creates an index to access the similarity matrix to setup-patch-topics [num-topics] ask patches [ ; Create random distribution of topics set topics make-topics num-topics ] ;; Create an index so that we can access the similarity list let n 0 foreach sort patches [ ask ? [ set pindex n set n n + 1 ] ] end ; Turtle function; creates a turtle-patch similarity matrix to make-similarity-list set similarity-list [] foreach sort patches [ set similarity-list lput cosine-similarity ? similarity-list ] end ;; turtle function; reports the cosine similarity of a turtle and a patch's topics to-report cosine-similarity [curr-patch] let patch-topics [topics] of curr-patch ; Dot product of topics let dot-product sum (map * topic-interests patch-topics) ; Then normalize by the magnitude of the vectors report dot-product / (make-magnitude topic-interests * make-magnitude patch-topics) end to-report make-magnitude [vector] ; Magnitude of a vector report sqrt sum map [? * ?] vector end ;; Patch and turtle function to-report make-topics [num-topics] let topic-list [] repeat num-topics [ ; For each topic, randomly choose how much of that topic set topic-list lput random 3 topic-list ] report topic-list end ; turtle method to find-top-project ifelse topic-based? [ ; if it's topic-based, then look at all patches set top-project max-one-of patches [patch-utility] ][ ; Otherwise, only look at neighbors set top-project max-one-of patches in-radius neighborhood-size [patch-utility] ] end to contribute-to-project ; Find the top utility of the top project let top-utility [patch-utility] of top-project ; If the benefit is greater than the cost, then contribute resources ifelse top-utility > resources [ ask top-project[ ; update the contribution level and progress of the project set contribution-level contribution-level + [resources] of myself update-patch-progress set pcolor red ] ; Record that this turtle has made a contribution set contributions-made contributions-made + resources ; If they contributed, they are more likely to contribute in the future set interest interest * (1 + positive-reinforcement) ; But, they can't go above the max interest if interest > max-interest [ set interest max-interest ] set color red ][ ;; If they didn't contribute, then decrease their interest set interest interest * (1 - negative-reinforcement) set color blue ] end to update-patch-progress set progress get-patch-progress contribution-level end to-report patch-utility let x contribution-level + [resources] of myself ; What would the total contribution be? let weight [interest] of myself * multiplier / distance myself ; The utility is multiplied by the overall multiplier times my interest if topic-based? [ ; Multiply the weight by how similar the patch topic distribution is to my interest set weight weight * item pindex [similarity-list] of myself ] let orig_utility weight * progress ; Current utility based on logisitic let total_utility weight * get-patch-progress x report total_utility - orig_utility ; Return the amount of utility added end ;; Patch reporter; gives the progress at a given x to-report get-patch-progress [x] let result 0 carefully[ ; Update the patch progress based on the current contribution level. set result 1 / (e ^ ((mu - x) / beta) + 1) ][ ;If the exponential is too lrge, it means we're really close to 0 set result 0 ] report result end to recolor-patches set pcolor scale-color orange progress -1 2 end ; Turtle function to ask-to-die if interest < .05 [ die ] end to update-ginis ; Code basically stolen from the wealth distribution model set patch-gini gini [contribution-level] of patches set turtle-gini gini [contributions-made] of turtles set patch-progress-gini gini [progress] of patches end ;; this procedure recomputes the value of gini-index-reserve ;; and the points in lorenz-points for the Lorenz and Gini-Index plots to-report gini [contributions] let sorted-contribs sort contributions let total-contribs sum sorted-contribs if total-contribs = 0 [ report 0 ] let contrib-sum-so-far 0 let index 0 let gini-index-reserve 0 let lorenz-points [] let num-contribs length contributions ;; now actually plot the Lorenz curve -- along the way, we also ;; calculate the Gini index. ;; (see the Info tab for a description of the curve and measure) repeat num-contribs [ set contrib-sum-so-far (contrib-sum-so-far + item index sorted-contribs) set lorenz-points lput ((contrib-sum-so-far / total-contribs) * 100) lorenz-points set index (index + 1) set gini-index-reserve gini-index-reserve + (index / num-contribs) - (contrib-sum-so-far / total-contribs) ] report (gini-index-reserve / num-contribs) / 0.5 end

There are 6 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Collective Action Communities.png | preview | Preview for 'Collective Action Communities' | over 6 years ago, by Jeremy Foote | Download |

collective_action_abm.pdf | Design Document v1 | over 6 years ago, by Jeremy Foote | Download | |

JeremyFoote_May9.pdf | Progress Report - May 9 | over 6 years ago, by Jeremy Foote | Download |

This model does not have any ancestors.

This model does not have any descendants.