DemGenTrout 1.2

No preview image

2 collaborators

Default-person Béatrice Frank (Author)
Philippe Baret (Advisor)

Tags

barrier 

Tagged by Béatrice Frank over 10 years ago

brown trout 

Tagged by Béatrice Frank over 10 years ago

fish 

Tagged by Béatrice Frank over 10 years ago

population dynamics 

Tagged by Béatrice Frank over 10 years ago

population genetics 

Tagged by Béatrice Frank over 10 years ago

salmo trutta 

Tagged by Béatrice Frank over 10 years ago

Child of model DemGenTrout 1.1
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.2 • Viewed 420 times • Downloaded 22 times • Run 0 times
Download the 'DemGenTrout 1.2' 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 is the version 1.2 of a brown trout demogenetic model developed by Beatrice Frank during her PhD thesis (Supervisor: Prof. Philippe Baret, Earth and Life Institute, Universite catholique de Louvain). This version includes features of DemGenTrout 1.1 (faster initialisation) and simulates a barrier to upstream spawning migration.

HOW IT WORKS

The model, named DemGenTrout, was designed to understand how anthropogenic disturbances can affect a brown trout (Salmo trutta L.) population living in a river / nursery brook system of the Lesse River network (Belgium). Changes in the demogenetic (i.e., demography and genetics) structure of the population were monitored, and at a latter stage, the model was used to predict how trout populations might respond to migration barriers and stocking with hatchery trout (Frank & Baret, 2013).

The model has been described following the ODD (Overview, Design concepts, Details) protocol (Grimm et al., 2006; 2010) in DemGenTrout 1.1. The presence of an obstacle at the confluence of the Chicheron brook (stream C) was simulated in the model by simply preventing any upstream movement during the spawning process. All candidate spawners thus stayed in their current stream during the reproduction period. The young trout downstream movement process remained unchanged.

HOW TO USE IT

Click the 'Setup' button to initialise the model. In this version, the values of all variables are imported from the file ''DemGenTrout-world.csv''.

You can change the values of parameters with the sliders, then click the 'change parameters' button, or you can keep the default values (to restore them, click the 'restore parameters' button).

Click the 'go' button to start the simulation (click 'go' again to stop it). The model can also be run weekly ('step-W' button), monthly ('step-M') or yearly ('step-Y'). The two plots on the left vary with time, and show the age distribution of trout in both streams (numbers of trout in each age-class are also displayed below each plot). The first plot on the right shows trout abundance in both streams, and is updated each year at week 1. The second plot represents the number of spawners moving from stream L to stream C for reproduction in winter (upswimming spawners), then moving back to stream L (downswimming spawners). For upswimming spawners, the percentage of spawners born in stream C is indicated (natal homing behaviour). The number of offspring produced in each stream is also monitored. The last plot shows the number of age-1 and age-2 trout migrating from stream C in spring and summer.

THINGS TO NOTICE AND TO TRY

The isolation of the brook from the main river prevents spawners to move upstream and to contribute to offspring production. This results in a severe reduction in trout abundance in stream C, until its complete extinction after 10 years.

The negative relation between abundance and downstream movement of age-2 trout was responsible in great part for this phenomenon. You can test this by changing the variables of this function. With the sliders, set variables A and B of the probability of moving for age-2 migrants identical to those used for age-1 migrants. Click the 'setup' button, change the values of move-age2-varA and move-age2-varB to 0.0026 and -4.8, respectively. Click the buttons 'change parameters' then 'go'. The extinction in stream C occurs later.

RELATED MODELS

DemGenTrout 1.0: This is the first version of the DemGenTrout model, as described in Frank & Baret (2013).

DemGenTrout 1.1: In comparison with DemGenTrout 1.0, the initialisation of this version is faster.

DemGenTrout 1.3: This version includes features of DemGenTrout 1.1 (faster initialisation) and simulates stocking with hatchery trout.

CREDITS AND CITATION

The development of the model was funded by the "Fonds pour la formation a la Recherche dans l'Industrie et dans l'Agriculture" (F.R.I.A.). During the formulation phase, the report describing the inSTREAM model of Railsback et al. (2009) has been an inspirational source. For the programming phase, many of the sample NetLogo models were of great use.

To refer to this model in academic publications, please use: Frank, B.M., Baret, P.V. (2013). Simulating brown trout demogenetics in a river/nursery brook system: The individual-based model DemGenTrout. Ecological Modelling 248: 184-202.

COPYRIGHT AND LICENSE

DemGenTrout 1.2 (2012)

Beatrice M. Frank

Earth and Life Institute

Universite catholique de Louvain

beatrice.frank@gmail.com

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/.

Comments and Questions

About DemGenTrout 1.2

This version includes features of DemGenTrout 1.1 (faster initialisation) and simulates a barrier to upstream spawning migration. An applet of the model is available at: http://sites-final.uclouvain.be/gena-truites/DemGenTrout/DemGenTrout-V1-2.html

Posted over 11 years ago

Click to Run Model

;; DemGenTrout 1.2 (2012)
;;
;; Developed by
;; Beatrice M. Frank
;; Earth and Life Institute
;; Universite catholique de Louvain
;; Beatrice.Frank@gmail.com
;; 
;; Last updated: September 2012

breed[ trout ]
breed[ dead ]
breed[ gone ]

;; trout state variables
trout-own[ sex genotype natal-stream week-of-birth week-of-birth2 ;; fixed
  current-stream age stage status body-length body-weight condition-factor num-offspring
  spawned? moved-to-spawn? returned? ]

;; gone trout state variables
gone-own[ sex genotype natal-stream week-of-birth week-of-birth2 ;; fixed
  current-stream age stage status body-length body-weight condition-factor num-offspring
  spawned? moved-to-spawn? returned? ]

;; dead trout state variables
dead-own[ sex genotype natal-stream week-of-birth week-of-birth2 ;; fixed
  current-stream age stage status body-length body-weight condition-factor num-offspring
  spawned? moved-to-spawn? returned? ]
  
;; stream state variables
patches-own [ stream flow temperature ] 

globals[ week week-of-year month-of-year year
 ;; trout initialisation
 prop-C prop-L init-N
 prop-age0-C prop-age1-C prop-age2-C prop-age3-C
 prop-age0-L prop-age1-L prop-age2-L
 meanl-age0-C meanl-age0-L meanl-age1-C meanl-age1-L meanl-age2-C meanl-age2-L meanl-age3-C meanl-age3-L
 sdl-age0-C sdl-age0-L sdl-age1-C sdl-age1-L sdl-age2-C sdl-age2-L sdl-age3-C sdl-age3-L 
 trdown-age0-C trdown-age0-L trdown-age1-C trdown-age1-L trdown-age2-C trdown-age2-L trdown-age3-C trdown-age3-L
 trup-age0-C trup-age0-L trup-age1-C trup-age1-L trup-age2-C trup-age2-L trup-age3-C trup-age3-L
 meanl-birth-C sdl-birth-C meanl-birth-L sdl-birth-L trdown-C trup-C trdown-L trup-L 
 mean-bcf-C sd-bcf-C mean-bcf-L sd-bcf-L
 propC-inL 
 ;; stream input data
 streamC-discharge streamL-discharge streamC-temperature streamL-temperature 
 mean-dischargeC sd-dischargeC mean-dischargeL sd-dischargeL
 mean-temperatureC sd-temperatureC mean-temperatureL sd-temperatureL
 max-dischargeC max-dischargeL

 ;; survival parameters 
 streamC-age0-survival streamC-age1-survival streamC-age2-survival streamC-age3-survival
 streamL-age0-survival streamL-age1-survival streamL-age2-survival streamL-age3-survival 
 streamC-age0-survival-list streamC-age1-survival-list streamC-age2-survival-list streamC-age3-survival-list
 streamL-age0-survival-list streamL-age1-survival-list streamL-age2-survival-list streamL-age3-survival-list  
; predation-factor
 ;; growth parameters
 streamC-parK streamL-parK
 streamC-max-length streamC-parA streamC-parB streamL-max-length streamL-parA streamL-parB   
 ;; spawning parameters
; spawn-start spawn-end moved-prop spawn-mean-length spawn-mean-cond
 spawn-sd-length spawn-sd-cond spawn-min-age
 spawn-mean-temperature spawn-sd-temperature spawn-mean-flow spawn-sd-flow
 streamC-capacity offprod offprod-min-length offprod-max-length offprod-min
 offspringC-varA offspringC-varB offspringL-varA offspringL-varB
; offprodC-max offprodL-max 
 length-heritability 
 ;; hatching parameters
 hatch-start hatch-end
 ;; downstream movement parameters
; move-start move-end move-min-age move-max-age
 move-mean-length move-sd-length
 move-age1-prob move-age2-prob  
; move-age1-varB move-age1-varA move-age2-varB move-age2-varA 
 move-mean-temperature move-sd-temperature move-mean-flow move-sd-flow
 ;; leaving stream L forever parameters
 leaving-propC leaving-propL
 
 out-year out-month out-week
 ]  

to setup 
  clear-all      
  no-display 
  ;; controlling the random numbers
  random-seed 1223251200
  
  ;; first week of the year = 1st to 7th October included
  set week 1
  set week-of-year 1
  set month-of-year 1
  set year 1 
  
  import-world "DemGenTrout-world.csv"
  reset-ticks
end 

to restore-defaults
  ;; restore the default parameters         
  ;;; input parameters ;;;
  file-open "init-params.txt"
  ;; weekly survival rates for trout in stream C
  if file-read = "streamC.age0.survival" [set streamC-age0-survival file-read]
  if file-read = "streamC.age1.survival" [set streamC-age1-survival file-read] 
  if file-read = "streamC.age2.survival" [set streamC-age2-survival file-read]
  if file-read = "streamC.age3.survival" [set streamC-age3-survival file-read]
  ;; weekly survival rates for trout in stream L  
  if file-read = "streamL.age0.survival" [set streamL-age0-survival file-read]  
  if file-read = "streamL.age1.survival" [set streamL-age1-survival file-read]
  if file-read = "streamL.age2.survival" [set streamL-age2-survival file-read]
  if file-read = "streamL.age3.survival" [set streamL-age3-survival file-read]  
  if file-read = "predation.factor" [set predation-factor file-read]   
  ;; growth parameters
  if file-read = "streamC.parK" [set streamC-parK file-read]
  if file-read = "streamL.parK" [set streamL-parK file-read]  
  if file-read = "streamC.max.length" [set streamC-max-length file-read]
  if file-read = "streamL.max.length" [set streamL-max-length file-read]  
  if file-read = "streamC.parA" [set streamC-parA file-read]
  if file-read = "streamL.parA" [set streamL-parA file-read]  
  if file-read = "streamC.parB" [set streamC-parB file-read]
  if file-read = "streamL.parB" [set streamL-parB file-read]           
  ;; spawning parameters
  if file-read = "spawn.start" [set spawn-start file-read]
  if file-read = "spawn.end" [set spawn-end file-read] 
  if file-read = "spawn.min.age" [set spawn-min-age file-read]      
  if file-read = "spawn.mean.length" [set spawn-mean-length file-read]  
  if file-read = "spawn.sd.length" [set spawn-sd-length file-read]   
  if file-read = "spawn.mean.cond" [set spawn-mean-cond file-read] 
  if file-read = "spawn.sd.cond" [set spawn-sd-cond file-read]  
  if file-read = "moved.prop" [set moved-prop file-read]       
  if file-read = "spawn.mean.flow" [set spawn-mean-flow file-read]  
  if file-read = "spawn.sd.flow" [set spawn-sd-flow file-read]   
  if file-read = "streamC.capacity" [set streamC-capacity file-read]    
  if file-read = "offprod.min.length" [set offprod-min-length file-read] 
  if file-read = "offprod.max.length" [set offprod-max-length file-read]     
  if file-read = "offprod.min" [set offprod-min file-read]         
  if file-read = "offprodC.max" [set offprodC-max file-read] 
  if file-read = "offprodL.max" [set offprodL-max file-read] 
  if file-read = "length.heritability" [set length-heritability file-read]     
  ;; hatching parameters
  if file-read = "hatch.start" [set hatch-start file-read]
  if file-read = "hatch.end" [set hatch-end file-read]      
  ;; downstream movement parameters
  if file-read = "move.start" [set move-start file-read] 
  if file-read = "move.end" [set move-end file-read] 
  if file-read = "move.min.age" [set move-min-age file-read] 
  if file-read = "move.max.age" [set move-max-age file-read]  
  if file-read = "move.mean.length" [set move-mean-length file-read] 
  if file-read = "move.sd.length" [set move-sd-length file-read]     
  if file-read = "move.age1.varA" [set move-age1-varA file-read] 
  if file-read = "move.age1.varB" [set move-age1-varB file-read]  
  if file-read = "move.age2.varA" [set move-age2-varA file-read] 
  if file-read = "move.age2.varB" [set move-age2-varB file-read] 
  if file-read = "move.mean.temperature" [set move-mean-temperature file-read] 
  if file-read = "move.sd.temperature" [set move-sd-temperature file-read] 
  if file-read = "move.mean.flow" [set move-mean-flow file-read] 
  if file-read = "move.sd.flow" [set move-sd-flow file-read]            
  ;; leaving streamL forever parameters
  if file-read = "leaving.propC" [set leaving-propC file-read]  
  if file-read = "leaving.propL" [set leaving-propL file-read]    
  file-close

  set C-age0-survival 0.39 set C-age1-survival 0.37 set C-age2-survival 0.85 set C-age3-survival 0.70
  set L-age0-survival 0.38 set L-age1-survival 0.74 set L-age2-survival 0.87 set L-age3-survival 0.69
end     

to set-parameters 
  ;; weekly survival rates for trout in stream C  
  file-open "streamC-age0-survival.txt"  
  set streamC-age0-survival-list file-read file-close
  file-open "streamC-age1-survival.txt"  
  set streamC-age1-survival-list file-read file-close  
  file-open "streamC-age2-survival.txt"  
  set streamC-age2-survival-list file-read file-close
  file-open "streamC-age3-survival.txt"  
  set streamC-age3-survival-list file-read file-close  
  ;; weekly survival rates for trout in stream L  
  file-open "streamL-age0-survival.txt"  
  set streamL-age0-survival-list file-read file-close  
  file-open "streamL-age1-survival.txt"  
  set streamL-age1-survival-list file-read file-close 
  file-open "streamL-age2-survival.txt"  
  set streamL-age2-survival-list file-read file-close     
  file-open "streamL-age3-survival.txt"  
  set streamL-age3-survival-list file-read file-close   
  
  let seq (list 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
                     0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19
                     0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29
                     0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39
                     0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49
                     0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59
                     0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69
                     0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79
                     0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89
                     0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00)
  let index (list 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
                 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
                 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
                 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
                 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
                 100)
  
  (foreach seq index
    [
      if C-age0-survival = ?1 [set streamC-age0-survival item ?2 streamC-age0-survival-list]
      if C-age1-survival = ?1 [set streamC-age1-survival item ?2 streamC-age1-survival-list]
      if C-age2-survival = ?1 [set streamC-age2-survival item ?2 streamC-age2-survival-list]
      if C-age3-survival = ?1 [set streamC-age3-survival item ?2 streamC-age3-survival-list]                  
      if L-age0-survival = ?1 [set streamL-age0-survival item ?2 streamL-age0-survival-list]
      if L-age1-survival = ?1 [set streamL-age1-survival item ?2 streamL-age1-survival-list]
      if L-age2-survival = ?1 [set streamL-age2-survival item ?2 streamL-age2-survival-list]
      if L-age3-survival = ?1 [set streamL-age3-survival item ?2 streamL-age3-survival-list]
    ])    
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SCHEDULING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go 
  no-display   
  tick 
  if ticks = 1820 [ user-message "Input data are only available for 35 years."  stop ]
  if count trout with [ current-stream = "C" ] = 0 [ user-message (word "There are no trout in the brook at year " year ".") stop ]
  ;; a year = 52 weeks  
  set week-of-year (week mod 52) + 1
  set month-of-year (int(week-of-year / 4.5) mod 52) + 1 
  set year (int(week / 52)) + 1 ; mod 52  
  
  ;; each week

;-- 1. Update stream hydrological conditions ----------------------------------------------------------
  
  ask patches [ update-stream-conditions ] 
  
;-- 2. Kill trout in each stream ----------------------------------------------------------------------

  ask trout [ trout-die ]      
    
;-- 3. Update trout length, weight and condition factor -----------------------------------------------
  
  ask trout [ trout-grow ]  
      
;-- 4. Reproduce trout in each stream ----------------------------------------------------------------- 

  ;; spawning time window: duration = 11 weeks
  if week-of-year >= spawn-start and week-of-year <= spawn-end
  [   
    ;--- 4.1. Identify candidate spawners ---;
    ask trout [ trout-become-candidate-spawners ] 
;    ;; select some of the candidate spawners born in stream L in order to make them reproduce in C
;    let candidate-spawners-streamL trout with [ status = "candidate-spawner" and current-stream = "L" 
;      and natal-stream = "L" and not moved-to-spawn? ]
;    while [ (count trout with [status = "selected-candidate-spawner"]) < (moved-prop * count candidate-spawners-streamL) ]
;    [ ask one-of candidate-spawners-streamL [ set status "selected-candidate-spawner" ] ]      
;    
;    ;--- 4.2. Move candidate spawners upstream ---;   
;    ask trout [ trout-move-to-spawn ]         
    
    ;; adapt offspring production if abundance in C is strictly higher than streamC-capacity
    ifelse count trout with [ current-stream = "C" ] > streamC-capacity 
    [ set offprodC-max offprod / 10 ]
    [ set offprodC-max offprod ]        

    ;--- 4.3. Produce offspring in each stream ---;  
    trout-spawn-in-streamC
    trout-spawn-in-streamL
  ]
    
;-- 5. Increment trout age and update stage -----------------------------------------------------------

  if week-of-year = (hatch-start - 1) ;; one week before hatching
  [ 
    ask trout [ trout-update-age ]
    ask trout with [age > 6] [die!] ;; trout die at age 7    
  ]     
   
;-- 6. Reveal offspring -------------------------------------------------------------------------------   
  
  ;; hatching time window: duration = 11 weeks
  if week-of-year >= hatch-start and week-of-year <= hatch-end
  [ (foreach sort trout with [age = -1]
      [ ask ?
        [
          if (week-of-year - week-of-birth) = (hatch-start - spawn-start) ;; delay = 10 weeks
          [ set hidden? false set age 0 ]
        ]])
  ]
  
;-- 7. Move trout of stream C downstream ----------------------------------------------------------
    
  ;; migration time window: duration = 25 weeks
  if week-of-year >= move-start and week-of-year <= move-end
  [             
    ;--- 7.1. Identify candidate migrants among juveniles ---; 
    ask trout [ trout-become-candidate-migrants ]          
     
    ;--- 7.2. Update movement probabilities ---;     
    update-move-age1-prob   
    update-move-age2-prob      
            
    ;--- 7.3. Move candidate migrants ---;
    ask trout [ trout-move-downstream ]                  
  ]       

;-- 8. Move upswimming spawners back to stream L ----------------------------------------------------- 

  if week-of-year = (spawn-end + 1) ;; the week after the spawning process
  [ 
    ask trout [ trout-move-back ]
  ]                                           
   
;-- 9. Remove young trout of stream L from the system ------------------------------------------------   
  
  ;; at the end of the year
  if week-of-year = 52
  [ 
    ;; some juveniles born in C and living in stream L do not settle and go elsewhere 
    let bornC-in-streamL trout with [current-stream = "L" and natal-stream = "C" and status = "migrant"]    
    let bornC-leaving (leaving-propC * count bornC-in-streamL)
    ask n-of bornC-leaving bornC-in-streamL [ leave-streamL ]  
    ;; some juveniles born in L and living in stream L do not settle and go elsewhere  
    let bornL-in-streamL trout with [current-stream = "L" and natal-stream = "L" and (age = 1 or age = 2)]
    let bornL-leaving (leaving-propL * count bornL-in-streamL)
    ask n-of bornL-leaving bornL-in-streamL [ leave-streamL ]   
  ]                
  
; Trout reset --------------------------------------------------------------------------------------
  
  ;; at the end of the year
  if week-of-year = 52
  [        
    ;; reset trout status and boolean state variables    
    ask trout [ set status "non-spawner" set moved-to-spawn? false set spawned? false set returned? false ] 
    ;; kill all hidden turtles  
    ask gone [die]     
    ask dead [die]          
  ]

; Increment the week -------------------------------------------------------------------------------
   
  set week week + 1
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;; STREAM PROCEDURE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; update water temperature and flow of each stream

to update-stream-conditions
  ifelse ticks < (6 * 52)
  ;; first 6 years (2004 to 2009)
  [
    ifelse stream = "C"
    [
      set flow item week streamC-discharge
      set temperature item week streamC-temperature 
    ]
    [
      set flow item week streamL-discharge
      set temperature item week streamL-temperature
    ]  
  ]
  ;; next years (2010 to 2038)
  [
    ifelse stream = "C"
    [
      set flow min (list max-dischargeC (item week streamC-discharge + random-lognormal mean-dischargeC sd-dischargeC))
      set temperature (item week streamC-temperature + random-normal mean-temperatureC sd-temperatureC) 
    ]
    [
      set flow min (list max-dischargeL (item week streamL-discharge + random-lognormal mean-dischargeL sd-dischargeL))
      set temperature (item week streamL-temperature + random-normal mean-temperatureL sd-temperatureL)
    ]  
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;; TROUT PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; trout mortality

to trout-die
  ;; in stream C
  if stage = "fry" and current-stream = "C" [if random-float 1 > ((item week-of-year streamC-age0-survival) ^ (1 / 52)) [die!]]
  if stage = "juvenile" and age = 1 and current-stream = "C" [if random-float 1 > ((item week-of-year streamC-age1-survival) ^ (1 / 52)) [die!]]
  if stage = "juvenile" and age = 2 and current-stream = "C" [if random-float 1 > ((item week-of-year streamC-age2-survival) ^ (1 / 52)) [die!]]
  if stage = "adult" and age < 6 and current-stream = "C" [if random-float 1 > ((item week-of-year streamC-age3-survival) ^ (1 / 52)) [die!]] 
  if week-of-year >= spawn-start and week-of-year <= spawn-end and moved-to-spawn? = true and current-stream = "C" 
   [if random-float 1 > (((item week-of-year streamC-age3-survival) / predation-factor) ^ (1 / (spawn-end - spawn-start))) [die!]] 
  ;; in stream L
  if stage = "fry" and current-stream = "L" [if random-float 1 > ((item week-of-year streamL-age0-survival) ^ (1 / 52)) [die!]]
  if stage = "juvenile" and age = 1 and current-stream = "L" [if random-float 1 > ((item week-of-year streamL-age1-survival) ^ (1 / 52)) [die!]]
  if stage = "juvenile" and age = 2 and current-stream = "L" [if random-float 1 > ((item week-of-year streamL-age2-survival) ^ (1 / 52)) [die!]]
  if stage = "adult" and age < 6 and current-stream = "L" [if random-float 1 > ((item week-of-year streamL-age3-survival) ^ (1 / 52)) [die!]]
end 

;; individual growth

to trout-grow
  ifelse current-stream = "C"
  [
    ;; von Bertalanffy growth equation for trout in stream C
    set body-length (body-length + (streamC-parK * (streamC-max-length - body-length)))
    let healthy-weight (streamC-parA * ((body-length) ^ streamC-parB)) ;; weight-length regression 
    set body-weight (condition-factor * healthy-weight)      
  ]
  [
    ;; von Bertalanffy growth equation for trout in stream L
    set body-length (body-length + (streamL-parK * (streamL-max-length - body-length)))  
    let healthy-weight (streamL-parA * ((body-length) ^ streamL-parB)) ;; weight-length regression
    set body-weight (condition-factor * healthy-weight)      
  ]
  set condition-factor max (list 0.5 (condition-factor + (- 0.008 + random-float 0.016)))
  ;; test for negative length and negative weight
  if body-length < 0 [ user-message "Negative fish length" ]
  if body-weight < 0 [ user-message "Negative fish weight" ]    
end 

to die!
  set breed dead
  hide-turtle
end 

;; identification of candidate spawners

to trout-become-candidate-spawners
  if age >= spawn-min-age and status != "spawner" and not moved-to-spawn? 
  [ if random-normal spawn-mean-length spawn-sd-length < body-length and 
    random-normal spawn-mean-cond spawn-sd-cond < condition-factor
    [ set status "candidate-spawner" ] ]  
end 

;; movement to stream C for reproduction

to trout-move-to-spawn
 let temperature-streamL [temperature] of one-of patches with [ stream = "L" ]      
 let flow-streamL [flow] of one-of patches with [ stream = "L" ] 
 ;; spawners born in C or in L move to C
 if (status = "candidate-spawner" and not moved-to-spawn? and current-stream = "L" and natal-stream = "C") 
   or (status = "selected-candidate-spawner" and not moved-to-spawn?)     
 [ if random-lognormal spawn-mean-flow spawn-sd-flow < flow-streamL   
   [ set current-stream "C" set xcor 1 set moved-to-spawn? true set status "candidate-spawner" ] ]  
end 

;; update trout age and stage

to trout-update-age
  set age age + 1
  trout-update-stage 
end   

;; update trout stage: fry, juvenile, adult 

to trout-update-stage
  if age < 1 [ set stage "fry" stop ]
  if age >= 1 and age <= 2 [ set stage "juvenile"stop ]
  if age > 2 [ set stage "adult" stop ] 
end 

;; reproduction

to trout-spawn-in-streamC
  let spawners trout with [ status = "candidate-spawner" or status = "spawner" and current-stream = "C" ]  
  ifelse count spawners < 2
  [ stop ]
  [  
    ;; length of parents when born (VBLF backwards)
    let born-length-parents VBLF-reverse spawners    
    ;; mean and variance of length of parents when born
    if length born-length-parents < 2 [ stop ]
    let mean-parents mean born-length-parents
    let var-parents variance born-length-parents
    let num-crossover (floor (count spawners / 2))  
    ;; polygamous mating with satellite males (not in good condition)    
    repeat num-crossover
    [
      let num-males 1 + random 4 ; number of males drawn randomly from an uniform distribution from 1 to 4
      let all-parent-M spawners with [ sex = "M" ]
      if count all-parent-M < num-males [ stop ]         
      let no-parent-M max-n-of num-males spawners with [ sex = "M" ] [condition-factor]
      let sel-parent-M all-parent-M with [ not member? self no-parent-M and not spawned? ]  
      if count spawners with [ sex = "F" and not spawned? ] <= 1 [ stop ] 
      if count sel-parent-M < num-males [ stop ]  
      ;; select the parents: first, the spawners that have moved to spawn, then the other spawners  
      let parent-M n-of num-males sel-parent-M
      let parent-F max-one-of spawners with [ sex = "F" and not spawned? ] [condition-factor]     
      if (count spawners with [ sex = "M" and not spawned? and moved-to-spawn? ] - num-males) >= num-males  
      [ 
        if any? spawners with [ sex = "M" and not spawned? and moved-to-spawn? ] 
        [
          set all-parent-M spawners with [ sex = "M" and moved-to-spawn? ]
          set no-parent-M max-n-of num-males spawners with [ sex = "M" and moved-to-spawn? ] [condition-factor]
          set sel-parent-M all-parent-M with [ not member? self no-parent-M and not spawned? ]           
          set parent-M n-of num-males sel-parent-M
        ]
      ]
      if any? spawners with [ sex = "F" and not spawned? and moved-to-spawn?]
      [ set parent-F max-one-of spawners with [ sex = "F" and not spawned? and moved-to-spawn?] [condition-factor] ]
      ;; length deviances of parents M and F from mean-parents
      let dummy VBLF-reverse parent-M
      let dev-M 0
      let temp (random-normal meanl-birth-C sdl-birth-C)
      if temp < trdown-C [set temp trdown-C]   
      if temp > trup-C [set temp trup-C]                
      if length dummy = 0 [ set dev-M (mean-parents - temp) ]      
      if length dummy = 1 [ set dev-M (mean-parents - (item 0 dummy)) ]        
      if length dummy > 1 [ set dev-M (mean-parents - mean dummy) ]
      let dev-F (mean-parents - (VBLF-reverse parent-F)) 
      ask parent-F
      [
        set spawned? true
        set status "spawner"
        set xcor 1
        let num-fry update-num-offspringC [body-length] of parent-F   
        hatch-trout num-fry
        [
          set hidden? true ;; hide trout until hatching
          set age -1 set stage "fry"  
          ; genotype of parent-M is a mixture of the several genotypes of males
          let genotype-mix mixture ([genotype] of parent-M)
          ;; define genotypes for eggs
          let egg-genotype cross-genotype (genotype-mix) ([genotype] of parent-F)                
          set genotype egg-genotype                         
          set xcor 1
          set current-stream "C"
          set natal-stream "C"
          set num-offspring 0
          set week-of-birth week-of-year      
          set week-of-birth2 (week + 1)          
          ifelse random-float 1 > 0.5 [ set sex "M" ] [ set sex "F" ]
          set status "non-spawner" set spawned? false
          set moved-to-spawn? false set returned? false          
          ;; set body-length as function of parents' length and environment
          let genetic-dev (sqrt length-heritability) * (dev-M + dev-F)    
          let envi-var ((1 - length-heritability) ^ 2) * var-parents
          let envi-dev random-normal 0 (sqrt envi-var) 
          set body-length mean-parents + genetic-dev + envi-dev
          let temp2 (random-normal meanl-birth-C sdl-birth-C)  
          if temp2 < trdown-C [set temp2 trdown-C]   
          if temp2 > trup-C [set temp2 trup-C]                
          if body-length < trdown-C or body-length > trup-C [ set body-length temp2 ]           
          ;; set body-weight and condition-factor
          set condition-factor (random-normal mean-bcf-C sd-bcf-C)         
          set body-weight (condition-factor * ((body-length) ^ 3) / 100000)       
        ] 
        set num-offspring num-fry
      ]
      ask parent-M
      [
        ;set spawned? true ;; shut because males can reproduce more than once
        set status "spawner" 
        set xcor 1        
        set num-offspring [num-offspring] of parent-F               
      ] 
    ]
  ]               
end  

to trout-spawn-in-streamL
  let spawners trout with [ status = "candidate-spawner" or status = "spawner" and current-stream = "L" ]
  ifelse count spawners < 2
  [ stop ]
  [  
    let born-length-parents VBLF-reverse spawners 
    ;; mean and variance of length of parents when born
    if length born-length-parents < 2 [ stop ]  
    let mean-parents mean born-length-parents
    let var-parents variance born-length-parents  
    let num-crossover (floor (count spawners / 2))   
    ;; polygamous mating with satellite males (not in good condition)    
    repeat num-crossover  
    [
      let num-males 1 + random 4 ; number of males drawn randomly from an uniform distribution from 1 to 4
      let all-parent-M spawners with [ sex = "M" ]
      if count all-parent-M < num-males [ stop ]         
      let no-parent-M max-n-of num-males spawners with [ sex = "M" ] [condition-factor]
      let sel-parent-M all-parent-M with [ not member? self no-parent-M and not spawned? ]  
      if count spawners with [ sex = "F" and not spawned? ] <= 1 [ stop ] 
      if count sel-parent-M < num-males [ stop ]  
      ;; select the parents: first, the spawners that have moved to spawn, then the other spawners  
      let parent-M n-of num-males sel-parent-M
      let parent-F max-one-of spawners with [ sex = "F" and not spawned? ] [condition-factor]     
      if (count spawners with [ sex = "M" and not spawned? and moved-to-spawn? ] - num-males) >= num-males  
      [ 
        if any? spawners with [ sex = "M" and not spawned? and moved-to-spawn? ] 
        [
          set all-parent-M spawners with [ sex = "M" and moved-to-spawn? ]
          set no-parent-M max-n-of num-males spawners with [ sex = "M" and moved-to-spawn? ] [condition-factor]
          set sel-parent-M all-parent-M with [ not member? self no-parent-M and not spawned? ]           
          set parent-M n-of num-males sel-parent-M
        ]
      ]
      if any? spawners with [ sex = "F" and not spawned? and moved-to-spawn?]
      [ set parent-F max-one-of spawners with [ sex = "F" and not spawned? and moved-to-spawn?] [condition-factor] ]
      ;; length deviances of parents M and F from mean-parents
      let dummy VBLF-reverse parent-M
      let dev-M 0
      let temp (random-normal meanl-birth-L sdl-birth-L)
      if temp < trdown-L [set temp trdown-L]   
      if temp > trup-L [set temp trup-L]                
      if length dummy = 0 [ set dev-M (mean-parents - temp) ]            
      if length dummy = 1 [ set dev-M (mean-parents - (item 0 dummy)) ]        
      if length dummy > 1 [ set dev-M (mean-parents - mean dummy) ]    
      let dev-F (mean-parents - (VBLF-reverse parent-F))      
      ask parent-F
      [
        set spawned? true
        set status "spawner"
        set xcor 0
        let num-fry update-num-offspringL [body-length] of parent-F 
        hatch-trout num-fry
        [
          set hidden? true ;; hide trout until hatching
          set age -1 set stage "fry"
          ; genotype of parent-M is a mixture of the several genotypes of males
          let genotype-mix mixture ([genotype] of parent-M)
          ;; define genotypes for eggs
          let egg-genotype cross-genotype (genotype-mix) ([genotype] of parent-F)              
          set genotype egg-genotype                                 
          set xcor 0
          set current-stream "L"
          set natal-stream "L"  
          set num-offspring 0   
          set week-of-birth week-of-year      
          set week-of-birth2 (week + 1)              
          ifelse random-float 1 > 0.5 [ set sex "M" ] [ set sex "F" ]    
          set status "non-spawner" set spawned? false
          set moved-to-spawn? false set returned? false                   
          ;; set body-length as function of parents' length and environment
          let genetic-dev (sqrt length-heritability) * (dev-M + dev-F)     
          let envi-var ((1 - length-heritability) ^ 2) * var-parents
          let envi-dev random-normal 0 (sqrt envi-var) 
          set body-length mean-parents + genetic-dev + envi-dev
          let temp2 (random-normal meanl-birth-L sdl-birth-L)  
          if temp2 < trdown-L [set temp2 trdown-L]   
          if temp2 > trup-L [set temp2 trup-L]                         
          if body-length < trdown-L or body-length > trup-L [ set body-length temp2 ]       
          ;; set body-weight and condition-factor
          set condition-factor (random-normal mean-bcf-L sd-bcf-L)
          set body-weight (condition-factor * ((body-length) ^ 3) / 100000)              
        ]
        set num-offspring num-fry
      ]
      ask parent-M
      [
        ;set spawned? true ;; shut because males can reproduce more than once
        set status "spawner"
        set xcor 0      
        set num-offspring [num-offspring] of parent-F
      ]       
    ]  
  ]      
end   

;; stream C

to-report update-num-offspringC [ female-length ] ;; linear function
  ;; compute the intermediate variables for the linear offspring production function for trout of stream C
  set offspringC-varA (offprodC-max - offprod-min) / (offprod-max-length - offprod-min-length)
  set offspringC-varB offprod-min - (offspringC-varA * offprod-min-length) 
  report ((offspringC-varA * female-length) + offspringC-varB)
end 

;; stream L

to-report update-num-offspringL [ female-length ] ;; linear function
  ;; compute the intermediate variables for the linear offspring production function  for trout of stream C
  set offspringL-varA (offprodL-max - offprod-min) / (offprod-max-length - offprod-min-length)
  set offspringL-varB offprod-min - (offspringL-varA * offprod-min-length)    
  report ((offspringL-varA * female-length) + offspringL-varB)
end 

to-report cross-genotype [ genotype1 genotype2 ]
  let new-genotype []
  let bit 0
  repeat length genotype1
  [
    let choice random 4
    if choice = 0
    [ set new-genotype (lput (word(substring (item bit genotype1) 0 4)(substring (item bit genotype2) 0 3)) new-genotype)]
    if choice = 1
    [ set new-genotype (lput (word(substring (item bit genotype1) 0 3) (substring (item bit genotype2) 3 7)) new-genotype)]
    if choice = 2
    [ set new-genotype (lput (word(substring (item bit genotype2) 0 3) (substring (item bit genotype1) 3 7)) new-genotype)]
    if choice = 3
    [ set new-genotype (lput (word(substring (item bit genotype1) 4 7) (substring (item bit genotype2) 3 7)) new-genotype)]      
    set bit bit + 1
  ]
  report new-genotype
end 

to-report mixture [ genotype-temp ]
  let genotype-mix []
  let bit 0
  repeat length one-of genotype-temp
  [
    let choice random (length genotype-temp) ; choose randomly one genotype among n males
    set genotype-mix lput item bit (item choice genotype-temp) genotype-mix
    set bit bit + 1
  ] 
  report genotype-mix
end 

to-report VBLF-reverse [ trout-indiv ]  
  ifelse is-agentset? trout-indiv
  [
    let length-when-born []
    (foreach sort trout-indiv
      [
        let time 0
        let length-diff 0
        let length-when-born-temp 0
        ask ?
        [
          set time (week - week-of-birth2)
          ifelse natal-stream = "C" 
          [ 
            set length-diff (streamC-max-length - body-length)
            set length-when-born-temp (streamC-max-length - (length-diff / ((1 - streamC-parK) ^ (time))))            
          ]
          [ 
            set length-diff (streamL-max-length - body-length)
            set length-when-born-temp (streamL-max-length - (length-diff / ((1 - streamL-parK) ^ (time))))            
          ]
        ]     
        set length-when-born lput length-when-born-temp length-when-born                
      ])
    report length-when-born 
  ]  
  [
    let time (week - ([week-of-birth2] of trout-indiv))      
    ifelse [natal-stream] of trout-indiv = "C"
    [ 
      let length-when-born (streamC-max-length - ((streamC-max-length - [body-length] of trout-indiv) / ((1 - streamC-parK) ^ (time)))) 
      report length-when-born
    ]
    [ 
      let length-when-born (streamL-max-length - ((streamL-max-length - [body-length] of trout-indiv) / ((1 - streamL-parK) ^ (time)))) 
      report length-when-born  
    ]   
  ]   
end 

to trout-become-candidate-migrants
  if (age = move-min-age or age = move-max-age) and current-stream = "C" and natal-stream = "C" 
  [ if random-normal move-mean-length move-sd-length < body-length
    [ set status "candidate-migrant" ] ]
end 

;; movement from C to L

to trout-move-downstream
  let temperature-streamC [temperature] of one-of patches with [ stream = "C" ]  
  let flow-streamC [flow] of one-of patches with [ stream = "C" ]    
  if status = "candidate-migrant"
  [ if random-normal move-mean-temperature move-sd-temperature < temperature-streamC 
    and random-lognormal move-mean-flow move-sd-flow < flow-streamC
    [ ifelse age = 1
      ;; juveniles age 1
      [ if random-float 1 < move-age1-prob 
        [ set xcor 0 set current-stream "L" set status "migrant" ] ]
      ;; juveniles age 2
      [ if random-float 1 < move-age2-prob
        [ set xcor 0 set current-stream "L" set status "migrant" ] ]
    ] 
  ]   
end     

to update-move-age1-prob ;; logistic function
  let nb1 count trout with [current-stream = "C" and body-length > 70]
  let Z1 (exp((move-age1-varA * nb1) + move-age1-varB))
  set move-age1-prob (Z1 / (1 + Z1))  
end 

to update-move-age2-prob ;; logistic function
  let nb2 count trout with [current-stream = "C" and body-length > 70]
  let Z1 (exp((move-age2-varA * nb2) + move-age2-varB))
  set move-age2-prob (Z1 / (1 + Z1))  
end 

to trout-move-back
  ;; candidate spawners return to previous stream
  if (status = "candidate-spawner" and current-stream = "C" and moved-to-spawn?)
  ;; effective spawners return to previous stream
    or (status = "spawner" and current-stream = "C" and moved-to-spawn?)
  [ set current-stream "L" set xcor 0 set returned? true ]  
end 

to leave-streamL
  set breed gone
  hide-turtle
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report random-lognormal [mu sigma]
  let S sqrt(ln(((sigma / mu) ^ 2) + 1))
  let M ln (mu) - ((S ^ 2) / 2)
  report exp(random-normal M S)
end 

There is only one version of this model, created over 11 years ago by Béatrice Frank.

Attached files

File Type Description Last updated
DemGenTrout-V1-2_data.zip data External files for 'DemGenTrout 1.2' about 11 years ago, by Béatrice Frank Download

Parent: DemGenTrout 1.1

This model does not have any descendants.

Graph of models related to 'DemGenTrout 1.2'