Nutrition Model June 6 Final V1

No preview image

1 collaborator

Default-person Nate Harner (Author)

Tags

(This model has yet to be categorized with any tags)
Model group EECS 372-Spring 2011 | Visible to everyone | Changeable by the author
Model was written in NetLogo 4.1.2 • Viewed 281 times • Downloaded 38 times • Run 1 time
Download the 'Nutrition Model June 6 Final V1' 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 project is an agent-based model of human nutrition, created to study the effects of different macro level phenomenon on health. In the nutrition model, the simple macronutrients that make up human diets are included. These are fats, carbohydrates, proteins, fiber, and water. The model explores the effects of different patterns of diet and exercise on weight and metabolism over different time horizons. As part of the model, exercise is also included. Exercise patterns can be changed over time mid-simulation. Agent interactions are enabled in a modular fashion, and can be experimented with simultaneously for different theoretical conclusions. The macronutrients are the agents in the model, and the environment is the human subject being studied.

HOW IT WORKS

VISUALIZATION: The visualization aspect of the model is one of the most imporant educational tools. When the subject eats a meal, the digestive system is populated with nutrients that will be consumed by exercise and the body's resting caloric needs.

MACRONUTRIENTS: The macronutrients are represented by different colors, that flow through the digestive system to supply the body with energy. They can be consumed by the environment, representative of the BMR, or the energy required to pump blood, expand the lungs, etc. Or they can be consumed by calorie burners as energy for exercise.

BODY FATS: The purple agents represent the amount of body fat in the system. They are created and destroyed as the subject gains and loses weight. Both exercise and a calorie defecit burn body fat.

CALORIE BURNERS: The pink agents represent the body's need for energy during exercise. When a subject exercises, their muscles and cardiovascular system need extra energy to operate. The Calorie Burners seek out energy with a preference for fast-fueling nutrients.

HOW TO USE IT

First, enter in the initial body information for the subject. This determines BMR among other dynamic variables. You can also give the subject an initial exercise level. This is how many calories the subject will burn every day doing additional work. It is important to note that even sitting at a desk, working on a computer, burns more calories than lying in bed.

You can also specify which agent interactions to include and the diet pattern of the subject.

THINGS TO NOTICE

Notice long term weight gain patterns and the very long term ( 1 - 5 year) equilibrium that is reached with any steady diet. If caloric intake and exercise are kept constant, the body will eventually reach a level where it has either completely deteriorated, or BMR has increased to the point where the daily caloric surplus reaches an average of 0.

Notice the slope of the body composition and weight plots. The BMR serves to decelerate weight gain, and accelerate weight loss, as the body requires more or less energy for daily resting function.

Notice the affect of fiber on keeping the digestive system populated. This is the feeling of being "full" that is discussed as a benefit to a diet high in fiber when attempting weight loss.

Notice the compounding effect of the fat interaction. When increased insulin levels lead the subject to crave fats and carbohydrates, the extra carbohydrates and fats consumed as a result serve to compound this effect.

THINGS TO TRY

Try experimenting with different body types. While a 110 pound teenage woman would undergo massive weight gain on the McDonalds diet, a 190 pound active male could maintain a steady weight in the short run, ignoring the long term consequences of a highly processed diet.

Try varying exercise slightly. What would happen if you ran 30 minutes a day for an extra 400 calories burned?

Try experimenting with the agent interactions. Does the fat interaction create a viscious cycle of weight gain and insatiable cravings? Does the fiber interaction create a more steady stream of energy for the body?

EXTENDING THE MODEL

Human nutrition is fundamentally too complicated to model accurately with our current knowledge of the subject, but many interactions and agents could be added to the model to expand the conclusions generated.

Agent Additions:

Micronutrients (Vitamins, Minerals)

Muscle

Bone

Connective Tissue

Intermediate agents (ATP, Glycogen, Amino Acids)

Interactions:

Metabolic Pathways

Muscle Development

More complex BMR calculation

RELATED MODELS

Sadly, there are no other agent based models for nutrition as of June 2011. In fact, there are no comprehensive computational models for human nutrition. The closest models that exist are for optomizing beef yeild in mega cattle farms.

CREDITS AND REFERENCES

Dietary Guidelines: www.nutrition.gov

NetLogo Modeling Commons link: http://modelingcommons.org/projects/22

Comments and Questions

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

Click to Run Model

;;A tick is one minute of activity, there are 3600 ticks in a day. 
;;The color of the background represents how fast the body is using energy, i.e. metabolism

;; In this model, the body consumes calories and attempts to consume calories based on the body's needs

;; There are 1440 ticks in a day, each tick represents a minute

;;The 5 macronutrients. One agent represents a calorie of the nutrient
breed [fats fat]
breed [carbohydrates carbohydrate]
breed [proteins protein]
breed [fibers fiber]
breed [water single-water]

;;Persistent agents, body stores
breed [body-fats a-body-fat]  ;; One body fat agent represents 500 calories of body fat

;;A calorie burner is an agent that seeks out energy to accomplish a task. Sleeping and exercise burn calories on top of the BMR
breed [calorie-burners a-calorie-burner]

calorie-burners-own
[
  calories-left-to-burn
]

globals
[ 
  basal-metabolic-rate  ;;Calories/Day at rest
  height                ;;Height in meters
  base-weight           ;;Weight without body fat
  weight                ;;Weight in Kilograms
  age                   ;;Age in years
  
  body-fat-calories              ;;The calories of body fat currently in the body
  
  ;;Daily counters, explained by names
  ticks-per-day ;;Ticks per day
  yesterdays-calorie-balance
  calories-burned-today
  calories-consumed-today
  daily-calorie-intake
  
  body-fat-burned-today
  nutrients-burned-today
  %-nutrients-burned-during-exercise ;;The % of calories burned from nutrients, relative to calories burned from body fat
]

to setup
  clear-all
  
  set weight ( initial-weight-in-lbs * 0.4536 ) ;; Convert to kg from lbs
  set base-weight ( weight ) * ( 1 - initial-body-fat-% )  ;;The base weight is the weight of the individual without any body fat
  set height ( initial-height-in-inches * 2.54) ;;Convert to cm from in
  set age initial-age
  
  set ticks-per-day (1440 / minutes-per-tick) ;; 1440 minutes in a day
  
  
  ;;Create the initial body fat
  set body-fat-calories ( 7716 * ( weight * initial-body-fat-%) ) ;;7716 calories per kg of body fat
  
  set-default-shape turtles "circle"
  ask patches [
    set pcolor white
  ]
  ask patches with [ pxcor = 0 ]
  [
    set pcolor black
  ]
  
  update-BMR
end 

to update-BMR
  ;;In this model, BMR is a dynamic variable
  
  ;;Mifflin Equation (1990), shown to be highly accurate for 18 - 70 yr.
  set basal-metabolic-rate ( 10.0 * ( weight ) + 6.25 * height - 5 * age )
  ifelse(male?) 
  [ set basal-metabolic-rate ( basal-metabolic-rate + 5) ]
  [ set basal-metabolic-rate ( basal-metabolic-rate - 161) ]
end 

to go
  ;;If there are <= 0 body fat calories, the subject has died, so stop the simulation
  if ( body-fat-calories <= 0 ) [ stop ] 
  if ( ticks mod ticks-per-day = 0 ) 
  [
    ;;Update daily counters
     if( nutrients-burned-today + body-fat-burned-today != 0) 
     [ 
       set %-nutrients-burned-during-exercise (nutrients-burned-today)/(nutrients-burned-today + body-fat-burned-today)
     ]
     set yesterdays-calorie-balance (calories-consumed-today - calories-burned-today)
     set daily-calorie-intake (calories-consumed-today)
     set calories-burned-today 0 
     set calories-consumed-today 0
     set nutrients-burned-today 0
     set body-fat-burned-today 0
     
     set age ( age + ( 1 / 365 ) ) ;;Update age every day
  ] 
  
  ;;Agent actions for each time step
  eat-meals
  exercise
  digest
  burn-calories
  visualize-body-fats
  update-BMR
  if(update-plots? ) [update-plots]
  tick
end 

to eat-food [ grams-fat grams-carbohydrate grams-protein grams-fiber grams-water ]
 
  create-fats ( grams-fat * 9 )  ;; 9 Calories per gram of fat
  [
    set color yellow
    setxy ( ( random max-pxcor )  + 1)  random-ycor
    set calories-consumed-today (calories-consumed-today + 1)
    set size 0.9
  ]
  create-carbohydrates ( grams-carbohydrate * 4 ) ;; 4 Calories per gram of carbs
  [
    set color brown
    setxy ( ( random max-pxcor )  + 1) random-ycor
    set calories-consumed-today (calories-consumed-today + 1)
    set size 0.9
  ]
  create-proteins ( grams-protein * 4 ) ;; 4 calories per gram of protein
  [
    set color red
    setxy ( ( random max-pxcor )  + 1) random-ycor
    set calories-consumed-today (calories-consumed-today + 1)
    set size 0.9
  ]
  create-fibers ( grams-fiber * 4 ) ;; 4 Calories per gram of carbs
  [
    set color green
    setxy ( ( random max-pxcor )  + 1) random-ycor
    set size 0.9
  ]
  create-water ( grams-water )
  [
    set color blue
    setxy ( ( random max-pxcor )  + 1) random-ycor
    set size 0.9
  ]
end 

to digest
  let calories-consumed-this-tick ( basal-metabolic-rate / ticks-per-day ) ;;The calories that the body needs for internal function
  let frac ( calories-consumed-this-tick - (floor calories-consumed-this-tick) ) ;;Remainder, since we cannot consume partial calories
  
  ;Compensate for fractional calories-consumed-this-minute
  if ( random-float 1 < frac ) [ set calories-consumed-this-tick ( calories-consumed-this-tick + 1) ]
  
  ;;Temp boolean variable for fat interaction
  let eat-junk-food?  false
  
  repeat calories-consumed-this-tick
  [
    set eat-junk-food? false
    ;;Consume as many available calories as possible, on the last 5 rows. This means they are available for use. If there are not enough in 
    ifelse( count turtles with [ ycor - 5 < min-pycor and xcor > 0 and breed != calorie-burners and breed != fibers] > 0 )
    [  
        ask one-of turtles with [ (ycor - 5 < min-pycor ) and xcor > 0 and breed != calorie-burners and breed != fibers]
        [ 
          ;; With fat interactions turned on, digesting a fat occasionally causes the subject to eat more junk food. This models the phenomenon that diets high in fat often indirectly lead to
          ;; increased insulin levels, which in turn can spike the desire for fats and carbohydrates
          if( fat-interactions? and breed = fats and ( random 200 < 1 ) ) [ set eat-junk-food? true ]
          
          ;;Burn a calorie of a nutrient (fat, carbohydrates, protein) 
          set calories-burned-today ( calories-burned-today + 1 )
          die
        ]
    ]
    [
        ;;Burn body fat if there are no nutrients available for consumption
        set body-fat-calories (body-fat-calories - 1)
        set calories-burned-today ( calories-burned-today + 1 )
    ]
    
    if(eat-junk-food?) [ eat-junk-food ]
  ]
  
  
  ask turtles with [xcor > 0 and breed != calorie-burners]
  [
    ;;Speed is influenced by fibers. Fiber in the diet slows down digestion speed, in this model, fiber acts as a bonding agent and slows nearby agents down to 35% normal speed
    let speed ( calories-consumed-this-tick / ( max-pycor * 2 ) )
    if (  fiber-interactions? and count fibers-here > 0)
    [
      set speed (speed * 0.35)
    ]
    
    
    ;; on the last row, the unburned nutrients go into persistent storage, i.e. turn into body fat
    ifelse( ycor - speed < min-pycor)
    [
      if( breed != fibers) [ set body-fat-calories ( body-fat-calories + 1 ) ]
      die  
    ]
    [
       ;; Progress the agent through the digestive system
        set ycor (ycor - speed)
    ]
  ]
end 

to visualize-body-fats
  ;;Update the amount of body fat agents based on the body-fat-calories variable
  ;;There are 500 calories per body fat agent
  if(count body-fats < body-fat-calories / 500)
  [
    create-body-fats( ( body-fat-calories - (count body-fats) * 500 ) / 500 )
    [
      set color violet
      setxy (random min-pxcor - 1) random-ycor
      set size 0.9
    ]
  ]
  
  if( count body-fats > body-fat-calories / 500)
  [
    ask n-of (( (count body-fats) * 500 - body-fat-calories) / 500 ) body-fats
    [
      die
    ]
  ]
end 

to burn-calories
  ask calorie-burners
  [ 
    ;;The calorie burners will start on the left side of the view, or the digestive system, and seek out nutrients for consumption, with a random walk pattern. 
    rt (random 20 ) - 10
    forward 0.5
    
    if(count ( other turtles-here with [ breed != calorie-burners and breed != fibers] ) > 0 )
    [
       ask other turtles-here with [ breed != calorie-burners and breed != fibers]
       [
         ifelse( breed = body-fats )
         [
           ;; If the calorie burner reaches a body fat, subtract body fat calories and destroy the calorie burner
           set body-fat-calories (body-fat-calories - 1 )
           set body-fat-burned-today (body-fat-burned-today +  1 )
           ask myself [ set calories-left-to-burn (calories-left-to-burn - 1) ]
         ]
         [
           ;; If the calorie burner reaches a normal nutrient, 
           ask myself [ set calories-left-to-burn (calories-left-to-burn - 1) ]
           set nutrients-burned-today ( nutrients-burned-today + 1 )
           die
         ]
       ]
       if ( calories-left-to-burn <= 0 ) 
       [ 
         ;;Destroy the calorie burner if they have burned 10 calories
         set calories-burned-today (calories-burned-today + 10)
         die 
       ]
    ]
  ]
end 

to exercise
  ;;Exercising will generate a certain number of calorie-burning agents
    ;;Exercise twice a day, with a level based on the slider
  if(ticks mod ticks-per-day = floor(ticks-per-day * 1 / 3))
  [
    create-calorie-burners( (exercise-level / 2) / 10 )
    [
      setxy random max-pxcor random-pycor
      set color pink
      set calories-left-to-burn 10
      set size 0.9
    ] 
  ]
  
  if(ticks mod ticks-per-day = floor(ticks-per-day * 2 / 3))
  [
    create-calorie-burners( (exercise-level / 2) / 10 )
    [
      setxy random max-pxcor random-pycor
      set color pink
      set calories-left-to-burn 10
      set size 0.9
    ]
  ]
end 


;;;;;;;;;;;;;;;; PLOTTING FUNCTION ;;;;;;;;;;;;;;;;;;;;;;

to update-plots
  set-current-plot "Nutrient Breakdown"
  set-current-plot-pen "carbohydrates"
  plot count carbohydrates
  
  set-current-plot-pen "fats"
  plot count fats
  
  set-current-plot-pen "protein"
  plot count proteins
  
  set-current-plot-pen "fibers"
  plot count fibers
  
  set-current-plot-pen "water"
  plot count water
  
  set-current-plot "Weight"
  ;;Each agent has a gram weight associated with it
  set weight ( base-weight + ( (count fats) / 9 + (count carbohydrates) / 4 + (count proteins) / 4 ) / 1000 ) + (body-fat-calories / 7716 )
  
  ifelse( not weight-in-kg)
  [
    plot ( weight * 2.204 )
  ]
  [
    plot weight
  ]
  
  set-current-plot "Body Composition"
  set-current-plot-pen "% Body Fat"
  let %-body-fat ( ( body-fat-calories / 3500 ) / ( weight * 2.204 ) )
  plot %-body-fat
  
  set-current-plot-pen "% Other"
  plot 1 - %-body-fat
end 

;;;;;;;;;;;;;;;;;;;;;;;; PRESET MEAL SCHEDULES AND NUTRITIONAL INFORMATION ;;;;;;;;;;;;;;;;;;;;;;;;;;

to eat-meals
  ;;Eat meals
  
  ;;MCDONALDS FOR EVERY MEAL!!!
  if( diet-pattern = "mcdonalds" )
  [
  if ( ( ticks mod ticks-per-day ) = floor(ticks-per-day / 4) )
  [
    ;;Breakfast at 8 am
    eat-food-named "sausage-mcmuffin"
    eat-food-named "orange-juice"
  ]
  
  if (ticks mod ticks-per-day = floor(ticks-per-day / 2) )
  [
    ;;Lunch at 12 pm
    eat-food-named "big-mac"
    eat-food-named "large-fries"
    eat-food-named "large-coke"
  ]
  
  if(ticks mod ticks-per-day = floor(ticks-per-day * 3 / 4))
  [
    ;;Dinner at 6 pm
    eat-food-named "big-mac"
    eat-food-named "large-coke"
    eat-food-named "large-fries"
  ]
  
  if( ticks mod ticks-per-day = floor(ticks-per-day * 7 / 8 ) )
  [
    ;;10 PM snack
    eat-food-named "oreo-mcflurry"
    eat-food-named "soy-milk"
  ]
  ]
  
  ;;Typical Vegan Diet (raw foods only)
  ;;Nurtitional information from Livestrong.com calorie counter
  if( diet-pattern = "vegan" )
  [
  if ( ( ticks mod ticks-per-day ) = floor(ticks-per-day / 4) )
  [
    ;;Breakfast at 8 am
    eat-food-named "mango-smoothie"
    eat-food-named "whole-wheat-bagel"
  ]
  
  if (ticks mod ticks-per-day = floor(ticks-per-day / 2) )
  [
    ;;Lunch at 12 pm
    eat-food-named "kidney-beans"
    eat-food-named "apple-juice"
  ]
  
  if(ticks mod ticks-per-day = floor(ticks-per-day * 3 / 4))
  [
    ;;Dinner at 6 pm
    eat-food-named "pbj-sandwich"
    eat-food-named "fried-brown-rice"
  ]
  
  if( ticks mod ticks-per-day = floor(ticks-per-day * 7 / 8 ) )
  [
    ;;10 PM snack
    eat-food-named "trail-mix"
    eat-food-named "soy-milk"
  ]
  ]
end 

to eat-food-named [ food-name ]
  
  ;;VEGAN DIET
  if( food-name = "mango-smoothie" )
  [
    eat-food 10 61 2 3 0
  ]
  if( food-name = "whole-wheat-bagel" )
  [
    eat-food 2 52 13 8 0
  ]
  if( food-name = "kidney-beans" )
  [
    eat-food 2 41 21 16 0
  ]
  if( food-name = "apple-juice" )
  [
    eat-food 0 27 0 1 0
  ]
  if( food-name = "pbj-sandwich" )
  [
    eat-food 10 44 9 3 0
  ]
  if( food-name = "fried-brown-rice" )
  [
    eat-food 6 39 6 4 0
  ]
  if( food-name = "trail-mix" )
  [
    eat-food 10 12 5 1 0
  ]
if( food-name = "soy-milk" )
  [
    eat-food 8 30 16 3 0
  ]
  
  ;;MCDONALDS
  if( food-name = "big-mac" )
  [
    eat-food 29 45 25 6 0  ;;McDonalds Big Mac
  ]
  if( food-name = "sausage-mcmuffin" )
  [
    eat-food 22 29 14 2 0 ;;McDonalds Sausage McMuffin
  ]
  if( food-name = "orange-juice" )
  [
    eat-food 0 39 3 0 0 ;;McDonalds Medium Orange Juice
  ]
  if( food-name = "diet-coke" )
  [
    eat-food 0 0 0 0 0;;Medium Diet Coke
  ]
  if( food-name = "large-coke" )
  [
    eat-food 0 86 0 0 0;; Large Coca-Cola
  ]
  if( food-name = "large-fries" )
  [
    eat-food 25 63 6 6 0 ;;McDonalds Large Fries
  ]
  if( food-name = "oreo-mcflurry" )
  [
    eat-food 19 89 13 3 0;;McDonalds Oreo McFlurry
  ]
  
  ;;Junk foods
  if( food-name = "doritos")
  [
    eat-food 7 18 2 1 0
  ]
  if( food-name = "wheat-thins")
  [
    eat-food 6 21 2 1 0
  ]
  if( food-name = "cheese-its")
  [
    eat-food 8 17 3 0 0
  ]
  if( food-name = "sour-patch")
  [
    eat-food 0 36 0 0 0
  ]
end 

to eat-junk-food
  ;;Random snacks
  ;;0 = Doritos
  ;;1 = Wheat thins
  ;;2 = Cheese-its
  let snack-choice (random 4)
  
  if( snack-choice = 0 )
  [
    eat-food-named "doritos"
  ]
  if( snack-choice = 1 )
  [
    eat-food-named "wheat-thins"
  ]
  if( snack-choice = 2 )
  [
    eat-food-named "cheese-its"
  ]
  if( snack-choice = 3 )
  [
    eat-food-named "sour-patch"
  ]
end 

There is only one version of this model, created almost 13 years ago by Nate Harner.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.