healthy and nonhealthy food choice

healthy and nonhealthy food choice preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Tags

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.4.0 • Viewed 697 times • Downloaded 46 times • Run 0 times
Download the 'healthy and nonhealthy food choice' 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 attempts to simulate food consumption. Agents evaluate two kinds of food (healthy and unhealthy) at different prices (more healthy then more expensive) with a fixed budget for each agent. There are some stores in the world that sell food that are healthy and unhealthy. Healthy food stores are colored green, and unhealthy food stores are colored red. Each agent has a metabolism threshold that triggers the need to search for food; when this threshold is reached, the turtle changes its color to yellow. When the metabolism is 0, the turtle does not die but remains stacked. The turtle decides what type of food to eat based on a food-preference property (0 healthy, 1 unhealthy), the shorter distance to any store, and if the food price could be afforded. In this version, the choice algorithm is a simple one, simply adding the property values and the winner is the choiced option (i.e., a turtle with a food preference for healthy food, but a shorter distance to an unhealthy store and a budget lower than healthy food will choose unhealthy food).

HOW IT WORKS

Agents are distributed randomly around the world and each turtle has a metabolism that is spent on each move. When the metabolism reaches a threshold (defined by the hungry-threshold slider), the turtle is hungry (changes to yellow) and decides what kind of food is going to eat. To decide whether food to eat, the agent weighs the distance to the nearest store, the food preference, and the budget (if the current budget is more than half of the earnings, then the turtle prefers healthy food and otherwise). Each item was added to one item, and the selected choice was higher. When the turtle goes to the store, their metabolism is restored (healthy food adds 2 units and unhealthy food adds 1), and the budget is spent (healthy food price is 6 and unhealthy food price is 3). After eating, turtles are randomly distributed around the world. When the number of ticks is equal to the payday, the turtles get paid and get more budget to buy food.

HOW TO USE IT

setup button configures the stores and distributes turtles randomly num-turt slider set the number of turtles earnings button set the wage each turtle is going to get on each 180 ticks hungry-threshold slider set the metabolism value which tells the turtle to go to the store payday slider sets the tick count to which turtles get paid

THINGS TO NOTICE

When the earnings are set to 89 or less, payday is set to 30, and hungry-threshold is set to 10, the turtles are stacked with metabolism = 0. This is due to the fact that turtles run out of money, regardless of whether they spend more on cheaper food (unhealthy) they run out of money, so they cannot restore their metabolism and get stacked (turtles do not die in the sense they do not disappear from the world). When earnings are set to 90 (with payday and hungry-threshold set to 30 and 10), the turtles continue to run forever. When earnings are set to less than 150 and more than 90, turtles consume more unhealthy food than healthy food; when earnings are over 150, they consume more healthy food.

THINGS TO TRY

Try to change the values of payday and earnings to find where the turtles get stacked and where they will run forever. Is the hungry-threshold affecting the turtle behaviour? Is the number of turtles affecting global behavior?

EXTENDING THE MODEL

In this version, the food preferences are fixed properties; they are set in the setup procedure. We have tried with a feature where when the turtle’s budget is lower than the price, the turtle switches its food preferences to unhealthy, in that way the turtles never get stacked. Another new feature could be that food preferences are updated through a turtle network.

RELATED MODELS

This model was based partially in Sugarscape

CREDITS AND REFERENCES

Complexity Explorer 2024 ABM course Diego Díaz Córdova Universidad de Buenos Aires 2024

Comments and Questions

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

Click to Run Model

patches-own[
  healthy ;healthy price food in the market
  unhealthy ;; unhealthy price food in the market, unhealthy is half price of healthy
]

turtles-own[
  metabolism ;;indicate when turtle must to go to shopping
  budget ;; indicate how much money turtle has to spend in food, it has a time basis, t is a kind of wage
  food-preferences ;;indicate what kind of food the agent prefers, healthy or unhealthy
  thealthy ;; keep track of the type of healthy food consumed
  tunhealthy ;; keep track of the type of unhealthy food consumed
  tdistance ;; keep track of the recorred distance
]

to setup
  ca
  buildmarkets
  reset-ticks
  crt num-turt [
    set color white
    set shape "person"
    set metabolism 10
    set budget earnings ;; set budget based on slider with earnings
    set food-preferences random 2 ;; 0 healthy, 1 unhealthy
    set thealthy 0
    set tunhealthy 0
    set tdistance 0
    set xcor random-xcor
    set ycor random-ycor
  ]
end 

to buildmarkets
  ask patches [
    ;;the food price is defined as the 3% of the max wages (1000), healthy food price is twice unhealthy food
    if pxcor > 10 and pxcor < 14 and pycor > 10 and pycor < 14
      [set pcolor green
       set healthy 6]
    if pxcor > 4 and pxcor < 8 and pycor > 10 and pycor < 14
      [set pcolor red
       set unhealthy 3]
    if pxcor > -2 and pxcor < 2 and pycor > 10 and pycor < 14
      [set pcolor green
       set healthy 6]
    if pxcor > -8 and pxcor < -4 and pycor > 10 and pycor < 14
      [set pcolor red
       set unhealthy 3]
    if pxcor > -14 and pxcor < -10 and pycor > 10 and pycor < 14
      [set pcolor green
       set healthy 6]
    ;;down line
    if pxcor > 10 and pxcor < 14 and pycor < -10 and pycor > -14
      [set pcolor red
       set unhealthy 3]
    if pxcor > 4 and pxcor < 8 and pycor < -10 and pycor > -14
      [set pcolor green
       set healthy 6]
    if pxcor > -2 and pxcor < 2 and pycor < -10 and pycor > -14
      [set pcolor red
       set unhealthy 3]
    if pxcor > -8 and pxcor < -4 and pycor < -10 and pycor > -14
      [set pcolor green
       set healthy 6]
    if pxcor > -14 and pxcor < -10 and pycor < -10 and pycor > -14
      [set pcolor red
       set unhealthy 3]
  ]
end 

to go
  ;; just to watch what is going on
    if sum [metabolism] of turtles = 0
      [stop]
  wandering
  hungry
  ;; every 180 ticks turtles get paid, this is 45 times turtles go to shop,
  ;; the price is 45 * 4.5 (average of food prices) equal to 202
  ;; check that is not the first tick (= 0)
  if ((ticks mod payday = 0) and (ticks != 0))
    [wagepay]
  tick
end 

to wagepay
  ask turtles [
    set budget budget + earnings ;; budget refilled beacause of payday
  ]
end 

to wandering
  ask turtles [
    if metabolism > 0
    [
      set heading random 361 ;; move random
      fd 1
      set metabolism metabolism - 1 ;;lose metabolism
      set tdistance tdistance + 1
    ]
  ]
end 

to hungry
  ask turtles[
  if metabolism > 0 and metabolism < hungry-threshold
    [ set color yellow
      ;; search for the more nearest store healthy and unhealthy
      let nearstoreh searchstoreh
      let nearstoreun searchstoreun
      ;; decide if eat healthy or unhelthy based on distance, preferences and budget
      let store eatchoice nearstoreh nearstoreun
      ;; face to the winner store
      face store
      ;; go to store
      fd distance store
      let ldistance (distance store)
      set tdistance round tdistance + ldistance
      buyfood
    ]
  ]
end 

to buyfood
  let price ([healthy] of patch-here + [unhealthy] of patch-here) ;; get price from patch
  if budget > price
    [set budget budget - price ;;spend budget on food
     set color white
     let foodpatch ([pcolor] of patch-here) ;; read patch colour
     ifelse (foodpatch = green)
      [set thealthy thealthy + 1 ;[healthy] of patch-here ;; set variable to sum kind of food bought
      set metabolism (metabolism + 2) ;; metabolism recovery and get 2 more for healthy food
      ]
      [set tunhealthy tunhealthy + 1;([unhealthy] of patch-here)
       set metabolism (metabolism + 1)
      ]
    ]
    ;[
    ;  set food-preferences 1
    ;]
  setxy random-xcor random-ycor ;;all turtles after buying go to a random spot
end 

to-report eatchoice [vnearstoreh vnearstoreun]
 ;; check preferences, by now it is only a boolean property, in a future version could be modified by network
 ;; check budget, if it is half of it then turtle buys cheap food (unhelathy) otherwise expensive food (healthy)
 ;; check distance to both closest stores, less distance i better
 ;; each property add 1 point, based on added points the turtle choice between healthy or unhealthy
 let sumchoiceh 0
 let sumchoiceun 0
 ifelse food-preferences = 0
   [set sumchoiceh sumchoiceh + 1]
   [set sumchoiceun sumchoiceun + 1]
 ifelse budget > (earnings / 2)
   [set sumchoiceh sumchoiceh + 1]
   [set sumchoiceun sumchoiceun + 1]
 ;; by pitagoras i get the distance sqr((mindthY - ycor)2 + (mindthyX - xcor)2)
 let ycort ycor ;; coord y from turtle
 let xcort xcor ;; coord x from turtle
 let ycorh [pycor] of vnearstoreh ;; coord y from closest healthy store
 let xcorh [pxcor] of vnearstoreh ;; coord x from closest healthy store
 let disth sqrt((ycorh - ycort) ^ 2 + (xcorh - xcort) ^ 2) ;; distance from turtle to closest healthy store
 let ycorun [pycor] of vnearstoreun ;; coord y from closest healthy store
 let xcorun [pxcor] of vnearstoreun ;; coord x from closest healthy store
 let distun sqrt((ycorun - ycort) ^ 2 + (xcorun - xcort) ^ 2) ;; distance from turtle to closest unhealthy store
 ifelse disth < distun
   [set sumchoiceh sumchoiceh + 1]
   [set sumchoiceun sumchoiceun + 1]
 ifelse sumchoiceh > sumchoiceun
   [report vnearstoreh]
   [report vnearstoreun]
end 

to-report searchstoreh
  ;; search for a food store
  let healthystores patch-set patches with [healthy > 0]
  let mindisth min-one-of healthystores [distance myself]
  report mindisth
end 

to-report searchstoreun
  let unhealthystores patch-set patches with [unhealthy > 0]
  let mindistun min-one-of unhealthystores [distance myself]
  report mindistun
end 

There are 2 versions of this model.

Uploaded by When Description Download
Diego Díaz Córdova 6 months ago a healthy and non healthy food chart was added Download this version
Diego Díaz Córdova about 1 year ago Initial upload Download this version

Attached files

File Type Description Last updated
healthy and nonhealthy food choice.png preview Preview for 'healthy and nonhealthy food choice' about 1 year ago, by Diego Díaz Córdova Download

This model does not have any ancestors.

This model does not have any descendants.