Single Club-Type Model

No preview image

1 collaborator

Default-person Sarah Reibstein (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model Reibstein_Sarah_Project
Model group EECS 372-Spring 2011 | Visible to everyone | Changeable by the author
Model was written in NetLogo 4.1.2 • Viewed 185 times • Downloaded 14 times • Run 0 times
Download the 'Single Club-Type Model ' modelDownload this modelEmbed this model

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


WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

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

Click to Run Model

breed [anchors anchor]
breed [people person]
breed [clubs club]

globals [
  center-anchor
  goals-met
  goals-missed
  mean-age
]

people-own [
  income  ;; monthly income
  goal-size  ;; how much money a turtle would like to accumulate
  goal-time  ;; how long a turtle has to accumulate the money
  goal-time-unrounded
  contribution ;; how much the turtle will contribute this tick
  accomplished-goal? ;; when club has finished its rounds, true if this turtle has met its savings goal
]

clubs-own [
  monthly-contribution  ;; how much individuals put in monthly
  members  ;; how many members are in the group
  money  ;; how much money is in the pot
  desired-members  ;; how many members the group can hold
  status ;; whether the club is full or not full
  ticks-at-start ;; value of tick counter when club started saving
  lifespan
]

to setup
  ca
  ; Create the center node anchor
    create-anchors 1 [
      set shape "circle"
      set color black
    ]
   ; This is a convenience variable that points to the center anchor
    set center-anchor one-of anchors
  create-people population
  set-default-shape people "person"
  set-default-shape clubs "circle"
  ask people [
    setxy random-xcor random-ycor
    set income random-normal mean-income income-variance 
    set goal-size random-normal mean-goal-size 10
    set goal-time-unrounded random-normal mean-goal-time goal-time-variance
    set goal-time round goal-time-unrounded
    if goal-time = 0 [
      die]
    set contribution 0
  ] 
 set goals-met 0
 set goals-missed 0
end 

to go
  ;; someone who is not currently in a club creates a club
  make-club
  ;; if there are any open clubs, someone who is not in a closed club decides whether or not to join one. Five people are asked this.
  ask people [ maybe-join]
  ;; if a club has been abandoned, it disappears
  ask clubs [
    if count my-links = 0 [
      die 
     ]
    ] 
   ;; visualization
    ask clubs [
      repeat 30 [
      layout-spring link-neighbors my-links .2 2 .5
      ]
     ]
    layout-spring clubs ( [my-links] of center-anchor ) .2 14 .5     
  tick  
  ;; if a club is full, run saving procedures
  ask clubs[
    if status = "full" [
     save
    ] 
  ]
  set mean-age mean [ticks - ticks-at-start] of clubs with [status = "full"]
  update-plots   
end 

;; a person who is not in a club creates a club

to make-club 
  if any? people with [count my-links = 0] [
    ask one-of people with [count my-links = 0] [
      create-saving-up] 
  ]
end 

to create-saving-up 
  ;; a club is created 2 spaces north of its creator, colored yellow
  ask patch-here [
    let creator myself
    sprout-clubs 1 [
      ifelse [ycor] of creator <= 14 
      [
        setxy [xcor] of creator [ycor] of creator + 2]
      [
        setxy [xcor] of creator [ycor] of creator - 2]
      set color yellow
      set size 1.3
      set lifespan " "
      ;; set monthly contribution such that expected payout in goal-time months = goal-size
      set monthly-contribution [goal-size] of creator / ([goal-time] of creator * (1 - risk))
      ;; the club's desired membership is its creator's goal-time rounded up 
      set desired-members [ceiling goal-time] of creator
      ;; initially, the club is not full
      set status "not-full"
      ;; the creator becomes the club's first member
      create-link-with creator
    ]
  ]
end 

to maybe-join 
  ask clubs [
    set members count my-links  ;; update members variable
    if members = desired-members 
    [
      set status "full"]
  ]
  if any? clubs with  [status = "not-full" ]  ;; if any open clubs remain
  [
    let open-club one-of clubs with [status = "not-full"]  ;; choose an open club to look at
    ;; if there is a person not already in a closed club, whose characteristics match this open club, join it (create link, kill other links)
    
    if any? people with [ count link-neighbors with [status = "full"] = 0 and 
                             (([desired-members] of open-club) * ([monthly-contribution] of open-club) * (1 - risk) >= goal-size) and 
                             ([desired-members] of open-club >= goal-time) ] 
    [
       ask one-of people with [ count link-neighbors with [status = "full"] = 0 and 
                             (([desired-members] of open-club) * ([monthly-contribution] of open-club) * (1 - risk) >= goal-size) and 
                             ([desired-members] of open-club >= goal-time) ] 
      [
       ask my-links 
       [
        die]
       create-link-with open-club
    ]
      ]                         
    ask open-club 
    [
     set members count my-links  ;; update members variable
     if members = desired-members 
     [
      set status "full"
      set ticks-at-start ticks]  
    ]
  ]
end 

to save
    ;; each member contributes 0 "risk"% of the time and "monthly-contribution" (1-"risk")% of the time
      ask link-neighbors [
        ifelse random-float 1 < risk 
        [
          set contribution 0]
        [
          set contribution [monthly-contribution] of myself]
      ]
    ;; money in the club increases by the amount of its members contributions
    set money money + sum [contribution] of link-neighbors
    ;; visually show money in club
    set label round money 
    set label-color black
    ;; when there have been as many ticks as there are members, divide up the money 
    if (ticks - ticks-at-start) mod members = 0 and (ticks != ticks-at-start) 
    [
     split-prize]
end 

to split-prize
  ;; set prize equal to money in the club divided by number of members
  let prize (money / members)
  ;; if the prize is >= goal size, goal is accomplished and stay in the club
  ;;if the prize is < goal size, goal is not accomplished and leave the club
  ask link-neighbors [
   ifelse [prize] of myself >= goal-size 
   [
    set accomplished-goal? true
    set goals-met goals-met + 1] 
   [
    set accomplished-goal? false
    set goals-missed goals-missed + 1
    ask my-links
    [
     die]
    ]]
  set members count my-links
  if members < desired-members 
  [
   set status "not-full" ]
   set money 0
   set label " " 
end 

to update-plots
  set-current-plot "plot 1"
  set-current-plot-pen "#-closed-clubs"
  plot count clubs with [status = "full"]
  set-current-plot-pen "mean-age"
  plot mean-age
  set-current-plot-pen "mean-size"
  plot mean [members] of clubs with [status = "full"]
  set-current-plot "plot 2"
  set-current-plot-pen "goals-met"
  plot goals-met
  set-current-plot-pen "goals-missed"
  plot goals-missed
end 
  

There is only one version of this model, created about 13 years ago by Sarah Reibstein.

Attached files

No files

Parent: Reibstein_Sarah_Project

This model does not have any descendants.

Graph of models related to 'Single Club-Type Model '