Tragedy of the Commons HubNet

Tragedy of the Commons HubNet preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

game 

Tagged by Mahlon Kupferschmid about 5 years ago

hubnet 

Tagged by Reuven M. Lerner about 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0beta1 • Viewed 948 times • Downloaded 72 times • Run 0 times
Download the 'Tragedy of the Commons HubNet' 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 model simulates the utilization of a common resource by multiple users. In this example, the common resource is represented by the common grazing area, used by goat farmers to feed their goats. Depending on the actions of the participants, the outcome may demonstrate a phenomenon called the "tragedy of the commons", where a common good or resource is over-utilized.

This is a counterexample to the efficient (as defined in "Pareto efficiency") market theorem. (The efficient market theorem states that agents, looking out for their own best interest [i.e., everyone trying to increase their own wealth], leads to the most efficient social outcome [i.e., the highest quantity of milk].)

HOW IT WORKS

The students act as the farmers. They own INIT-NUM-GOATS/FARMER when they join the simulation.

The goats move around the screen for a time span of GRAZING-PERIOD to graze and feed themselves. The amount of grass they eat is equivalent to how much milk they can produce (and ultimately, the amount of profit they produce for the farmer).

After the GRAZING-PERIOD, the farmers may choose to buy more goats to increase their own wealth.

Initially, the abundance of GRASS-SUPPLY of the patches can sustain the goats and their grazing and leads to increasing milk-supply and increasing revenue. But suppose, then, that due to the farmers' own incentive to increase their own wealth and each farmer's indifference to the other farmers' decision to purchase goats, each farmer continues to buy more goats. With the increase of the GOAT-POPULATION, GRASS-SUPPLY gradually decreases. Ultimately, the common grazing area does not contain enough grass to sustain the overcrowding of goats, and the milk-supply as well as the farmers' revenues decline. This is the "tragedy of the commons".

HOW TO USE IT

Quickstart Instructions:

Teacher: Follow these directions to run the HubNet activity. Optional: Zoom In (see Tools in the Menu Bar) Optional: Change any of the settings. If you do change the settings, press the SETUP button. Press the LOGIN button to allow people to login. Everyone: Open up a HubNet Client on your machine and enter your name, select this activity, and press ENTER.

Teacher: Once everyone has logged in, turn off the LOGIN button by pressing it again. Have the students acquaint themselves with the various information available to them in the monitors, buttons, and sliders. Then press the GO button to start the simulation. Please note that you may adjust the length of time, GRAZING-PERIOD, that goats allowed to graze each day. For a quicker demonstration, reduce the GRASS-GROWTH-RATE slider. To curb buying incentives of the students, increase the COST/GOAT slider. Any of the above mentioned parameters - GRAZING-PERIOD, GRASS-GROWTH-RATE, and COST/GOAT - may be altered without stopping the simulation.

Teacher: To run the activity again with the same group, stop the model by pressing the GO button, if it is on. Change any of the settings that you would like. Press the SETUP button. Restart the simulation by pressing the GO button.

Teacher: To start the simulation over with a new group, stop the model by pressing the GO button if it is on, press the RESET button in the Control Center to kick out all the clients and follow these instructions again from the beginning.

Buttons:

SETUP - returns all farmers, goats, and patches to initial condition and clears the plot. LOGIN - allows users to log into the activity without running the model or collecting data GO - runs the simulation

Sliders:

INIT-NUM-GOATS/FARMER - initial number of goats per farmer at the beginning of the simulation GRASS-GROWTH-RATE - amount of grass growth for each tick of the clock COST/GOAT - cost for a goat GRAZING-PERIOD - the time frame in which goats are allowed to graze each day

Monitors:

GRASS SUPPLY - amount of grass available to eat MILK SUPPLY - amount of milk produced each day AVG-PROFIT/DAY - amount of revenue collected from milk sale per day GOAT POPULATION - number of goats grazing in the common area

Plots:

GRASS SUPPLY - amount of grass available to graze upon over time (in days) MILK SUPPLY - amount of milk produced over time (in days) AVERAGE REVENUE - average revenue of all farmers over time (in days) GOAT POPULATION - number of goats on grazing field over time (in days)

Client Information

After logging in, the client interface will appear for the students, and if GO is pressed in NetLogo, they will be assigned a farmer which will be described by the color in the MY GOAT COLOR monitor. The MY GOAT POPULATION monitor will display the number of goats each student owns. Their revenue for the last day will be displayed in the CURRENT REVENUE monitor and their total assets in the TOTAL ASSETS monitor.

The global Cost per Goat can be viewed in the COST PER GOAT monitor. The performance of the society, measured by the amount of grass available for food and the amount of milk produced can be measured from the GRASS AMT and MILK AMT monitors, respectively. The current day, a day being defined as one grazing period followed by a milking session, is displayed in the DAY monitor.

The student manages his/her goat population. During the course of each grazing period, the student must decide what action to take for the day, whether to buy or to discard some goats. To buy or to discard goats, the student must adjust NUM-GOATS-TO-BUY slider to his/her desired quantity. At the end of the day, the specified transaction will be executed automatically. The transaction of the purchase will be described in the GOAT SELLER SAYS: monitor, which will inform the client of the action taken and how many goats were purchased, if any.

The progress of the community's welfare as measured by the grass available for grazing, average revenue of farmers, and milk supply is plotted in the GRASS SUPPLY, AVERAGE REVENUE, and MILK SUPPLY plots (if present), which are each identical to the plot of the same name in NetLogo.

THINGS TO NOTICE

Note that if the students do not confer with each other, the tragedy of the commons arises. The general patterns of the plots for average revenue and milk supply are similar -- the curves eventually peak and are followed by a decrease. After the initial run, ask the students which parameters helped them to decide to purchase or not purchase goats. Ask the students to switch objectives for the simulation; instead of maximizing total-assets, ask them to maximize milk-supply. Also, ask the students to confer and act as cooperative unit.

THINGS TO TRY

Use the model with the entire class to serve as an introduction to the topic. Upon running the initial set of simulations, ask the students to switch objective - instead of maximizing their own total-assets, ask them to maximize milk-supply for the entire community. Ask the students to confer and act as a cooperative unit. Observe and discuss the changes in AVG-REV/FARMER and MILK-SUPPLY from the initial simulation and the later simulation with altered objectives. Continue to discuss how the "Tragedy of the Commons" can be avoided and why or why not a society would want to avoid this phenomenon. Then, have students use the NetLogo model individually, in a computer lab, to explore the effects of the various parameters. Discuss what they find, observe, and can conclude from this model.

EXTENDING THE MODEL

Is there other information about the state of the simulation that the farmers might want access to? Do you think this would change the outcome of the simulation? From what other phenomena (e.g. prisoner's dilemma or free-rider problem) would the student's behavior to not sell the goats arise (if it arises)?

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

COPYRIGHT AND LICENSE

Copyright 2002 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

This activity and associated models and materials were created as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227.

Comments and Questions

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

Click to Run Model

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Variable and Breed declarations ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

globals
[
  day                ;; number of days so far

  colors             ;; list that holds the colors used for students' turtles
  color-names        ;; list that holds the names of the colors used for
                     ;; students' turtles
  num-colors         ;; number of colors in the color list
  used-colors        ;; list that holds the shape-color pairs that are
                     ;; already being used

  n/a                ;; unset variable indicator

  ;; quick start instructions variables
  quick-start        ;; current quickstart instruction displayed in the
                     ;; quickstart monitor
  qs-item            ;; index of the current quickstart instruction
  qs-items           ;; list of quickstart instructions

  grass-max          ;; grass capacity
  food-max           ;; grass collection capacity
  bite-size          ;; amount of grass collected at each move
]

patches-own
[
  grass-stored       ;; amount of grass currently stored
]

breed [ goats goat ]  ;; creation controlled by farmers
breed [ farmers farmer ] ;; created and controlled by clients


goats-own
[
  food-stored        ;; amount of grass collected from grazing
  owner#             ;; the user-id of the farmer who owns the goat
]

farmers-own
[
  user-id            ;; unique user-id, input by the client when they log in,
                     ;; to identify each student turtle
  num-goats-to-buy   ;; desired quantity of goats to purchase
  revenue-lst        ;; list of each days' revenue collection
  total-assets       ;; total of past revenue, minus expenses
  current-revenue    ;; the revenue collected at the end of the last day
]


;;;;;;;;;;;;;;;;;;;;;
;; Setup Functions ;;
;;;;;;;;;;;;;;;;;;;;;

to startup
  setup-quick-start
  hubnet-reset
  setup
end 

;; initializes the display
;; but does not clear already created farmers

to setup
  setup-globals
  setup-patches
  clear-output
  clear-all-plots
  ask farmers
    [ reset-farmers-vars ]
  hubnet-broadcast "Goat Seller Says:"
    (word "Everyone starts with " init-num-goats/farmer " goats.")
  hubnet-broadcast "num-goats-to-buy" 1
  broadcast-system-info
end 

;; initialize global variables

to setup-globals
  reset-ticks
  set day 0

  set grass-max 50
  set food-max 50
  ;; why this particular calculation?
  set bite-size (round (100 / (grazing-period - 1)))

  set colors      [ white   gray   orange   brown    yellow    turquoise
                    cyan    sky    blue     violet   magenta   pink ]
  set color-names ["white" "gray" "orange" "brown"  "yellow"  "turquoise"
                   "cyan"  "sky"  "blue"   "violet" "magenta" "pink"]
  set used-colors []
  set num-colors length colors
  set n/a "n/a"
end 

;; initialize grass supply for each patch

to setup-patches
  ask patches
  [
    ;; set amount of food at each patch
    set grass-stored grass-max
    color-patches
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;
;; Runtime Functions ;;
;;;;;;;;;;;;;;;;;;;;;;;

to go
  ;; get command and data from client
  listen-to-clients

  every .1
  [
    every .5
      [ broadcast-system-info ]

    if not any? farmers
    [
      user-message word "There are no farmers.  GO is stopping.  "
          "Press GO again when people have logged in."
      stop
    ]

    tick

    ;; when not milking time
    ifelse (ticks mod grazing-period) != 0
    [
      ask goats
        [ graze ]
    ]
    [
      set day day + 1
      ask farmers
        [ milk-goats ]
      go-to-market ;; to buy goats
      plot-graph
    ]

    reset-patches
  ]
end 

;; goat move along the common looking for best patch of grass

to graze  ;; goat procedure
  if (food-stored != food-max) or (other goats-here = nobody)
  [
    let new-food-amt (food-stored + get-amt-eaten)
    ifelse (new-food-amt < food-max)
      [ set food-stored new-food-amt ]
      [ set food-stored food-max ]
  ]
  rt (random-float 90)
  lt (random-float 90)
  fd 1
end 

;; returns amount of grass eaten at patch and
;; sets the patch grass amount accordingly

to-report get-amt-eaten  ;; goat procedure
  let reduced-amt (grass-stored - bite-size)
  ifelse (reduced-amt < 0)
  [
    set grass-stored 0
    report grass-stored
  ]
  [
    set grass-stored reduced-amt
    report bite-size
  ]
end 

;; collect milk and sells them at market ($1 = 1 gallon)

to milk-goats  ;; farmer procedure
  set current-revenue
    (round-to-place (sum [food-stored] of my-goats) 10)
  ask my-goats
    [ set food-stored 0 ]
  set revenue-lst (fput current-revenue revenue-lst)
  set total-assets total-assets + current-revenue
  send-personal-info
end 

;; the goat market setup

to go-to-market
  ask farmers
  [
    if num-goats-to-buy > 0
      [ buy-goats num-goats-to-buy ]
    if num-goats-to-buy < 0
      [ lose-goats (- num-goats-to-buy) ]
    if num-goats-to-buy = 0
      [ hubnet-send user-id "Goat Seller Says:" "You did not buy any goats." ]
    send-personal-info
  ]
end 

;; farmers buy goats at market

to buy-goats [ num-goats-desired ]  ;; farmer procedure
  let got-number-desired? true
  let num-goats-afford (int (total-assets / cost/goat))
  let num-goats-purchase num-goats-desired
  if (num-goats-afford < num-goats-purchase)
  [
    set num-goats-purchase num-goats-afford
    set got-number-desired? false
  ]
  let cost-of-purchase num-goats-purchase * cost/goat
  set total-assets (total-assets - cost-of-purchase)
  hubnet-send user-id "Goat Seller Says:"
    (seller-says got-number-desired? num-goats-desired num-goats-purchase)

  ;; create the goats purchased by the farmer
  hatch num-goats-purchase
    [ setup-goats user-id ]
end 

;; farmers eliminate some of their goats (with no gain in assets)

to lose-goats [ num-to-lose ]  ;; farmer procedure
  if ((count my-goats) < num-to-lose)
    [ set num-to-lose (count my-goats) ]
  hubnet-send user-id "Goat Seller Says:"
    (word "You lost " num-to-lose " goats.")

  ;; eliminate the goats ditched by the farmer
  ask (n-of num-to-lose my-goats)
    [ die ]
end 

;; reports the appropriate information on the transaction of purchasing goats

to-report seller-says [ success? desired purchased ]
  let seller-message ""
  let cost purchased * cost/goat
  ifelse success?
  [
    ifelse (purchased > 1)
      [ set seller-message (word "Here are your " purchased " goats.  ") ]
      [ set seller-message "Here is your goat.  " ]
    set seller-message (word seller-message "You have spent $" cost ".")
  ]
  [
    set seller-message (word "You do not have enough to buy " desired ".  "
      "You can afford " purchased " for $" cost ".")
  ]
  report seller-message
end 

;; initializes goat variables

to setup-goats [ farmer# ]  ;; turtle procedure
  set breed goats
  setxy random-xcor random-ycor
  set shape "goat"
  set food-stored 0
  set owner# farmer#
  st
end 

;; updates patches' color and increase grass supply with growth rate

to reset-patches
  ask patches with [grass-stored < grass-max]
  [
    let new-grass-amt (grass-stored + grass-growth-rate)
    ifelse (new-grass-amt > grass-max)
      [ set grass-stored grass-max ]
      [ set grass-stored new-grass-amt ]
    color-patches
  ]
end 

;; colors patches according to amount of grass on the patch

to color-patches  ;; patch procedure
  set pcolor (scale-color green grass-stored -5 (2 * grass-max))
end 


;;;;;;;;;;;;;;;;;;;;;;;;
;; Plotting Functions ;;
;;;;;;;;;;;;;;;;;;;;;;;;

;; plots the graph of the system

to plot-graph
  plot-value "Milk Supply" milk-supply
  plot-value "Grass Supply" grass-supply
  plot-value "Goat Population" count goats
  plot-value "Average Revenue" avg-revenue
end 

;; plot value on the plot called name-of-plot

to plot-value [ name-of-plot value ]
  set-current-plot name-of-plot
  plot value
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Calculation Functions ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report milk-supply
  ;; we can just compute this from revenue, since the price of milk is
  ;; fixed at $1/1 gallon.
  report sum [ current-revenue ] of farmers
end 

to-report grass-supply
  report sum [ grass-stored ] of patches
end 

to-report avg-revenue
  report mean [ current-revenue ] of farmers
end 

;; returns agentset that of goats of a particular farmer

to-report my-goats  ;; farmer procedure
  report goats with [ owner# = [user-id] of myself ]
end 

;; rounds given number to certain decimal-place

to-report round-to-place [ num decimal-place ]
  report (round (num * decimal-place)) / decimal-place
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Quick Start functions ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; instructions to quickly setup the model, and clients to run this activity

to setup-quick-start
  set qs-item 0
  set qs-items
  [
    "Teacher: Follow these directions to run the HubNet activity."
      "Optional: Zoom In (see Tools in the Menu Bar)"
      "Optional: Change any of the settings...."
      "If you do change the settings, press the SETUP button."
      "Press the LOGIN button to allow people to login."
      "Everyone: Open up a HubNet Client on your machine and..."
        "type your user name, select this activity and press ENTER."

    "Teacher: Once everyone has logged in,..."
        "turn off the LOGIN button by pressing it again."
      "Have the students acquaint themselves with the information..."
        "available to them in the monitors, buttons, and sliders."
      "Then press the GO button to start the simulation."
      "Please note that you may adjust the length of time..."
        "GRAZING-PERIOD, that goats are allowed to graze each day."
      "For a quicker demonstration, reduce the..."
        "GRASS-GROWTH-RATE slider."
      "To curb buying incentives of the students, increase..."
        "the COST/GOAT slider."
      "Any of the above mentioned parameters - ..."
        "GRAZING-PERIOD, GRASS-GROWTH-RATE, and COST/GOAT -..."
        "may be altered without stopping the simulation."

    "Teacher: To run the activity again with the same group,..."
        "stop the model by pressing the GO button, if it is on."
        "Change any of the settings that you would like."
      "Press the SETUP button."

    "Teacher: Restart the simulation by pressing the GO button again."

    "Teacher: To start the simulation over with a new group,..."
        "stop the model by pressing the GO button if it is on..."
        "press the RESET button in the Control Center"
        "and follow these instructions again from the beginning."
  ]
  set quick-start (item qs-item qs-items)
end 

;; view the next item in the quickstart monitor

to view-next
  set qs-item qs-item + 1
  if qs-item >= length qs-items
    [ set qs-item length qs-items - 1 ]
  set quick-start (item qs-item qs-items)
end 

;; view the previous item in the quickstart monitor

to view-prev
  set qs-item qs-item - 1
  if qs-item < 0
    [ set qs-item 0 ]
  set quick-start (item qs-item qs-items)
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Code for interacting with the clients ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; determines which client sent a command, and what the command was

to listen-to-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [
      create-new-farmer hubnet-message-source
    ]
    [
      ifelse hubnet-exit-message?
        [ remove-farmer hubnet-message-source ]
        [ execute-command hubnet-message-tag ]
    ]
  ]
end 

;; NetLogo knows what each student turtle is supposed to be
;; doing based on the tag sent by the node:
;; num-goats-to-buy - determine quantity of student's desired purchase

to execute-command [command]
  if command = "num-goats-to-buy"
  [
    ask farmers with [user-id = hubnet-message-source]
      [ set num-goats-to-buy hubnet-message ]
    stop
  ]
end 

to create-new-farmer [ id ]
  create-farmers 1
  [
    set user-id id
    setup-farm
    set-unique-color
    reset-farmers-vars
    hubnet-send id "num-goats-to-buy" num-goats-to-buy
    send-system-info
  ]
end 

;; situates the farmer in particular location

to setup-farm  ;; farmer procedure
  setxy ((random-float (world-width - 2)) + min-pxcor + 1)
        ((random-float (world-height - 2)) + min-pycor + 1)
  ht
end 

;; pick a color for the turtle

to set-unique-color  ;; turtle procedure
  let code random num-colors
  while [member? code used-colors and count farmers < num-colors]
    [ set code random num-colors ]
  set used-colors (lput code used-colors)
  set color item code colors
end 

;; set farmer variables to initial values

to reset-farmers-vars  ;; farmer procedure
  ;; reset the farmer variable to initial values
  set revenue-lst []
  set num-goats-to-buy 1
  set total-assets cost/goat
  set current-revenue 0

  ;; get rid of existing goats
  ask my-goats
    [ die ]

  ;; create new goats for the farmer
  hatch init-num-goats/farmer
    [ setup-goats user-id ]

  send-personal-info
end 

;; sends the appropriate monitor information back to the client

to send-personal-info  ;; farmer procedure
  hubnet-send user-id "My Goat Color" (color->string color)
  hubnet-send user-id "Current Revenue" current-revenue
  hubnet-send user-id "Total Assets" total-assets
  hubnet-send user-id "My Goat Population" count my-goats
end 

;; returns string version of color name

to-report color->string [ color-value ]
  report item (position color-value colors) color-names
end 

;; sends the appropriate monitor information back to one client

to send-system-info  ;; farmer procedure
  hubnet-send user-id "Milk Amt" milk-supply
  hubnet-send user-id "Grass Amt" grass-supply
  hubnet-send user-id "Cost per Goat" cost/goat
  hubnet-send user-id "Day" day
end 

;; broadcasts the appropriate monitor information back to all clients

to broadcast-system-info
  hubnet-broadcast "Milk Amt" milk-supply
  hubnet-broadcast "Grass Amt" (int grass-supply)
  hubnet-broadcast "Cost per Goat" cost/goat
  hubnet-broadcast "Day" day
end 

;; delete farmers once client has exited

to remove-farmer [ id ]
  let old-color 0
  ask farmers with [user-id = id]
  [
    set old-color color
    ask my-goats
      [ die ]
    die
  ]
  if not any? farmers with [color = old-color]
    [ set used-colors remove (position old-color colors) used-colors ]
end 


; Copyright 2002 Uri Wilensky.
; See Info tab for full copyright and license.

There are 7 versions of this model.

Uploaded by When Description Download
Uri Wilensky almost 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 11 years ago Updated version tag Download this version
Uri Wilensky over 11 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 12 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky almost 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky almost 14 years ago Tragedy of the Commons HubNet Download this version
Uri Wilensky almost 14 years ago Tragedy of the Commons HubNet Download this version

Attached files

File Type Description Last updated
Tragedy of the Commons HubNet.png preview Preview for 'Tragedy of the Commons HubNet' about 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.