Andrea Gallo Rosso

Simulation models for economics

Project work on

"Tragedy of commons."

 

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Oracle's Java site.


powered by NetLogo

view/download model file: tragedy_of_commons.nlogo

WHAT IS IT

The model represents two fields in 19th’s century England, before the industrial revolution. Three sheep farmers [A, B, C] pastures their animals [blue, gray, red]. Each of them wants to put the most of sheep as possible. They (in the model) start placing a fixed number of animals, sharing them out between the two fields. Sheep can reproduce, eat grass and die (if they don’t find enough grass).
When a farmer become “important” enough (i.e. he has much more sheep than any other farmer) he can enclose the field and chase away sheep that he does not own.

HOW TO USE IT

SPLITTING: You can share sheep of a farmer between the two fields.

REPRODUCTION SHEEP: It is the probability of a sheep reproducing at each time step (only in INTERACTION_OFF - read on)

GROWTH GRASS FIELD: How long it takes for grass to regrow once it is eaten.

INTERACTION —
Off: Sheep reproduce independently of other animals;
On: We suppose the sheep be very, very, prolific. The farmer can place in the field only few animals, according to the percentage of sheep he has and his ARROGANCE.

ACTIVE SIMULATION —
Off: Model go on as long as you want.
On: When the percentage of sheep of a farmer reach the QUOTA FOR APPROPRIATION, he encloses the field. The sheep of another color go in the adjoining field or die.

HOW IT WORKS

The model starts with a fixed number of sheep, shared between two fields. At each tick sheep wander randomly, using their energy. If a sheep arrives on a “patch of grass” it eats and increases its energy. If the energy is 0, the sheep dies. If INTERACTION is OFF, sheep can reproduce according to the growth-tax REPRODUCTION SHEEP. If INTERACTION in ON, sheep “born” when they have a place in the field.

The formula used in INTERACTION_ON is:

Probability of maintaining a sheep = ARROGANCE * no. of sheep / total amount of sheep

NOTE: When the probability is >1 (considering that it does not exist) in the model it is actually 1.

CREDITS AND REFERENCES

Julia Schindler (2012)
Rethinking the Tragedy of the Commons: The Integration of Socio-Psychological Dispositions
Journal of Artificial Societies and Social Simulation 15 (1) 4
http://jasss.soc.surrey.ac.uk/15/1/4.html

CODE

breed [a1]
breed [a2]
breed [b1]
breed [b2]
breed [c1]
breed [c2]
globals [ po1 po2 ]
;; -_-_-_-_-_-_-_-_-_-_-_-_-_- SETUP -_-_-_-_-_-_-_-_-_-_-_-_-_-

to Setup
  clear-all
  initial
  setup-patches
  setup-turtles
  reset-ticks
  ask patches with [ pxcor = 0 ][ set pcolor yellow]
end

to setup-patches
  ask patches [ set pcolor green ]
end

to initial
  set po1 1
  set po2 1
end

to setup-turtles
  create-a1 Splitting_A [ set shape "sheep" set color blue ]
  ask a1 [ setxy random-xcor random-ycor
    if xcor > 0 [ set xcor xcor - max-pxcor ] 
    if int(xcor) = 0 [ set xcor -1 ] ]
  
  create-a2 (Ewes_A - Splitting_A) [ set shape "sheep" set color blue ]
  ask a2 [ setxy random-xcor random-ycor
    if xcor < 0 [ set xcor xcor + max-pxcor ] 
    if int(xcor) = 0 [ set xcor 1 ] ]
  
  create-b1 Splitting_B [ set shape "sheep" set color grey ]
  ask b1 [ setxy random-xcor random-ycor
    if xcor > 0 [ set xcor xcor - max-pxcor ] 
    if int(xcor) = 0 [ set xcor -1 ] ]

  create-b2 (Ewes_B - Splitting_B) [ set shape "sheep" set color grey ]
  ask b2 [ setxy random-xcor random-ycor
    if xcor < 0 [ set xcor xcor + max-pxcor ] 
    if int(xcor) = 0 [ set xcor 1 ] ]

  create-c1 Splitting_C [ set shape "sheep" set color red ]
  ask c1 [ setxy random-xcor random-ycor
    if xcor > 0 [ set xcor xcor - max-pxcor ] 
    if int(xcor) = 0 [ set xcor -1 ] ]
  
  create-c2 (Ewes_C - Splitting_C) [ set shape "sheep" set color red ]
  ask c2 [ setxy random-xcor random-ycor
    if xcor < 0 [ set xcor xcor + max-pxcor ] 
    if int(xcor) = 0 [ set xcor 1 ] ]
end

;; _-_-_-_-_-_-_-_-_-_-_-_- END SETUP -_-_-_-_-_-_-_-_-_-_-_-_

turtles-own[energy]
;; _-_-_-_-_-_-_-_-_-_-_-_-_-_- GO -_-_-_-_-_-_-_-_-_-_-_-_-_-_

to go
  move-turtles
  eat-grass
  reproduce
  check-death
  regrow-grass
  tick
end

to move-turtles
  ask turtles [
    right random 360
    forward 1
    set energy energy - 1
  ]
  ask a1 [ if xcor >= 0 [ set xcor (xcor - max-pxcor)]]
  ask a2 [ if xcor <= 0 [ set xcor (xcor + max-pxcor)]]
  ask b1 [ if xcor >= 0 [ set xcor (xcor - max-pxcor)]]
  ask b2 [ if xcor <= 0 [ set xcor (xcor + max-pxcor)]]
  ask c1 [ if xcor >= 0 [ set xcor (xcor - max-pxcor)]]
  ask c2 [ if xcor <= 0 [ set xcor (xcor + max-pxcor)]]
end

to eat-grass
  ask turtles [
    if pcolor = green [
      set pcolor lime - 3
      set energy energy + 10
    ]
  ]
  if Active_simulation [
    if po1 = 1
    [ if ( count a1 / (count a1 + count b1 + count c1 ) ) * 100 >= Quota_for_appropriation [
        if po2 = 1 [
        create-b2 (count b1) [ set shape "sheep" set color grey ]
        create-c2 (count c1) [ set shape "sheep" set color red ]
        ]
        ask b1 [die]
        ask c1 [die]
        output-print "A encloses field 1!"
        set po1 0
        ]
    
      if ( count b1 / (count a1 + count b1 + count c1 ) ) * 100 >= Quota_for_appropriation [
        if po2 = 1 [
        create-a2 (count a1) [ set shape "sheep" set color blue ]
        create-c2 (count c1) [ set shape "sheep" set color red ]
        ]
        ask a1 [die]
        ask c1 [die]
        output-print "B encloses field 1!"
        set po1 0
        ]
      
      if ( count c1 / (count a1 + count b1 + count c1 ) ) * 100 >= Quota_for_appropriation [
        if po2 = 1 [
        create-b2 (count b1) [ set shape "sheep" set color grey ]
        create-a2 (count a1) [ set shape "sheep" set color blue ]
        ]
        ask b1 [die]
        ask a1 [die]
        output-print "C encloses field 1!"
        set po1 0
        ]
    ]
    
    if po2 = 1 [
      if ( count a2 / (count a2 + count b2 + count c2 ) ) * 100 >= Quota_for_appropriation [
        if po1 = 1 [
        create-b1 (count b2) [ set shape "sheep" set color grey ]
        create-c1 (count c2) [ set shape "sheep" set color red ]
        ]
        ask b2 [die]
        ask c2 [die]
        output-print "A encloses field 2!"
        set po2 0
        ]
      
      if ( count b2 / (count a2 + count b2 + count c2 ) ) * 100 >= Quota_for_appropriation [
        if po1 = 1 [
        create-a1 (count a2) [ set shape "sheep" set color blue ]
        create-c1 (count c2) [ set shape "sheep" set color red ]
        ]
        ask a2 [die]
        ask c2 [die]
        output-print "B encloses field 2!"
        set po2 0
        ]
      
      if ( count c2 / (count a2 + count b2 + count c2 ) ) * 100 >= Quota_for_appropriation [
        if po1 = 1 [
        create-b1 (count b2) [ set shape "sheep" set color grey ]
        create-a1 (count a2) [ set shape "sheep" set color red ]
        ]
        ask b2 [die]
        ask a2 [die]
        output-print "C encloses field 2!"
        set po2 0
        ]
    ]
  ]

end    

to reproduce
  ifelse Interaction [
  ask a1 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_A * ( count a1 / (count a1 + count b1 + count c1 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]
  
  ask a2 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_A * (count a2 / (count a2 + count b2 + count c2 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]

  ask b1 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_B * ( count b1 / (count a1 + count b1 + count c1 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]

  ask b2 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_B * (count b2 / (count a2 + count b2 + count c2 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]

  ask c1 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_C * ( count c1 / (count a1 + count b1 + count c1 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]

  ask c2 [
    if energy > 50 [
    if random-float 1 < ( Arrogance_C * (count c2 / (count a2 + count b2 + count c2 ) ) ) [
      hatch 1 [ set energy 50 ]
      set energy energy - 50
    ]
    ]
  ]
  ]
  
[
    ask turtles [
      if random 100 < Reproduction_sheep [
        hatch 1 [ set energy 50 ]
      set energy energy - 50
      ]
    ]
  ]
end

to check-death
  ask turtles [
    if energy <= 0 [ die ]
  ]
end

to regrow-grass
  ask patches [
    if pxcor < 0 [
    if random 100 < Growth_grass_field_1 [ set pcolor green ]
  ]
    if pxcor > 0 [
      if random 100 < Growth_grass_field_2 [set pcolor green ]
    ]
  ]
end