NetLogo 4 auto stress strategies

No preview image

1 collaborator

Default-person Edmund LeGrand (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 292 times • Downloaded 23 times • Run 0 times
Download the 'NetLogo 4 auto stress strategies' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

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

Click to Run Model

breed [ circles circle ]                                   ;; Host cells 
breed [ flags flag ]                                       ;; Key host cells
breed [ triangles triangle ]                               ;; Pathogens A
breed [ stars star ]                                       ;; Pathogens B
turtles-own [energy max-energy start-energy birth-energy]  ;; All turtles have energy and a maximum amount of energy they can take on.
patches-own [countdown patch-energy]                       ;; Countdown makes it run. Patch-energy is new to the program.
circles-own [circle-energy-to-survive]                     
flags-own [flag-energy-to-survive]
triangles-own [triangle-energy-to-survive]
stars-own [star-energy-to-survive]
globals [pathB cumulative-energy-deficit]

to setup
  clear-all
  set pathB 1  ;; Turns the pathB switch in the code to "on" in the setup. The user must still physically turn on the switch at the interface screen.
  
  ask patches 
  [ set pcolor green  set patch-energy 100]   ;; New code here with patch-energy.
    
 set-default-shape circles "circle"   ;; Host cells
  ask patches 
   [ sprout-circles 1 [ set color blue set start-energy 300 set birth-energy 90 set max-energy 300 set circle-energy-to-survive 40] ]  ;; START-ENERGY HAD BEEN 120 FOR ALL CELLS
  
 set-default-shape flags "flag"       ;; key host cells such as heart cells
  ask patches with [(pycor < 3) and (pycor > -3 ) and (pxcor < 3) and (pxcor > -3)]
   [sprout-flags 1 [ set color orange set start-energy 300 set max-energy 300 set flag-energy-to-survive 30] ]  ;; Can store lots of energy; not prone to apoptosis since irreplaceable.
  ask circles with [ (pycor < 3) and (pycor > -3 ) and (pxcor < 3) and (pxcor > -3)] [ die ] ;; This clears out the circles underneath the flags.  ;; FLAG MAX-ENERGY HAD BEEN 500
 
 set-default-shape triangles "triangle"  ;; Pathogens A (these are like large extracellular pathogens)
  ask circles with [ (pycor <= start-upper-pathogen-pycor) and (pycor > start-lower-pathogen-pycor) and (pxcor <= start-upper-pathogen-pxcor) and (pxcor > start-lower-pathogen-pxcor) ] [ die ]
   ;; This clears out the circles underneath where the triangles will be.
  ask patches with [ (pycor <= start-upper-pathogen-pycor) and (pycor > start-lower-pathogen-pycor) and (pxcor <= start-upper-pathogen-pxcor) and (pxcor > start-lower-pathogen-pxcor)]
   [sprout-triangles 1 [ set color red set start-energy 300 set birth-energy 60 set max-energy 300 set triangle-energy-to-survive 40] ]  
   ;; Low energy storage compared to host cells is a vulnerability; same energy to survive as host cells.
   ;; The pathogens' energy to survive can be modified by the slider (see below).
 
  ask turtles
  [ set energy start-energy ]  ;; Even though start-energy is mentioned above for each breed, this code is needed to actually impart the energy.
                                
  reset-ticks
end 

to go 
  set cumulative-energy-deficit 326700 - ((sum [energy] of circles) + (sum [energy] of flags)) + cumulative-energy-deficit  
      ;; There are 1089 potential host cells and key host cell x 300 max energy units per cell.
      ;; Note that the host starts with a deficit of 3000 because the of the initial infection (e.g. a bite wound).
      ;; The host must recover to its full 1089 cells.
      ;; Also changed the formula from 323700 to 326700 in the instantaneous-energy-deficit monitor on the interface.
  stop-adding-energy
  keep-turtles-still
  invoke-pathogen-harm
  invoke-pathogen-take-energy
  invoke-pathogen-low-energy
  invoke-pathogen-wander
  
    if auto-infect-with-pathogenB? and pathB = 1  ;; This is a switch in the code that permits turning off the secondary infection (pathogen B) after one tick. 
    [if count circles <= 1000 ;;and mean [energy] of circles <= 90  ;; I added the mean energy statement, but this could have been instantaneoud-energy-deficit.
      [invoke-auto-infection-pathogenB] ] ;; This code for pathogenB, the secondary infection, is farther down.
    
  invoke-pathogenB-harm
  invoke-pathogenB-take-energy
  invoke-pathogenB-low-energy
  invoke-pathogenB-wander
     
  invoke-local-directed
  invoke-local-stressor
  invoke-regional-stressor
  invoke-amputation
  invoke-amputationB
  invoke-hostcell-wander
  
  invoke-auto-systemic-stressor
  invoke-auto-systemic-stressor-slow
  invoke-auto-systemic-stressor-cycle
  invoke-auto-systemic-stressor-hi-cycle
  
  replicate   
  check-death
  tick
end 

to stop-adding-energy            ;; Limits the amount of energy each cell can store, but there can be temporary overshooting of the amount.
ask turtles 
  [ if energy >= max-energy
    [set energy max-energy ]]
end 

to keep-turtles-still      ;; This sets the action. The switches on the interface screen allow movement to adjacent vacant spacesfor either pathogens or host cells.
    ask turtles [
        right random 360
        forward 0                ;; This gets the turtles, especially the flags, to move in place; therefore no visible movement but it lets time occur (ticks go).
 
 ;; All turtles derive energy from the patches as patch-energy at each tick and lose a little less energy (metabolic energy) with each tick.
 set energy (random-normal 1 0.02) * (energy + ((patch-energy * 0.14) * ((100 - systemic-host-stressor) / 100))) ;; The systemic host stressor is here.    
   ;; set energy (random-normal 1 0.02) * (energy + (14 * (100 - systemic-host-stressor) / 100)) ;; This was old code where the turtles were simply given energy at each tick.
 set energy (random-normal 1 0.02) * (energy - 10)   ;; Every tick costs the turtles about 10 units of energy.  
;; This is the energy gain and loss per tick; the random-normal (mean of 1 and SD of 0.02) gives a bit of randomness to the whole program.
;; I don't want too much randomness since all turtles are bathed in the same fluid of patch-energy and are superficially identical
;; There's additional randomness in the pathogen damage routine and in the host defense routines.
;; The systemic host stressor represents the acute-phase response: fever, iron & zinc sequestration, anorexia/nutrient restriction, anemia/hypoxia, systemic acidosis, etc.

 ifelse show-energy?             ;; This is for the switch on the interface screen. Best to have it on.
     [ set label round energy ]  ;; "round" rounds the energy value on the screen to a readable integer.
     [ set label ""]             ;; If set to "No", no energy values show on the screen   
     
    ]
end 

;; PATHOGEN PHENOTYPE SLIDERS & SWITCH 

to invoke-pathogen-harm  ;; This acts like a toxin to harm adjacent host cells.
  ask triangles [ ask circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogen-harm-hostcells) ]]
  ask triangles [ ask flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogen-harm-hostcells) ]]  
end 

to invoke-pathogen-take-energy  ;; This gives the pathogen energy when it's adjacent to a host cell.
  ask triangles [ if any? circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogen-take-up-energy) ]]  
  ask triangles [ if any? flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogen-take-up-energy) ]] 
end 

to invoke-pathogen-low-energy  ;; Lowering the "pathogen-survive-low-energy" number lets them survive better. They still need 120 energy units to reproduce (2 * birth-energy).
  ask triangles [ set triangle-energy-to-survive pathogen-survive-low-energy ]
  ask triangles [ set max-energy pathogen-survive-low-energy + 260 ]  ;; As a minor handicap for enhanced survival, I've also reduced the max-energy they can store.
end 

to invoke-pathogen-wander  ;; In this model, letting the pathogens move to free spaces helps them only if they are more lethal than host cells; otherwise they're more vulnerable.
  ifelse pathogen-wander?
  [ ask triangles 
  [ let empty-patches neighbors4 with [ not any? turtles-here ]
    if any? empty-patches
    [ let target one-of empty-patches
      face target
      move-to target ]] ]
  [
  ]
end 

;; PATHOGEN B PHENOTYPE SLIDERS & SWITCH 

to invoke-auto-infection-pathogenB    ;; The parameters needed to start this secondary infection are coded earlier in the program.  
 ask circles with [ (pycor <= start-upper-pathogenB-pycor) and (pycor > start-lower-pathogenB-pycor) and (pxcor <= start-upper-pathogenB-pxcor) and (pxcor > start-lower-pathogenB-pxcor)]    
     [die]  ;; This clears out the host cells at the site before pathogen B comes along (otherwise the pathogens and the host cells are on the same patch and most pathogens die).
 ask patches with [ (pycor <= start-upper-pathogenB-pycor) and (pycor > start-lower-pathogenB-pycor) and (pxcor <= start-upper-pathogenB-pxcor) and (pxcor > start-lower-pathogenB-pxcor)]
  [sprout-stars 1 [ set color red set start-energy 300 set birth-energy 60 set max-energy 300 set star-energy-to-survive 40] ] 
 ask stars
  [ set energy start-energy ] 
 set pathB 0   ;; This turns off the infection with pathogen B after a single round.  
end   

to invoke-pathogenB-harm  ;; This acts like a toxin to harm adjacent host cells
  ask stars [ ask circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogenB-harm-hostcells) ]]
  ask stars [ ask flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy - pathogenB-harm-hostcells) ]]  
end 

to invoke-pathogenB-take-energy  ;; This gives pathogen B energy when adjacent to host cell
  ask stars [ if any? circles in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogenB-take-up-energy) ]]  
  ask stars [ if any? flags in-radius 1 [ set energy (random-normal 1 0.02) * (energy + pathogenB-take-up-energy) ]] 
end 

to invoke-pathogenB-low-energy  ;; Lowering the "pathogenB-survive-low-energy" number lets them survive better
  ask stars [ set star-energy-to-survive pathogenB-survive-low-energy ]
  ask stars [set max-energy pathogenB-survive-low-energy + 160 ]  ;; I've linked the max-energy they can use to the survival energy threshold as a minor handicap
end 

to invoke-pathogenB-wander  ;; In this model, letting the pathogens move to free spaces helps them only if they are more lethal than host cells; otherwise they're more vulnerable.
  ifelse pathogenB-wander?
  [ask stars 
  [ let empty-patches neighbors4 with [ not any? turtles-here ]
    if any? empty-patches
    [ let target one-of empty-patches
      face target
      move-to target ]] ]
  [
  ]
end  
    
;; HOST DEFENSES: SLIDERS & SWITCHES (Systemic stressor slider is already incorporated above)  

to invoke-local-directed  ;; Host cells directly harm adjacent pathogens (as if injecting a toxin).
  ask circles [ ask triangles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-directed) ]]   
  ask circles [ ask stars in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-directed) ]]
end  

to invoke-local-stressor ;; Harms all adjacent cells if the host cell is in contact with a pathogen as if depriving the area of nutrients or causing acidosis.
  ask triangles [ ask circles in-radius 1 [ ask turtles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-stressor) ]]]
  ask stars [ ask circles in-radius 1 [ ask turtles in-radius 1 [ set energy (random-normal 1 0.02) * (energy - local-host-stressor) ]]]
end 

to invoke-regional-stressor  ;; Harms all cells within 5 patches from conflict interface as if depriving the region of blood supply due to clotting & edema.
ask triangles [ ask circles in-radius 2 [ ask turtles in-radius 5 [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-host-stressor) / 100)) ]]]
ask stars [ ask circles in-radius 2 [ ask turtles in-radius 5 [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-host-stressor) / 100)) ]]]
;;  Not sure why the effect is so dramatic with a "regional-host-stressor" setting of 1 or 2
end 

to invoke-amputation  ;;  This code harms all cells in the lower right region as if using a tourniquet (or hypersensitive reaction in plants).
 ask turtles with [ (pycor < 0) and (pxcor > 10)] [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-amputation) / 100)) ] 
end 

to invoke-amputationB  ;;  This code harms all cells in the lower left region as if using a tourniquet (or hypersensitive reaction in plants).
 ask turtles with [ (pycor < 0) and (pxcor < -10)] [ set energy (random-normal 1 0.02) * (energy * ((100 - regional-amputationB) / 100)) ] 
end 

to invoke-hostcell-wander  ;; Lets the host cells move to free spaces.
  ifelse hostcell-wander?  ;; This slightly helps the host IF the host cells can harm the pathogens either directly or by local stressing.
  [ask circles 
  [ let empty-patches neighbors4 with [ not any? turtles-here ]
    if any? empty-patches
    [ let target one-of empty-patches
      face target
      move-to target ]] ]
  [
  ]
end 

to invoke-auto-systemic-stressor  ;; An automatic device that quickly turns the systemic stressor on and then off, etc. Lots of overshooting with this strategy.
  ifelse auto-systemic-stressor?  ;; However, once the pathogen invades enough that there are less than 925 host cells, it won't turn on anymore.
  [ if count circles <= 1030 ;;and count circles > 950  ;; This "and" allows one to get bigger cycles instead of just hovering around and overshooting 925.
    [ set systemic-host-stressor 60 ]
    if count circles <= 925                                     
    [ set systemic-host-stressor 0 ]]
  [ ]
 if (count triangles + count stars) = 0  ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at 60).
 [set systemic-host-stressor 0]     
end 

to invoke-auto-systemic-stressor-slow  ;; An automatic device that slowly turns the systemic stressor on and finally has strong 60 to 0 cycling at the end.
  ifelse auto-systemic-stressor-slow?  
  [ if count circles <= 1030   
    [ set systemic-host-stressor 10 ]
    if count circles <= 1020                                    
    [ set systemic-host-stressor 20 ]
 if count circles <= 1010                                    
    [ set systemic-host-stressor 30 ]
 if count circles <= 1000                                    
    [ set systemic-host-stressor 40 ] 
 if count circles <= 990                                    
    [ set systemic-host-stressor 50 ]  
 if count circles <= 980                                    
    [ set systemic-host-stressor 60 ]    
 if count circles <= 925                                    
    [ set systemic-host-stressor 0 ]] 
 [ ]
if (count triangles + count stars) = 0  ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at the final level).
 [set systemic-host-stressor 0]
end 

to invoke-auto-systemic-stressor-cycle  ;; An automatic device that cycles stress slowly
  ifelse auto-systemic-stressor-cycle?  
  [ if count circles <= 1030 
    [ set systemic-host-stressor 30 ]
    if count circles <= 1010                                     
    [ set systemic-host-stressor 60 ]
    if count circles <= 990 
    [ set systemic-host-stressor 30 ]
    if count circles <= 970                                     
    [ set systemic-host-stressor 0 ]
    if count circles <= 950                                    
    [ set systemic-host-stressor 30 ]
    if count circles <= 930                                     
    [ set systemic-host-stressor 60 ]
    if count circles <= 910                                    
    [ set systemic-host-stressor 30 ]
    if count circles <= 890                                   
    [ set systemic-host-stressor 0 ]
    if count circles <= 870                                    
    [ set systemic-host-stressor 30 ]
    if count circles <= 850                                    
    [ set systemic-host-stressor 60 ]
    if count circles <= 830                                    
    [ set systemic-host-stressor 30 ]
    if count circles <= 810        
    [ set systemic-host-stressor 0 ]]
  [ ]
if (count triangles + count stars) = 0  ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at the final level).
 [set systemic-host-stressor 0]
end 

to invoke-auto-systemic-stressor-hi-cycle  ;; An automatic device that quickly cycles from 60 to 0. This minimizes overshooting.
  ifelse auto-systemic-stressor-hi-cycle?  
  [ if count circles <= 1030 
    [ set systemic-host-stressor 60 ]
    if count circles <= 1015                                     
    [ set systemic-host-stressor 0 ]
    if count circles <= 1000                                     
    [ set systemic-host-stressor 60 ]
    if count circles <= 985                                     
    [ set systemic-host-stressor 0 ]
    if count circles <= 970                                     
    [ set systemic-host-stressor 60 ]
    if count circles <= 955                                     
    [ set systemic-host-stressor 0 ]
    if count circles <= 940                                     
    [ set systemic-host-stressor 60 ]
    if count circles <= 925                                     
    [ set systemic-host-stressor 0 ]]
  [ ]
if (count triangles + count stars) = 0  ;; These 2 lines allow the host to recover after eliminating the pathogens (otherwise the stressor stays at the final level).
 [set systemic-host-stressor 0]
end 

to replicate   
   ask triangles                                                                   ;; Pathogens replicate if they have 2x birth-energy (60 units) and a vacant patch for the hatchling to move to.
    [ if energy >  2 * birth-energy and any? neighbors4 with [not any? turtles-here]
      [ set energy energy / 2                                                      ;; This cuts the energy in half before hatching.
       hatch 1 [set energy birth-energy                                            ;; There's a little lost energy since mother may have more than 2x birth-energy,
         let target one-of neighbors4 with [not any? turtles-here]                 ;;   but daughter cell (hatchling) only gets the birth-energy.
        face target
        move-to target   ] ] ]
     
   ask stars [                                                                       ;; Pathogen B replicate if they have 2x birth-energy (60 units) and a vacant patch for the hatchling to move to.
     if energy >  2 * birth-energy and any? neighbors4 with [not any? turtles-here]
      [ set energy energy / 2                                                        ;; This cuts the energy in half before hatching.
       hatch 1 [set energy birth-energy                                              ;; There's a little lost energy since mother may have more than 2x birth-energy,
         let target one-of neighbors4 with [not any? turtles-here]                   ;;   but daughter cell (hatchling) only gets the birth-energy.
        face target
        move-to target   ] ] ] 
     
   ask circles [                                                                       
     if energy >  2 * birth-energy and any? neighbors4 with [not any? turtles-here]  ;; Host cells replicate if they have 2x birth-energy (90 units) and a vacant patch for the hatchling to move to.
      [ set energy energy / 2                                                        ;; This cuts the energy before hatching.
       hatch 1 [set energy birth-energy                                              ;; There's a little lost energy since mother may have more than 2x birth-energy,
         let target one-of neighbors4 with [not any? turtles-here]                   ;;   but daughter cell (hatchling) only gets the birth-energy.
        face target
        face target
        move-to target   ] ] ]                                                       ;; Flags (key host cells) don't replicate
end 

to check-death
   ask circles
    [ if energy <= circle-energy-to-survive [ die ]]
   ask flags
    [ if energy <= flag-energy-to-survive [ die ]]
   ask triangles
    [ if energy <= triangle-energy-to-survive [ die ]]  
   ask stars
    [ if energy <= star-energy-to-survive [ die ]]         
end 
  
  
  

There is only one version of this model, created about 10 years ago by Edmund LeGrand.

Attached files

No files

Parent: NetLogo host versus pathogens model

This model does not have any descendants.

Graph of models related to 'NetLogo 4 auto stress strategies'