Northwestern Group Dynamics
Model was written in NetLogo 6.0.3
•
Viewed 243 times
•
Downloaded 16 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
extensions [nw cf] breed [students student] breed [organizations organization] undirected-link-breed [friendships friendship] globals [ all-types ] students-own [ freshman? ;to distinguish between freshmen and upperclassmen group-types-wanted group total-groups-recruited-for happy? ] organizations-own [ name group-types drops-in-year ;counts how many students drop the group in a given year ] ;; To setup the model to setup clear-all set all-types ["cultural" "engineering" "greek" "business"] ;25% students are freshmen, rest upperclassmen initialize-orgs initialize-network initialize-freshmen colorize layout reset-ticks end ;; The go procedure that runs until all freshmen are in a group or have exhausted their recruitment limits ;; Calls next year procedure if 'years-roll-on' switch is enabled to go ; continue if there exists freshmen with no group or max-recruitment-limit not reached if count students with [freshman? = true and group = nobody and total-groups-recruited-for < student-recruit-limit] = 0 [ tabulate-happiness tick reset-drops-in-yr ifelse years-roll-on [ next-year ] [ stop ] ] ask students[ let new-friend nobody ifelse freshman? [ ;; 50% chance of meeting freshman vs upperclassmen (as opposed to doing it randomly, would be 25 - 75 based on population) ifelse random 10 < 5 [ set new-friend one-of other students with [freshman? = true] ] [ set new-friend one-of students with [freshman? = false]] ] [ ; upperclassmen meet new ppl w/ only 50% prbability since they are less likely to mingle if random 100 < 50 [ ;; 80% chance of meeting upperclassmen vs freshmen ifelse random 10 < 8 [ set new-friend one-of other students with [freshman? = false] ] [ set new-friend one-of students with [freshman? = true] ] ] ] if new-friend != nobody [ ; If not already friends, then: if not member? new-friend friendship-neighbors [ create-friendship-with new-friend ] ; if still looking for a group, and new friend is in a group if [group] of new-friend != nobody and group = nobody[ let potential-new-group [group] of new-friend if recruit? potential-new-group [ set group potential-new-group ] ] ] ] colorize layout end ;; To initialize the hidden organizations, with their names and group-types to initialize-orgs create-organizations 1 [ set name "ISBE" set hidden? true set group-types ["business"] set drops-in-year 0 ] create-organizations 1 [ set name "Sig Nu" set hidden? true set group-types ["greek"] set drops-in-year 0 ] create-organizations 1 [ set name "EPIC" set hidden? true set group-types ["business" ] set drops-in-year 0 ] create-organizations 1 [ set name "MCSA" set hidden? true set group-types ["cultural"] set drops-in-year 0 ] create-organizations 1 [ set name "Alpha Phi" set hidden? true set group-types ["greek"] set drops-in-year 0 ] create-organizations 1 [ set name "IEEE" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] create-organizations 1 [ set name "Formula" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] create-organizations 1 [ set name "SASA" set hidden? true set group-types ["cultural"] set drops-in-year 0 ] end ;; To initialize the initial network of Northwestern upperclassmen with preferrential attachment using built-in Networks extension to initialize-network ;each upperclassman has at least 5 friends nw:generate-preferential-attachment students friendships (num-students * 3 / 4) 5 ask students [ set freshman? false set group-types-wanted get-two-types ; put student in a group that is of one of the types he wants set group one-of organizations with [ member? (item 0 [group-types-wanted] of myself) group-types or member? (item 1 [group-types-wanted] of myself) group-types ] set happy? true set total-groups-recruited-for 1 ] end ;; The recruit procedure, that returns true if the student is accepted in org, false otherwise ;; Calls the recruit-freshman? or recruit-upperclassman? procedure depending on the year of the student ;; student procedure to-report recruit? [ org ] ifelse freshman? [ report recruit-freshman? org ] [ report recruit-upperclassman? org ] end ;; Freshman recruit procedure, returns true if the student is accepted in org, false otherwise ;; student procedure to-report recruit-freshman? [ org ] ; can only try to recruit if not exceeded limit let total-members-in-org count students with [group != nobody and [name] of group = [name] of org] if total-members-in-org >= group-recruitment-limit [ report false ] ifelse total-groups-recruited-for < student-recruit-limit [ set total-groups-recruited-for total-groups-recruited-for + 1 let x 0 ;x represents # of group types wanted by student that are also in the group type of the selected organization let y 0 ;y represents total # of group types wanted by student foreach group-types-wanted [ g-type -> if member? g-type [group-types] of org [ set x x + 1 ] set y y + 1 ] ;;once student has recruited for the max number of groups, he has a 50% chance of joining the group if there is no fit- desperation if total-groups-recruited-for = student-recruit-limit and x = 0[ set x 1 set y 2 ] ifelse random 100 < x / y * 100 [ report true ] [ report false ] ] [ report false ] end ;; Upperclassman recruit procedure, returns true if the student is accepted in org, false otherwise ;; student procedure to-report recruit-upperclassman? [ org ] let num-friends-in-org count friendship-neighbors with [group != nobody and [name] of group = [name] of org] let total-members-in-org count students with [group != nobody and [name] of group = [name] of org] if total-members-in-org >= group-recruitment-limit [ report false ] if total-groups-recruited-for > student-recruit-limit [ report false ] ;if you have an intersecting interest, you will join the group as an upperclassmen with 75% probability; or if you know more than threshold% of the group foreach group-types-wanted [ g-type -> if member? g-type [group-types] of org and random 100 < 75[ report true ] ] ifelse num-friends-in-org / total-members-in-org * 100 > group-friendship-threshold-% [ report true ] [ report false ] end ;; Initializes a new class of freshmen, with no friends or organization to initialize-freshmen create-students num-students / 4 [ set freshman? true set happy? false set total-groups-recruited-for 0 set group nobody set group-types-wanted get-two-types ] end ;; Sets the color and shape of the students based on their year and group affiliations to colorize ask students [ ifelse freshman? [ set shape "default" ] [ set shape "circle" ] ] ask students with [group = nobody ] [ set color white ] ask students with [group != nobody] [ (cf:ifelse [name] of group = "ISBE" [ set color red ] [name] of group = "Sig Nu" [ set color green ] [name] of group = "EPIC" [ set color violet ] [name] of group = "MCSA" [ set color yellow ] [name] of group = "Alpha Phi" [ set color pink ] [name] of group = "IEEE" [ set color cyan ] [name] of group = "Formula" [ set color orange ] [name] of group = "SASA" [ set color brown ] ) ] end ;; Sets the happy? parameter of each student as true/false at the end of the year to tabulate-happiness ask students [ ifelse group = nobody [ ;;unhappy if in no group set happy? false ] [ ;unhappy if in a group with no interests in common let interests-in-common 0 foreach group-types-wanted [ g-type -> if member? g-type [group-types] of group [ set interests-in-common interests-in-common + 1 ] ] ifelse interests-in-common = 0 [ ; if no interests in common, can still be happy if many friends in the group let num-friends-in-same-group count friendship-neighbors with [group != nobody and [name] of group = [name] of [group] of myself] let total-members-my-org count students with [group != nobody and [name] of group = [name] of [group] of myself] ifelse num-friends-in-same-group / total-members-my-org * 100 < group-friendship-threshold-% [ set happy? false ] [ set happy? true ] ] [ set happy? true ] ] ] end ;; Network visualization procedure to layout repeat 30 [ layout-spring students with [freshman? = false] friendships 0.2 5 1 layout-circle students with [freshman? = true] 10 display ] end ;; Called at the end of the year- seniors graduate, freshmen become upperclassmen, students drop groups if unhappy, and new class of freshmen initialized to next-year ;;33% of upperclassmen graduate (upperclasmen = soph, jun, sen)- only seniors graduate ask n-of (25 / 100 * num-students) students with [freshman? = false] [ die ] ask students with [freshman? = true] [ set freshman? false ] ask students [ if happy? = false [ if group != nobody [ ask group [ set drops-in-year drops-in-year + 1 ] set group nobody ] ] ] initialize-freshmen colorize layout end ;; Resets drops-in-year of each organization to 0 so can be retabulated for the following year to reset-drops-in-yr ask organizations [ set drops-in-year 0 ] end ;; Returns a list of 2 group-types based on the relative distribution of interests (sliders) to-report get-two-types ;The 2 types may be the same, just means that the particular student is very keen on that type of group let type1 get-one-type let type2 get-one-type report (list type1 type2) end ;; Returns 1 group type based on the relative distribution of interests (sliders) to-report get-one-type let type-probabilities (list cultural-interest engineering-interest greek-interest business-interest) report random-weighted all-types type-probabilities end ;; Returns one element from values list based on the weighted probabilities list weights ;; Source: http://netlogo-users.18673.x6.nabble.com/Using-list-distribution-as-a-probability-function-td4867966.html to-report random-weighted [values weights] let selector (random-float sum weights) let running-sum 0 (foreach values weights [ [a b] -> set running-sum (running-sum + b) if (running-sum > selector) [ report a ] ]) end ;; UNIT TESTS ;; Unit test for random-weighted ;; Takes in an input of 3 weights, reports the distribution of 100 actual values produced by calling the random-weighted function, which should reflect the inputed weights ;; If the sum of input weights is 100, output values will be approximately the same as input, otherwise output will reflect the distribution in a population of 100 to-report test-random-weighted [ weights ] let out [] repeat 100 [ set out lput (random-weighted [ "a" "b" "c"] weights) out ] let num-a 0 let num-b 0 let num-c 0 (foreach out [ x -> (cf:ifelse x = "a" [ set num-a num-a + 1 ] x = "b" [ set num-b num-b + 1 ] x = "c" [ set num-c num-c + 1 ] )]) report (list num-a num-b num-c) end ;; Unit test #1 for recruitment ;; Tests that both freshmen and upperclassmen who have exceeded their recruitment limit do not join the group ;; Reports true if the recruitment procedures are working accordingly, false otherwise to-report test-recruitment-1 clear-all set all-types ["cultural" "engineering" "greek" "business"] set student-recruit-limit 10 ;; all students initialized having exceeded their recruitment limit, with overlapping interest with the group create-students 50 [ set label "test" set freshman? true set happy? false set total-groups-recruited-for 20 set group nobody set group-types-wanted [ "engineering" "greek" ] ] create-students 50 [ set label "test" set freshman? false set happy? false set total-groups-recruited-for 20 set group nobody set group-types-wanted [ "engineering" "greek" ] ] ;; No students in the group initially, so group recruitment limit will not be triggered create-organizations 1 [ set name "test-group" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] ;; if any student gets in, means the recruit function is not working let rep true ask students with [label = "test"] [ if (recruit? (one-of organizations with [name = "test-group"])) = true [ set rep false ] ] report rep end ;; Unit test #2 for recruitment ;; Tests that both freshmen and upperclassmen are rejected by a group that has reached its recruitment capacity ;; Reports true if the recruitment procedures are working accordingly, false otherwise to-report test-recruitment-2 clear-all set all-types ["cultural" "engineering" "greek" "business"] set group-recruitment-limit 10 create-organizations 1 [ set name "test-group" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] ;; initialize the group with 10 members, the limit create-students 10 [ set label "test" set freshman? false set happy? true set total-groups-recruited-for 1 set group one-of organizations with [name = "test-group"] set group-types-wanted get-two-types ] create-students 50 [ set label "test" set freshman? true set happy? false set total-groups-recruited-for 0 set group nobody set group-types-wanted get-two-types ] create-students 50 [ set label "test" set freshman? false set happy? false set total-groups-recruited-for 0 set group nobody set group-types-wanted get-two-types ] ;; if any student gets in, means the recruit function is not working let rep true ask students with [label = "test"] [ if (recruit? (one-of organizations with [name = "test-group"])) = true [ set rep false ] ] report rep end ;; Unit test #3 for recruitment ;; Tests that a freshman with no interest in a group does not join the group ;; Reports true if the recruitment procedures are working accordingly, false otherwise to-report test-recruitment-3 clear-all set all-types ["cultural" "engineering" "greek" "business"] create-students 1 [ set label "test" set freshman? true set happy? false set total-groups-recruited-for 0 set group nobody set group-types-wanted ["cultural" "greek"] ] create-organizations 1 [ set name "test-group" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] ;; if this student gets in, means the recruit function is not working let rep false ask one-of students with [label = "test"] [ ifelse (recruit? (one-of organizations with [name = "test-group"])) = true [ set rep false ] [ set rep true] ] report rep end ;; Unit test #4 for recruitment ;; Confirms that upperclassmen join group if they are friends with more than group-friendship-threshold-% of the members ;; Reports true if the recruitment procedures are working accordingly, false otherwise to-report test-recruitment-4 clear-all set all-types ["cultural" "engineering" "greek" "business"] set group-friendship-threshold-% 25 let temp group-recruitment-limit set group-recruitment-limit 200 create-organizations 1 [ set name "test-group" set hidden? true set group-types ["engineering"] set drops-in-year 0 ] ;; create upperclassman with no overlapping interest create-students 1 [ set label "test" set freshman? false set happy? false set total-groups-recruited-for 0 set group nobody set group-types-wanted ["cultural" "greek"] ] ;; 30 students in the group who are friends with the test student create-students 30 [ set freshman? false set happy? false set total-groups-recruited-for 1 set group one-of organizations with [name = "test-group"] create-friendship-with one-of students with [label = "test"] ] ;; 70 students in the group who are not friends with the test student create-students 70 [ set freshman? false set happy? false set total-groups-recruited-for 1 set group one-of organizations with [name = "test-group"] ] ;; if this student does not get in, means the recruit function is not working, since he is frinds with more than threshold% of students in the group let rep false ask one-of students with [label = "test"] [ print recruit? (one-of organizations with [name = "test-group"]) if (recruit? (one-of organizations with [name = "test-group"])) = true [ set rep true ] ] set group-recruitment-limit temp report rep end
There is only one version of this model, created over 6 years ago by Rohaan Advani.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Northwestern Group Dynamics.png | preview | Preview for 'Northwestern Group Dynamics' | over 6 years ago, by Rohaan Advani | Download |
This model does not have any ancestors.
This model does not have any descendants.