# Online Community Simulator

Model was written in NetLogo 5.3.1
•
Viewed 874 times
•
Downloaded 26 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

globals [ total-membership-strength decay total-comments gini-index-membership lorenz-points gini-index-comms ] turtles-own [my-comments] breed [ members member ] members-own [ extra-chattiness membership-strength join-date latest-interaction active?] breed [ managers manager ] directed-link-breed [ intimacy-links intimacy-link ] intimacy-links-own [ strength ] directed-link-breed [ interaction-links interaction-link ] interaction-links-own [ comments latest ] ;; NetLogo does not support multiple edges! The "latest" property keeps ;; track of the last time member i communicated with members j to setup ca reset-ticks set decay 1 / 100 set-default-shape turtles "circle" ;; the initial network is a clique of numerosity founders + 1 manager create-managers 1 [ set color red set my-comments 0] create-members founders [ set color white set join-date -1 set active? True set my-comments 0] ask members [ create-intimacy-links-to other members ] ask intimacy-links [ set strength 1 ] ask members [ set extra-chattiness 0 ] layout update-membership-strength update-lorenz-and-gini repeat count members [ tick ] reset-timer end to go create-members 1 [ set color white setxy random-xcor random-ycor set join-date ticks set active? True set my-comments 0 ] converse update-intimacy-links update-membership-strength if count members > num-members [ show ( word "Time elapsed: " timer " seconds.") stop ] manage-community update-lorenz-and-gini update-gini-comms tick end to converse ;; each member must decide whether to engage in interaction. ;; probability of engaging increases if member received communication the previous period. ask members with [ active? ] [ if my-in-interaction-links with [ latest = ticks - 1 ] != nobody [ ;; need to distinguish between in-interaction-links of community managers and those of members. Need an agentset with two "with" conditions! set extra-chattiness 0.2 ] if random-float 1.0 <= chattiness + extra-chattiness [ connect ] set extra-chattiness 0 ;; after the decision to connect reset the extra chattiness ] ;; layout end to connect ;; the member has decided to engage, now she must select the target of her communication. ;; average number of targets is 1 ;; iterate over other members. Prob of creating an interaction-link with another member depends ;; on (relative) strength of intimacy-links with it ;; compute each numerator and decide whether to engage. let denominator count members ;; the denominator of equation (1) in the PDF file is at least count members let connect? False ask other members [ let strength1 0 let strength2 0 if in-intimacy-link-from myself != nobody [ ask in-intimacy-link-from myself [ set strength1 strength ] if out-intimacy-link-to myself != nobody [ ask out-intimacy-link-to myself [ set strength2 strength ] set denominator denominator + 1 + intimacy-strength * strength1 * strength2 ] ] ] ask other members [ let numerator 1 let strength1 0 let strength2 0 if in-intimacy-link-from myself != nobody [ ask in-intimacy-link-from myself [ set strength1 strength ] if out-intimacy-link-to myself != nobody [ ask out-intimacy-link-to myself [ set strength2 strength ] set numerator 1 + intimacy-strength * strength1 * strength2 ] ] if numerator / denominator > random-float 1.0 [ ;; roll the dice for connecting each other member set connect? True ;; keep track that at least one connection happened set my-comments my-comments + 1 set total-comments total-comments + 1 create-interaction-link-from myself [ set color 93 ] ;; if there already was one, the instruction is ignored ask in-interaction-link-from myself [ set latest ticks set comments comments + 1 ] create-intimacy-link-from myself ;; if there already was one, the instruction is ignored ask in-intimacy-link-from myself [ set strength strength + 1] ] ] if connect? = True [ set latest-interaction ticks ] end to update-intimacy-links ask intimacy-links [ set strength strength / ( 1 + decay ) ] end to update-membership-strength ask members with [ active? ] [ let ms 0 ask my-in-intimacy-links [ set ms ms + strength ] set membership-strength ms if membership-strength < threshold and ticks - join-date > 50 [ set active? False set color grey set membership-strength 0 ] set total-membership-strength total-membership-strength + ms ] end to manage-community if onboard = True [ ask managers [ do-onboarding ] ] if engage = True [ ask managers [ do-engagement ] ] end to do-onboarding if ticks > 0 [ create-interaction-links-to members with [ join-date = ticks - 1 ] [ set latest ticks set comments 1 ] create-intimacy-links-to members with [ join-date = ticks - 1 ] [ set strength 1 ] set my-comments my-comments + count members with [ join-date = ticks - 1 ] ;; in this model this is always 1. ] end to do-engagement if ticks > 0 [ ;; to avoid generalized engagement in the first tick create-interaction-links-to members with [ latest-interaction = ticks - 1 ] [ set color 93 ] ;; if it's already there, it will be ignored create-intimacy-links-to members with [ latest-interaction = ticks - 1 ] ;; ditto let this-tick-comms 0 ask members with [ latest-interaction = ticks - 1 ] [ ask in-interaction-link-from myself [ set latest ticks set comments comments + 1 set this-tick-comms this-tick-comms + 1 ] ask in-intimacy-link-from myself [ set strength strength + 1 ] ] set my-comments my-comments + this-tick-comms ] end ;; ============ REPORTERS ======================== ;; COMPUTE LORENZ CURVE AND GINI COEFFICIENT ;; adapted from Wilensky, U. (1998). NetLogo Wealth Distribution model. ;; http://ccl.northwestern.edu/netlogo/models/WealthDistribution. ;; this procedure recomputes the value of gini-index-reserve ;; and the points in lorenz-points for the Lorenz and Gini-Index plots to update-lorenz-and-gini let sorted-ms sort [membership-strength] of members let total-ms sum sorted-ms let ms-sum-so-far 0 let index 0 set gini-index-membership 0 set lorenz-points [] ;; 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 count members [ set ms-sum-so-far (ms-sum-so-far + item index sorted-ms) set lorenz-points lput ((ms-sum-so-far / total-ms) * 100) lorenz-points ;; lput is like append in Python set index (index + 1) set gini-index-membership gini-index-membership + (index / count members ) - (ms-sum-so-far / total-ms ) ] end to-report dropouts report count members - count members with [ active? ] end to update-gini-comms ; let sorted-mc sort [my-comments] of members let total-mc sum sorted-mc let mc-sum-so-far 0 let index-comms 0 set gini-index-comms 0 ;; calculate the Gini index. repeat count members [ set mc-sum-so-far (mc-sum-so-far + item index-comms sorted-mc) set index-comms (index-comms + 1) set gini-index-comms gini-index-comms + (index-comms / count members ) - (mc-sum-so-far / (total-mc + 0.000001 )) ] end ;; ============================================================= ;; LAYOUT PROCEDURE ;; stolen from the preferential attachment model by Uri Wilensky to layout ;; the number 3 here is arbitrary; more repetitions slows down the ;; model, but too few gives poor layouts repeat 3 [ ;; the more turtles we have to fit into the same amount of space, ;; the smaller the inputs to layout-spring we'll need to use let factor sqrt count turtles ;; numbers here are arbitrarily chosen for pleasing appearance layout-spring turtles links (1 / factor) (15 / factor) (4 / factor) display ;; for smooth animation ] ;; don't bump the edges of the world let x-offset max [xcor] of turtles + min [xcor] of turtles let y-offset max [ycor] of turtles + min [ycor] of turtles ;; big jumps look funny, so only adjust a little each time set x-offset limit-magnitude x-offset 0.1 set y-offset limit-magnitude y-offset 0.1 ask turtles [ setxy (xcor - x-offset / 2) (ycor - y-offset / 2) ] end to-report limit-magnitude [number limit] if number > limit [ report limit ] if number < (- limit) [ report (- limit) ] report number end to-report manager-comms report [my-comments] of turtle 0 end ;; =================================================

There is only one version of this model, created over 7 years ago by Alberto Cottica.

## Attached files

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

Online Community Simulator.png | preview | Preview for 'Online Community Simulator' | over 7 years ago, by Alberto Cottica | Download |

This model does not have any ancestors.

This model does not have any descendants.