Marta Bruschi Michele Demichelis Alberto Fierro

Simulation models for economics

Project work on

"Cooperation vs. greed."

 

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.


Here you can find an introduction to the Cooperation vs. greed application.


powered by NetLogo

view/download model file: cooperation_vs._greed.nlogo

WHAT IS IT?

We model a society with three types of people: cooperative citizens, greedy citizens and stealers. The first two groups try to defend themselves from the third. We investigate how the difference in behaviour (cooperative or not) affects aggregate income.

HOW IT WORKS

The two groups of citizens have income which is given according to a normal distribution. Then cooperative citizens tax themselves, and with the revenues pay policemen (chosen among low income profiles in their group). Greedy citizens buy weapons, but not everyone can afford the expense. Both groups then invest their net incomes in the financial markets. Stealers take citizen’s income with a certain probability, this depends on weapons and on the presence of policemen in the neighbourhood.
Stealers can reproduce exceeded a certain amount of robbery, but the threshold increases exponentially with the amount of stealers. When stealers meet cops they loose the booty, which will be counted as aggregate income for cooperative citizens.

HOW TO USE IT

Press Setup button:
- incomes are distributed, cooperative citizens below a threshold become cops
- weapons are buyed and tax collected
Press Go button:
- agents start moving and stealers take others income with a certain probability

THINGS TO NOTICE

Important variables:
-Aggregatecit = measures invested income of cooperative citizens plus wage of cops and booty seized to stealers
-Aggregreedy = measures invested income of greedy citizens
-Aggregaterobberycit= amount of robbery stolen to cooperative citizens
-Aggregaterobberygreed = amount of robbery stolen to greedy citizens

Changes in these variables allow to understand which group is facing better the threat of stealers.

THINGS TO TRY

Sliders:
- Amount of cooperative and greedy citizens can be changed, as also the number of stealers.
- Mean value and standard deviation of the normal distribution of incomes. Interest rates at which citizens invest.
-Price of weapons: a fixed cost component as also a marginal cost component.
-Thresholds: the one under which cooperative citizens become cops and the one above which stealers reproduce themselves.

EXTENDING THE MODEL

In order to make our inferences more applicable to reality, an implementation could be rethinking the entire model introducing values for the parameters closer to empiric ones. Our last experiment is just a first attempt in this direction. For example we could introduce microlevel data, describing places and daily activities of individuals, in order to represent their usual habits of movements.

CODE


breed [stealers stealer]
breed [cops cop]
breed [greedy-citizens greedy-citizen]
breed [friendly-citizens friendly-citizen]


globals [ farest-stealer victim aggrecit collectedtax aggregaterobberycit aggregaterobberygreed aggregreedy aggregatetreasure aggregaterobbery aggregatewage  price reproduction-threshold  ]

friendly-citizens-own [initincome tax netincome income]
greedy-citizens-own [initincome netincomeg incomeg] ;; price e total-stealers non "appartengono" ai greedy citizens, come toglierle?
stealers-own [robberycit robberygreed robbery netincome netincomeg income incomeg]
cops-own [initincome netincome wage   income tax treasure]

to setup
  clear-all
  setup-stealers
  setup-friendly-citizens
  setup-greedy-citizens
  setup-cops
 
  set aggrecit sum [income] of friendly-citizens 
  set aggregaterobberycit sum [robberycit] of stealers
  set aggregaterobberygreed sum [robberygreed] of stealers
  set aggregaterobbery sum [robbery] of stealers
  set aggregreedy sum [incomeg] of greedy-citizens
  set aggregatewage sum [wage] of cops
  set collectedtax sum [tax] of friendly-citizens
  set reproduction-threshold intercept-reproduction
  ask patches [ set pcolor white ]
  reset-ticks
end

to setup-stealers
  set-default-shape stealers "wolf"
  create-stealers number-stealers [set color black setxy random-xcor random-ycor]
  
  ask stealers
  [set robberycit 0
    set robberygreed 0
    
    ]
  
end



to setup-friendly-citizens
  set-default-shape friendly-citizens "person"
  create-friendly-citizens number-friendly-citizens [ set color red 
    setxy random-xcor random-ycor
     ]
  ask friendly-citizens 
  [set initincome random-normal value-mean value-deviation
  set tax trate * initincome
  set netincome (initincome - tax)
  set income  netincome
  ]
  
end

to setup-greedy-citizens
  set-default-shape greedy-citizens "person"
  create-greedy-citizens number-greedy-citizens [ set color blue 
    setxy random-xcor random-ycor
     ]
  
  ask greedy-citizens
  [set initincome random-normal value-mean value-deviation  
 
  set price  number-stealers * initcost + number-stealers * marginalcost
  set netincomeg (initincome - price)
  ifelse netincomeg > 0
  [set incomeg netincomeg]
  [set incomeg initincome] 
  
  
  
  ] ;; provare differenziare robbery
 
end

to setup-cops 
   ask friendly-citizens 
   [ifelse initincome <= copthreshold
    [set breed cops
      set color green
      setxy random-xcor random-ycor
      set wage income
      set treasure 0
      ] 
    [set breed friendly-citizens]
    
   ]
   
end

to go
  ask turtles
  [move-turtles]
  ask friendly-citizens
  [invest-cit]
  ask greedy-citizens
  [invest-greedy]
  ask cops
  [invest-cop]
  ask stealers[
   steal
   reproduce]
  update-variables
  if all? greedy-citizens [incomeg = 0] or all? friendly-citizens [income = 0]
  [stop]
 
  
   tick
end

to move-turtles
   right random 360
    forward 1 
end

to invest-cop
 set wage wage + collectedtax / count cops
 
end

to invest-cit
  set income income + income * interestfriendly - (income * interestfriendly) * trate
  set tax (income * interestfriendly) * trate
  
end

to invest-greedy
  set price count stealers * marginalcost
  ifelse incomeg > 0
  [set incomeg incomeg + incomeg * interestgreedy - (price)]
  [set incomeg 0]
end

to steal
  set victim max-one-of turtles [distance myself] 
 
 ask victim 
 [ set farest-stealer max-one-of stealers [distance myself]
   ask farest-stealer 
   
     [if [breed] of myself = greedy-citizens
        
       
      [if sum [count cops] of neighbors4 >= 1 and [netincomeg] of myself >= 0
        [ifelse random-float 1.0 <= 0.3
         [set robberygreed robberygreed + [incomeg] of myself
           ask victim
          [set incomeg 0]
          ]
         [set robberygreed robberygreed]]
         
       
      if sum [count cops] of neighbors4 < 1 and [netincomeg] of myself >= 0
        
        [ifelse random-float 1.0 <= 0.7
         [set robberygreed robberygreed + [incomeg] of myself
           ask victim
          [set incomeg 0]
          ]
        [set robberygreed robberygreed]]
        
       
      if sum [count cops] of neighbors4 >= 1 and [netincomeg] of myself < 0
      
      [ifelse random-float 1.0 <= 0.5
        [set robberygreed robberygreed + [incomeg] of myself
          ask victim
          [set incomeg 0]
          ]
        [set robberygreed robberygreed]]
      
      
       if sum [count cops] of neighbors4 < 1 and [netincomeg] of myself < 0
      
      [ifelse random-float 1.0 <= 0.9
        [set robberygreed robberygreed + [incomeg] of myself
          
          ask victim
          [set incomeg 0]
          ]
        [set robberygreed robberygreed]]
      ]
      
       
      
     if [breed] of myself = friendly-citizens
      
     [if sum [count cops] of neighbors4 >= 1 
       
       [ifelse random-float 1.0 <= 0.5
        [set robberycit robberycit + [income] of myself 
          ask victim 
          [set income 0]]
        [set robberycit robberycit]]
       
       if sum [count cops] of neighbors4 < 1 
        
        [ifelse random-float 1.0 <= 0.9
         [set robberycit robberycit + [income] of myself
           
           ask victim
          [set income 0]
          ]
        [set robberycit robberycit]
        ]]
        
    if [breed] of myself = cops
   [ ask victim
    [ set treasure treasure + [robberycit] of myself + [robberygreed] of myself
      set wage wage + treasure
      ask farest-stealer
      [set robberycit 0
      set robberygreed 0]]
    
    
    
 ]
 ]
 ]

 
end
  
 
 
to reproduce

  if robberygreed >= reproduction-threshold or robberycit >= reproduction-threshold
  [  hatch 1 
    [lt 45 fd 1]
    ]
end
     
   



to update-variables
  set aggrecit sum [income] of friendly-citizens
  print aggrecit
  set aggregreedy sum [incomeg] of greedy-citizens
  print aggregreedy
  set aggregatetreasure sum [treasure] of cops
  print aggregatetreasure
  set collectedtax  sum [tax] of friendly-citizens
  print collectedtax
  set aggregaterobberycit sum [robberycit] of stealers
  print aggregaterobberycit
  set aggregaterobberygreed sum [robberygreed] of stealers
  print aggregaterobberygreed
  set aggregaterobbery aggregaterobberygreed + aggregaterobberycit
  print aggregaterobbery
  set aggregatewage sum [wage] of cops
  print aggregatewage
  
  
  ifelse count stealers >= number-friendly-citizens 
  [set reproduction-threshold exp((count stealers)^ 0.5) - exp((count stealers)^ 0.10)]
  [set reproduction-threshold intercept-reproduction]
  end