Sugarscape_Seasonal_Migration_mv

No preview image

1 collaborator

20160405_001940000_ios Hendra Kusumah (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.3.0 • Viewed 122 times • Downloaded 9 times • Run 0 times
Download the 'Sugarscape_Seasonal_Migration_mv' 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 third model in the NetLogo Sugarscape suite implements Epstein & Axtell's Sugarscape Wealth Distribution model, as described in chapter 2 of their book Growing Artificial Societies: Social Science from the Bottom Up. It provides a ground-up simulation of inequality in wealth. Only a minority of the population have above average wealth, while most agents have wealth near the same level as the initial endowment.

The inequity of the resulting distribution can be described graphically by the Lorenz curve and quantitatively by the Gini coefficient.

HOW IT WORKS

Each patch contains some sugar, the maximum amount of which is predetermined. At each tick, each patch regains one unit of sugar, until it reaches the maximum amount. The amount of sugar a patch currently contains is indicated by its color; the darker the yellow, the more sugar.

At setup, agents are placed at random within the world. Each agent can only see a certain distance horizontally and vertically. At each tick, each agent will move to the nearest unoccupied location within their vision range with the most sugar, and collect all the sugar there. If its current location has as much or more sugar than any unoccupied location it can see, it will stay put.

Agents also use (and thus lose) a certain amount of sugar each tick, based on their metabolism rates. If an agent runs out of sugar, it dies.

Each agent also has a maximum age, which is assigned randomly from the range 60 to 100 ticks. When the agent reaches an age beyond its maximum age, it dies.

Whenever an agent dies (either from starvation or old age), a new randomly initialized agent is created somewhere in the world; hence, in this model the global population count stays constant.

HOW TO USE IT

The INITIAL-POPULATION slider sets how many agents are in the world.

The MINIMUM-SUGAR-ENDOWMENT and MAXIMUM-SUGAR-ENDOWMENT sliders set the initial amount of sugar ("wealth") each agent has when it hatches. The actual value is randomly chosen from the given range.

Press SETUP to populate the world with agents and import the sugar map data. GO will run the simulation continuously, while GO ONCE will run one tick.

The VISUALIZATION chooser gives different visualization options and may be changed while the GO button is pressed. When NO-VISUALIZATION is selected all the agents will be red. When COLOR-AGENTS-BY-VISION is selected the agents with the longest vision will be darkest and, similarly, when COLOR-AGENTS-BY-METABOLISM is selected the agents with the lowest metabolism will be darkest.

The WEALTH-DISTRIBUTION histogram on the right shows the distribution of wealth.

The LORENZ CURVE plot shows what percent of the wealth is held by what percent of the population, and the the GINI-INDEX V. TIME plot shows a measure of the inequity of the distribution over time. A GINI-INDEX of 0 equates to everyone having the exact same amount of wealth (collected sugar), and a GINI-INDEX of 1 equates to the most skewed wealth distribution possible, where a single person has all the sugar, and no one else has any.

THINGS TO NOTICE

After running the model for a while, the wealth distribution histogram shows that there are many more agents with low wealth than agents with high wealth.

Some agents will have less than the minimum initial wealth (MINIMUM-SUGAR-ENDOWMENT), if the minimum initial wealth was greater than 0.

THINGS TO TRY

How does the initial population affect the wealth distribution? How long does it take for the skewed distribution to emerge?

How is the wealth distribution affected when you change the initial endowments of wealth?

NETLOGO FEATURES

All of the Sugarscape models create the world by using file-read to import data from an external file, sugar-map.txt. This file defines both the initial and the maximum sugar value for each patch in the world.

Since agents cannot see diagonally we cannot use in-radius to find the patches in the agents' vision. Instead, we use at-points.

RELATED MODELS

Other models in the NetLogo Sugarscape suite include:

  • Sugarscape 1 Immediate Growback
  • Sugarscape 2 Constant Growback

For more explanation of the Lorenz curve and the Gini index, see the Info tab of the Wealth Distribution model. (That model is also based on Epstein and Axtell's Sugarscape model, but more loosely.)

CREDITS AND REFERENCES

Epstein, J. and Axtell, R. (1996). Growing Artificial Societies: Social Science from the Bottom Up. Washington, D.C.: Brookings Institution Press.

HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:

COPYRIGHT AND LICENSE

Copyright 2009 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 https://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.

Comments and Questions

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

Click to Run Model

extensions [matrix]
globals [
  gini-index-reserve
  lorenz-points
  winter? ;;variable para el invierno
  duraciontotal ;; duracion del invierno
]
;; posibles agregados: enfermedades contagiosas, prediposición a enfermarse tomando en cuenta un metabolismo que no es satisfecha
;; ECT diabetes, prediabetes, normal -> tortugas profesionales de la salud; distribución de recursos y herencia
;; azucar limitar los recursos; azucar contaminada
;; accidentes; azucar se contamine siempre y cuando haya muchas tortugas alrededor
;; cuando la tortuga consume azucar genera deshecho
turtles-own [
  sugar           ;; the amount of sugar this turtle has
  metabolism      ;; the amount of sugar that each turtles loses each tick
  vision          ;; the distance that this turtle can see in the horizontal and vertical directions
  vision-points   ;; the points that this turtle can see in relative to it's current position (based on vision)
  age             ;; the current age of this turtle (in ticks)
  max-age         ;; the age at which this turtle will die of natural causes
]

patches-own [
  psugar           ;; the amount of sugar on this patch
  max-psugar       ;; the maximum amount of sugar that can be on this patch
]

;;
;; Setup Procedures
;;

to setup
  if maximum-sugar-endowment <= minimum-sugar-endowment [
    user-message "Oops: the maximum-sugar-endowment must be larger than the minimum-sugar-endowment"
    stop
  ]
  clear-all
  create-turtles initial-population [ turtle-setup ]
  setup-patches


  update-lorenz-and-gini
  set winter? true ;;indica si es true que hay invierno en el hemisferio norte (y verano en el sur)
  set duraciontotal 40 ;;indica cuantos ticks dura el invierno/verano
  reset-ticks
end 

to turtle-setup ;; turtle procedure
  set color red
  set shape "turtle"
  ;move-to one-of patches with [not any? other turtles-here]
  set sugar random-in-range minimum-sugar-endowment maximum-sugar-endowment
  set metabolism random-in-range 1 4
  set max-age random-in-range 60 100
  set age 0
  set vision random-in-range 1 10
  ;; turtles can look horizontally and vertically up to vision patches
  ;; but cannot look diagonally at all
  set vision-points []
  foreach (range 1 (vision + 1)) [ n ->
    set vision-points sentence vision-points (list (list 0 n) (list n 0) (list 0 (- n)) (list (- n) 0))
  ]
  move-to one-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 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
  let i 0
  let j 0
  ;let m1 matrix:transpose m
  let rowx 49
  repeat 50 [ repeat 50
              [
      let row-i matrix:get-row m i
      ask patches with [pxcor = i and pycor = j] [set max-psugar item rowx row-i
                set psugar max-psugar
                patch-recolor
                ]
               set rowx rowx - 1
               set j j + 1
              ]
    set i i + 1
    set j 0
  set rowx 49]

  ;ask patches [patch-recolor]
  ;file-open "sugar-map.txt"
  ;foreach sort patches [ p ->
  ;  ask p [
  ;    set max-psugar file-read
  ;    set psugar max-psugar
  ;    patch-recolor
  ;  ]
  ;]
  ;file-close
end 

;;
;; Runtime Procedures
;;

to go
  if not any? turtles [
    stop
  ]
  ask patches [
    ;pregunto si hay invierno
    ifelse (estaciones? = true)
    [
     ifelse (winter? = true)
     [ifelse (pxcor + 48 = pycor * -1) or (pxcor * -1 + 48 = pycor) and (pxcor > pycor * -1 + 48) or (pxcor * -1 + 48 > pycor)
       [patch-growbackwinter]
       [patch-growback]
     ]
     [ifelse (pxcor + 48 = pycor * -1) or (pxcor * -1 + 48 = pycor) and (pxcor > pycor * -1 + 48) or (pxcor * -1 + 48 > pycor)
       [patch-growback]
       [patch-growbackwinter]
     ]

    ]
     [patch-growbacknormal
    ]
    patch-recolor
  ]
  ask turtles [
    turtle-move
    turtle-eat
    set age (age + 1)
    if sugar <= 0 ;or age > max-age
    [
      ;hatch 1 [ turtle-setup ]
      die
    ]
    run visualization
  ]
  update-lorenz-and-gini
  ;;invierno y verano

  if (ticks mod duraciontotal = 0)
     [ifelse (winter? = true)
        [set winter? false]
        [set winter? true]
     ]

  tick
end 

to turtle-move ;; turtle procedure
  ;; consider moving to unoccupied patches in our vision, as well as staying at the current patch
  let move-candidates (patch-set patch-here (patches at-points vision-points) with [not any? turtles-here])
  let possible-winners move-candidates with-max [psugar]
  if any? possible-winners [
    ;; if there are any such patches move to one of the patches that is closest
    move-to min-one-of possible-winners [distance myself]
  ]
end 

to turtle-eat ;; turtle procedure
  ;; metabolize some sugar, and eat all the sugar on the current patch
  set sugar (sugar - metabolism + psugar)
  set psugar 0
end 

to patch-recolor ;; patch procedure
  ;; color patches based on the amount of sugar they have
  if psugar < 0
  [set psugar 0]
  set pcolor (yellow + 4.9 - psugar)
end 

to patch-growbacknormal ;; patch procedure
  ;; gradually grow back all of the sugar for the patch, en el original decía 1 en vez de 0.5
  set psugar min (list max-psugar (psugar + 0.5))
end 

to patch-growback ;; patch procedure
  ;; gradually grow back all of the sugar for the patch
  set psugar min (list max-psugar (psugar + 1))
end 
;;agrego crecimiento invernal

to patch-growbackwinter ;; patch procedure
  ;; gradually grow back all of the sugar for the patch
  set psugar min (list max-psugar (psugar + (1 / 8)))
end 

to update-lorenz-and-gini
  let num-people count turtles
  let sorted-wealths sort [sugar] of turtles
  let total-wealth sum sorted-wealths
  let wealth-sum-so-far 0
  let index 0
  set gini-index-reserve 0
  set lorenz-points []
  repeat num-people [
    set wealth-sum-so-far (wealth-sum-so-far + item index sorted-wealths)
    set lorenz-points lput ((wealth-sum-so-far / total-wealth) * 100) lorenz-points
    set index (index + 1)
    set gini-index-reserve
      gini-index-reserve +
      (index / num-people) -
      (wealth-sum-so-far / total-wealth)
  ]
end 

;;
;; Utilities
;;

to-report random-in-range [low high]
  report low + random (high - low + 1)
end 

;;
;; Visualization Procedures
;;

to no-visualization ;; turtle procedure
  set color red
end 

to color-agents-by-vision ;; turtle procedure
  set color red - (vision - 3.5)
end 

to color-agents-by-metabolism ;; turtle procedure
  set color red + (metabolism - 2.5)
end 


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

There is only one version of this model, created over 1 year ago by Hendra Kusumah.

Attached files

No files

Parent: Sugarscape Seasonal Migration

This model does not have any descendants.

Graph of models related to 'Sugarscape_Seasonal_Migration_mv'