Skip to content

Commit

Permalink
changed fitness impact
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-lg committed Mar 31, 2021
1 parent d11d36c commit 5be971c
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 47 deletions.
2 changes: 1 addition & 1 deletion model/FDM.nlogo
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ to setup

set no-output temp-no-output

set model-version "V1.3.1"
set model-version "V1.4.0"

if behaviorspace-run-number > 0 [ random-seed behaviorspace-run-number ]

Expand Down
34 changes: 23 additions & 11 deletions model/flies.nls
Original file line number Diff line number Diff line change
Expand Up @@ -565,24 +565,35 @@ to fly-activities
let fertile-female-adult-flies female-adult-flies with [ partner-search = TRUE ]

ask fertile-female-adult-flies [

let fertile-male-adult-flies-here flies-here with [ sex = "m" and mode = "adult" and partner-search = TRUE ]

let mating-chance random-float 1
let fertile-male-adult-flies-here flies-here with [ sex = "m" and mode = "adult" and partner-search = TRUE and fitness >= mating-chance ]

; if female fly detects male fly on same patch => start fertilization
if any? fertile-male-adult-flies-here [
set partner-search FALSE
set fertilization-tick ticks
set eggs eggs-per-cycle

let partner n-of 1 fertile-male-adult-flies-here
; "[genotype] of partner" and "[fitness] of partner" return lists
set genotype-of-partner first [genotype] of partner
set fitness-of-partner first [fitness] of partner
set combined-fitness ( fitness * fitness-of-partner )
set color orange
ask partner [
set partner-search FALSE
set fertilization-tick ticks
]

let mating-success random-float 1
ifelse ( fitness >= mating-success ) [

set partner-search FALSE
set fertilization-tick ticks
set eggs eggs-per-cycle
; "[genotype] of partner" and "[fitness] of partner" return lists
set genotype-of-partner first [genotype] of partner
set fitness-of-partner first [fitness] of partner
set combined-fitness ( fitness * fitness-of-partner )
set color orange

] [
start-immature-state
]

]

]
Expand Down Expand Up @@ -620,7 +631,8 @@ to fly-activities
]

; fitness rate
if random-float 1 > combined-fitness [ set lay-egg FALSE ]
; deactivated. new impact of fitness: mating chance(m)/success(f)
; if random-float 1 > combined-fitness [ set lay-egg FALSE ]

ifelse lay-egg [

Expand Down
115 changes: 80 additions & 35 deletions model/verification.nls
Original file line number Diff line number Diff line change
Expand Up @@ -1736,45 +1736,90 @@ to-report test-fitness [ verification-file ]
let log-header "test-fitness: "
let log-content ""

; check if cherry and fruit number get reduced if egg gets not layed due to fitness

refresh-world
; grow cherries
ask trees [
set grown-cherries 5
set occupied-cherries 0
; FIRST TEST
; 300 trials
; 1 female / 1 male fly
; female fitness 1
; male fitness 0.4
; mating success should be around 40%

let trials 300
let trial 1
let matings 0
while [ trial <= trials ] [

refresh-world
random-seed new-seed

set init-pop 2
start-season
ask flies with-min [who] [
set sex "f"
set fitness 1
move-to min-one-of trees [who] ; move to tree with lowest id
]
ask flies with-max [who] [
set sex "m"
set fitness 0.4
move-to min-one-of trees [who] ; move to tree with lowest id
]

fly-activities

; check mating
if count flies with [ sex = "f" and eggs > 0 ] > 0 [
set matings ( matings + 1 )
]

set trial ( trial + 1 )
]
set cherries-available TRUE
; grow wildberries
ask wildberry-plants [
set grown-wildberries 5
set occupied-wildberries 0
; Most of the time the result should be between .38 and .42, but due to low total trials it may happen that the deviation is slightly higher. Therefore, .36 and .44 chosen for boundaries.
if ( matings / trials ) < 0.36 or ( matings / trials ) > 0.44 [
set log-content ( word log-content "CHECK FITNESS: first test failed - mating success not around 40% (" round( matings / trials * 100 ) "%); " )
]
set wildberries-available TRUE
; create flies
set init-pop 1
start-season
; modify flies
ask flies [
set sex "f"
set ready-to-lay-egg TRUE
set eggs 1
set genotype "++"
set genotype-of-partner "++"
set fitness 0
set fitness-of-partner 0
set combined-fitness 0
set fertilization-tick 0
move-to min-one-of trees [who] ; move to tree with lowest id

; SECOND TEST
; 300 trials
; 1 female / 1 male fly
; female fitness 0.6
; male fitness 1
; mating success should be around 60%

set trials 300
set trial 1
set matings 0
while [ trial <= trials ] [

refresh-world
random-seed new-seed

set init-pop 2
start-season
ask flies with-min [who] [
set sex "f"
set fitness 0.6
move-to min-one-of trees [who] ; move to tree with lowest id
]
ask flies with-max [who] [
set sex "m"
set fitness 1
move-to min-one-of trees [who] ; move to tree with lowest id
]

fly-activities

; check mating
if count flies with [ sex = "f" and eggs > 0 ] > 0 [
set matings ( matings + 1 )
]

set trial ( trial + 1 )
]
fly-activities
; check values
if count flies with [ mode = "adult" ] != 1 [
set log-content word log-content "CHECK FITNESS: wrong number of adult flies; "
; Most of the time the result should be between .56 and .64, but due to low total trials it may happen that the deviation is slightly higher. Therefore, .56 and .64 chosen for boundaries.
if ( matings / trials ) < 0.56 or ( matings / trials ) > 0.64 [
set log-content ( word log-content "CHECK FITNESS: second test failed - mating success not around 60% (" round( matings / trials * 100 ) "%); " )
]
if count flies with [ mode = "stationary" ] != 0 [
set log-content word log-content "CHECK FITNESS: wrong number of stationary flies; "
]


write-verification-result-to-file verification-file log-header log-content
ifelse length log-content > 0 [ report FALSE ] [ report TRUE ]
Expand Down

0 comments on commit 5be971c

Please # to comment.