Alexandra Scudo Katia Sette

Simulation models for economics

Project work on

"Indirect cooperation in a Kibbutz."

 

The applet requires Java 1.4.1 or higher. It will not run on Windows 95 or Mac OS 8 or 9. Mac users must have OS X 10.2.6 or higher and use a browser that supports Java 1.4. (Safari works, IE does not. Mac OS X comes with Safari. Open Safari and set it as your default web browser under Safari/Preferences/General.) On other operating systems, you may obtain the latest Java plugin from Sun's Java site.


An introduction to the simulation model.


powered by NetLogo

view/download model file: indirect_cooperation_in_a_kibbutz.nlogo

WHAT IS IT?

Our model simulates a Kibbutz, a collective based village in Israel, traditionally based on agriculture. Nowadays, the farming activity has been partly supplanted by other economic branches, among which industrial plants and high-tech firms.
In recent decades, many kibbutzim have been privatized and several changes have been implemented in the communal lifestyle.
The aim of the simulation is to study the reasons why kibbutzim may collapse.


HOW IT WORKS

The economy is composed by four sectors that are characterized by different colors: milk production (light blue), education (yellow), health (pink) and household (green). Each sector requires a different level of productivity in order to surive in the economy. There are two kind of agents: opportunists (blue agents) and ideologists (red agents), divided among the four sectors. Each person is characterized by an initial random level of happiness (happiness-yesterday), productivity (initial-productivity) and needs.
When the go button is pressed our agents start to prduce accordingly to their initial level of productivity. Then opportunists compare the average supply of the sector in which they work with their level of needs; weather their needs are satisfied or not they change accordingly their level of happiness. Ideologists, instead, change their level of happiness accordingly to two different models: "Russia" model or "Italy" model. If happiness has increased ideologists increase production by a large amount, while if their level of happiness has decreased they increase the level of production by a small amount. Opportunists, on the other hand, reduce production if their level of happiness has increased while they increase production by a lesser amount if happiness has decreased.
Given the updated level of productivity, we compute the overall productivity of the agents that work in each sector. This level of productivity is compared with the productivity required by the sector. If the productivity of the agents in the sector is higher then the level of productivity required by the sector, agents move to other sectors characterized by an insufficient level of productivity.
The model collapse in two cases: if the average supply is too low (that means that the kibbutz is no longer able to stay on the market) and if individuals that work in the milk sector have a lower level of productivity than the one required by the sector.


HOW TO USE IT

In the beginning by using the slider in the interface of the model we have to choose the number of ideologists and opportunists in the economy and the level of responsiveness of the agents accordingly to breed and level of happiness. We have also to choose the kind of model that we want to run by using the chooser button. The switch button related to the command expel has to be set on the "off" mode.
When the start button is pressed, world is created.
By clicking the go button the simulation starts, and our agents begin to produce.
While the simulation is running we can see what happens if the "expel" command is activated. To stop the simulation it is necessary to press again the go button.

The monitors allow us to see the level of productivity of all the agents that work in a given sector, the average supply and the aggregate supply.

The graphs show the average supply in each sector and the level of happiness and production for ideologists and opportunists.


THINGS TO NOTICE

Our economy can be considered as open because the relationship with the market is mantained through the milk sector. This is the reason why we have set the collapse to occur not only when the average supply is too law (that can be considered as a natural collapse) but also when the milk sector is not able anymore to survive on the market under competitive conditions.
We can say that the milk production sector, because of its features, is the most important one in our economy.


THINGS TO TRY

It can be interesting to see what happens when we modify the number of ideologists and opportunists in the economy. We can also choose the "Russia" or "Italy" model and see what happens in the economiy or we can play with the sliders by changing the level of responsiveness of the agents.


EXTENDING THE MODEL

The model could be extended by adding imitation. What happens in the economy if our agents can imitate their neighbours, or if agents with a higher level of happiness or production are imitaded by other agents?


RELATED MODELS

An interesting and realted model is: "Cooperation", to be found in the Models Library.


CREDITS AND REFERENCES

"Imitation and cooperation in different helping games" by Giangiacomo Bravo, 2008
"Simulating Evolutionary Games: A Python-Based Introduction" by Alan G. Isaac, 2008


PROCEDURES

globals [                                                        ;define the global variables
  average-supply
  average-supply-sector1
  average-supply-sector2
  average-supply-sector3
  average-supply-sector4
  productivity-agents-sector1
  productivity-agents-sector2
  productivity-agents-sector3
  productivity-agents-sector4
  expell
]

breed [ideologists ideologist]                                   ;define two breeds               
breed [opportunists opportunist]

turtles-own [                                                    ;define turtles' charactristics
  production
  initial-productivity
  updated-productivity
  happiness-yesterday
  happiness-today
  needs
  sector-number
  max-size
  min-size
]

patches-own [                                                    ;define patches' characteristics
  n-sector
  required-productivity-to-01                        
  required-productivity-to-00                        
  required-productivity-to-10                        
  required-productivity-to-11                        
  max-color
  min-color
]

to setup                                                         ;world creation with ptaches and turtles positions
  clear-all
  setup-patches
  setup-turtles
  do-plots
end

to setup-patches                                                 ;patches' creation
  setup-colors
  setup-productivity
end

to setup-colors                                                  ;define the color of the patches
   ask patch 0 1                                                 ;first patch                                    
  [set pcolor 45                                                 ;1st patch color
    set n-sector 1                                               ;patch identification
    set max-color 43                                             ;define an interval into which the color of the patch can change                               
    set min-color 48]
   ask patch 0 0                                                 ;second patch
  [set pcolor 65                                                 ;2nd patch color
    set n-sector 2                                               ;patch identification
    set max-color 63                                             ;define an interval into which the color of the patch can change 
    set min-color 68]
  ask patch 1 0                                                  ;third patch
   [set pcolor 135                                               ;3rd patch color
     set n-sector 3                                              ;patch identification
     set max-color 133                                           ;define an interval into which the color of the patch can change 
     set min-color 138]
   ask patch 1 1                                                 ;fourth patch
   [set pcolor 95                                                ;4th patch color
    set n-sector 4                                               ;patch identification
    set max-color 93                                             ;define an interval into which the color of the patch can change 
    set min-color 98 ]
end

to setup-productivity                                                     ;define the level of productivity required by patches                                                     
  ask patch 0 1 [set required-productivity-to-01 (220 + random 390)]      ;productivity required by 1st patch
  ask patch 0 0 [set required-productivity-to-00 (200 + random 300)]      ;productivity required by 2nd patch
  ask patch 1 0 [set required-productivity-to-10 (230 + random 430)]      ;productivity required by 3rd patch
  ask patch 1 1 [set required-productivity-to-11 (230 + random 410)]      ;productivity required by 4th patch
end

to setup-turtles                                                          ;turtles' creation                                                        
  create-ideologists number-ideologists / 4                               ;creation of ideologists divided among the four sectors                             
  [setxy 0 0 right random 360 forward random-float 0.45
    set sector-number n-sector]                                           ;attribution of the number of the sector to turtles
  create-ideologists number-ideologists / 4 
  [setxy 0 1 right random 360 forward random-float 0.45
     set sector-number n-sector]
  create-ideologists number-ideologists / 4
  [setxy 1 0 right random 360 forward random-float 0.45
     set sector-number n-sector]
  create-ideologists number-ideologists / 4 
  [setxy 1 1 right random 360 forward random-float 0.45
     set sector-number n-sector]
  ask ideologists [set shape "person"                                     ;set shape person to ideologists
     set color red ]                                                      ;set color red to ideologists
  
  create-opportunists (84 - number-ideologists) / 4                       ;creation of opportunists divided among the four sectors
  [setxy 0 0 right random 360 forward random-float 0.45
    set sector-number n-sector]                                           ;attribution of the number of the sector to turtles
  create-opportunists (84 - number-ideologists) / 4 
  [setxy 0 1 right random 360 forward random-float 0.45
    set sector-number n-sector]
  create-opportunists (84 - number-ideologists) / 4 
  [setxy 1 0 right random 360 forward random-float 0.45
    set sector-number n-sector]
  create-opportunists (84 - number-ideologists) / 4 
  [setxy 1 1 right random 360 forward random-float 0.45
    set sector-number n-sector]
  ask opportunists [set shape "person"                                    ;set shape person to opportunists
    set color blue ]                                                      ;set color blue to ideologists
  
  ask turtles [set happiness-yesterday random 50                          ;define turtles' yesterday happiness
    set initial-productivity (3 + random 47)]                             ;define turtles' initial productvity
  ask turtles [
    set size 0.10                                                         ;define turtles' size
    set max-size 0.2          
    set min-size 0.08
    set needs (6 + random 10)]                                            ;define turtles' needs
end

to go                                                                     ;model development
  if ticks >= 1700 [stop]                                                 ;if ticks >= 1700 stops the model
  produce
  grow
  change-production
  update-productivity
  compute-sector-productivity
  change-patch
  collapse
  dismiss
  tick
  do-plots
end

to produce                                                                ;define the relation between initial productivity and production
  ask turtles [ifelse initial-productivity <= 25
    [set production (2 + random 7)
      ask patch-here
      [set pcolor (pcolor - 0.002)                                        ;ask the patch under the turtle to become darker
       if pcolor < max-color [set pcolor max-color]]]                     ;if the color of the patch is darker then the max color defined, set the color of the patch equal the max color
    [set production (10 + random 6)
      ask patch-here
      [set pcolor (pcolor - 0.006)                                       
        if pcolor < max-color [set pcolor max-color]]]]
  
set average-supply ((sum [production] of ideologists + sum [production] of opportunists) / (count turtles))
set average-supply-sector1 ((sum [production] of turtles with [sector-number = 1]) / (count turtles with [sector-number = 1]))
set average-supply-sector2 ((sum [production] of turtles with [sector-number = 2]) / (count turtles with [sector-number = 2]))
set average-supply-sector3 ((sum [production] of turtles with [sector-number = 3]) / (count turtles with [sector-number = 3]))
set average-supply-sector4 ((sum [production] of turtles with [sector-number = 4]) / (count turtles with [sector-number = 4]))
end

to grow                                                             ;define how the happiness of the turtles changes
  ask ideologists [if model = "Russia"                              ;first model for ideologists
    [ifelse (sum [production] of turtles with [sector-number = 4]) > (500 - (300 + random 100))  ;we subtruct to 500 a value that is random between 300 and 399
      [set happiness-today (happiness-yesterday + 10)
      set size (size + 0.01)]                                       ;increase the size of ideologists
      [set happiness-today (happiness-yesterday - 10)
      set size (size - 0.01)]]]
  
  ask ideologists [if model = "Italy"                               ;second model for ideologists
    [ifelse average-supply > needs
      [set happiness-today (happiness-yesterday + (7 + random 3))   ;add to yesterday happiness a value between 7 and 9
      set size (size + 0.01)]                                       ;increase the size of ideologists
    [set happiness-today (happiness-yesterday - (7 + random 3))
      set size (size - 0.01)]]]
          
  ask opportunists-on patch 0 1 [ifelse average-supply-sector1 > needs   ;define the change of happiness for opportunists of the 1st patch
    [set happiness-today (happiness-yesterday + (7 + random 3))
      set size (size + 0.01)]
    [set happiness-today (happiness-yesterday - (7 + random 3))
      set size (size - 0.01)]]
  
  ask opportunists-on patch 0 0 [ifelse average-supply-sector2 > needs   ;define the change of happiness for opportunists of the 2nd patch
    [set happiness-today (happiness-yesterday + (7 + random 3))
      set size (size + 0.01)]
    [set happiness-today (happiness-yesterday - (7 + random 3))
      set size (size - 0.01)]]
  
  ask opportunists-on patch 1 0 [ifelse average-supply-sector3 > needs   ;define the change of happiness for opportunists of the 3rd patch
    [set happiness-today (happiness-yesterday + (7 + random 3))
      set size (size + 0.01)]
    [set happiness-today (happiness-yesterday - (7 + random 3))
      set size (size - 0.01)]]
  
  ask opportunists-on patch 1 1 [ifelse average-supply-sector4 > needs   ;define the change of happiness for opportunists of the 4th patch
    [set happiness-today (happiness-yesterday + (7 + random 3))
      set size (size + 0.01)]
    [set happiness-today (happiness-yesterday - (7 + random 3))
      set size (size - 0.01)]]

   ask turtles [if size <= min-size                                      ;if the size of the turtles is lower than the min-size defined, set the size equal the min-size
    [set size min-size]]
  ask turtles [if size >= max-size                                       ;if the size of the turtles is greater than the max-size defined, set the size equal the max-size
    [set size max-size]]
end

to change-production                                                     ;define the relation between happiness and production of turtles
  ask ideologists [ifelse happiness-today > happiness-yesterday
    [set production (production + (responsiveness-id-happy))             ;responsiveness-id-happy is equal to the amount defined by the slider
      ask patch-here
     [set pcolor (pcolor - 0.002)                                        ;ask the patch under the turtle to become darker
       if pcolor < max-color [set pcolor max-color]]]                    ;if the color of the patch is darker then the max color defined, set the color of the patch equal the max color
    [set production (production + (responsiveness-id-sad))
      ask patch-here
     [set pcolor (pcolor - 0.002)                                        
       if pcolor < max-color [set pcolor max-color]]]]
  
   ask opportunists [ifelse happiness-today > happiness-yesterday
    [set production (production + (responsiveness-opp-happy))
      ask patch-here
     [set pcolor (pcolor + 0.002)                                        ;if the color of the patch is lighter then the min color defined, set the color of the patch equal the min color
       if pcolor > min-color [set pcolor min-color]]]
    [set production (production + (responsiveness-opp-sad)) 
      ask patch-here
     [set pcolor (pcolor - 0.002)
       if pcolor < max-color [set pcolor max-color]]]]
   
set average-supply ((sum [production] of ideologists + sum [production] of opportunists) / (count turtles))
set average-supply-sector1 ((sum [production] of turtles with [sector-number = 1]) / (count turtles with [sector-number = 1]))
set average-supply-sector2 ((sum [production] of turtles with [sector-number = 2]) / (count turtles with [sector-number = 2]))
set average-supply-sector3 ((sum [production] of turtles with [sector-number = 3]) / (count turtles with [sector-number = 3]))
set average-supply-sector4 ((sum [production] of turtles with [sector-number = 4]) / (count turtles with [sector-number = 4]))
end

to update-productivity                                                   ;define the relation between production and new productivity
  ask ideologists [ifelse production <= 18
    [set updated-productivity (initial-productivity + (-5 + random 3))]  ;initial productivity decreases within an interval between -5 and -3
    [set updated-productivity (initial-productivity + ( 1 + random 7))]  ;initial productivity incerases within an interval between 1 and 7
  ]
  
  ask opportunists [ifelse production <= 18
    [set updated-productivity (initial-productivity + (-12 + random 7))] ;initial productivity decreases within an interval between -12 and -6
    [set updated-productivity (initial-productivity + (  1 + random 4))] ;initial productivity increases within an interval between 1 and 4
  ]
end

to compute-sector-productivity                                           ;define the productivity from agents of a sector
  ask turtles [
  set productivity-agents-sector1 (sum [updated-productivity] of turtles with [sector-number = 1])
  set productivity-agents-sector2 (sum [updated-productivity] of turtles with [sector-number = 2])
  set productivity-agents-sector3 (sum [updated-productivity] of turtles with [sector-number = 3])
  set productivity-agents-sector4 (sum [updated-productivity] of turtles with [sector-number = 4])
  ]
end

to change-patch                                                         ;define the dynamics of the model
  ask turtles with [updated-productivity < 20 and sector-number = 1]
  [if (productivity-agents-sector1 > required-productivity-to-01)
    [move-to patch 1 0 right random 360 forward random-float 0.45       ;turtles of the first sector move to the third
      set sector-number 3]]
  ask turtles with [updated-productivity < 20 and sector-number = 2]
  [if (productivity-agents-sector2 > required-productivity-to-00)
    [move-to patch 1 1 right random 360 forward random-float 0.45       ;turtles of the secod sector move to the forth
      set sector-number 4]]
  ask turtles with [updated-productivity < 20 and sector-number = 3]
  [if (productivity-agents-sector3 > required-productivity-to-10)
    [move-to patch 0 1 right random 360 forward random-float 0.45       ;turtles of the third sector move to the first
      set sector-number 1]]
  ask turtles with [updated-productivity < 20 and sector-number = 4]
  [if (productivity-agents-sector4 > required-productivity-to-11)       
    [move-to patch 0 0 right random 360 forward random-float 0.45       ;turtles of the forth sector move to the second
      set sector-number 2]]
end

to collapse                                                             ;first way to collapse
   if average-supply <= 10
  [ tick-advance 1600                                                   ;advance the tick counter by 1600
    ask patches [set pcolor black]
    ask turtles [wait 0.03                                              ;ask the turtles to wait a given number of seconds
      set happiness-yesterday 0
      set happiness-today 0
      set needs 0
      set initial-productivity 0
      set updated-productivity 0
      set production 0
      set productivity-agents-sector1 0
      set productivity-agents-sector2 0
      set productivity-agents-sector3 0
      set productivity-agents-sector4 0]]
  
  if ticks >= 1700 [stop]
end
    
to dismiss                                                             ;second way to collapse
  if expell?
   [ask patch 1 1 [if productivity-agents-sector4 < required-productivity-to-11
    [set pcolor black
    ask turtles with [sector-number = 4]
    [hide-turtle
     set productivity-agents-sector4 0
    ask turtles with [sector-number = 1] [
      set happiness-yesterday 0
      set happiness-today 0
      set needs 0
      set initial-productivity 0
      set updated-productivity 0
      set production 0
      set productivity-agents-sector1 0
    ask turtles with [sector-number = 2] [
      set happiness-yesterday 0
      set happiness-today 0
      set needs 0
      set initial-productivity 0
      set updated-productivity 0
      set production 0
      set productivity-agents-sector2 0
    ask turtles with [sector-number = 3] [
      set happiness-yesterday 0
      set happiness-today 0
      set needs 0
      set initial-productivity 0
      set updated-productivity 0
      set production 0
      set productivity-agents-sector3 0]]]]]]]
end

to do-plots
  set-current-plot "happiness"
  set-current-plot-pen "ideol-happiness"
  plot (( sum [happiness-today] of ideologists ) / (count ideologists))
  set-current-plot-pen "opport-happiness"
  plot ((sum [happiness-today] of opportunists ) / (count opportunists))
  if average-supply <= 10 [clear-plot]
  
  set-current-plot "production"
  set-current-plot-pen "ideol-production"
  plot (( sum [production] of ideologists ) / (count ideologists))
  set-current-plot-pen "opport-production"
  plot (( sum [production] of opportunists ) / (count opportunists))
  if average-supply <= 10 [clear-plot]

  set-current-plot "average-sup-sect1"
  set-current-plot-pen "supply1"
  plot average-supply-sector1
  if average-supply <= 10 [clear-plot]
  
    set-current-plot "average-sup-sect2"
  set-current-plot-pen "supply2"
  plot average-supply-sector2
  if average-supply <= 10 [clear-plot]
  
  set-current-plot "average-sup-sect3"
  set-current-plot-pen "supply3"
  plot average-supply-sector3
  if average-supply <= 10 [clear-plot]
  
  set-current-plot "average-sup-sect4"
  set-current-plot-pen "supply4"
  plot average-supply-sector4
  if productivity-agents-sector4 = 0 [clear-plot]
  if average-supply <= 10 [clear-plot]
end