如何创建在种群中选择配偶的多代繁殖



我有一个两种性别的模拟,男性和女性。雌性从一群雄性中选择并产生后代。多个雄性可以与一个雌配,雌性产生多个后代。当它们繁殖时,父母死亡,但有一些特征的遗传,这些特征turtles-own变量。

我在这里得到了帮助,让雌性从可用的雄性池中进行选择(availa-males(。但问题是mates变量在第一轮交配后不起作用。它保持为长度为 0 的agent-set。希望你能帮到忙;如果有什么不清楚的地方,我可以澄清。

to go
if ticks mod 364 = 0 [set year year + 1]

ask turtles [
set mates ( turtle-set ) 
fd 1
set age ticks 
]
ask females [
choose-mates
reproduce
]
tick
end

to choose-mates
ask females   [
; set a cap on possible mates for females; 5, or the number
; available within the radius if less than 5
set availa-males males in-radius 5
let n-max count availa-males
set max-mate-count ifelse-value ( n-max < 5 ) [ n-max ] [ 5 ]
; Until a female has chosen up to her maximum number of mates:
while [ mate-count < max-mate-count ] [
; determine which available males are not already in her 'mates' agentset
set availa-males availa-males with [ not member? self [mates] of myself ]
; assess the proportion of B strategy in remaining available males
let prop_B ( count availa-males with [ anadromous = 0 ] ) / n-max
; example probability choice, just meant to choose B males
; with a frequency disproportionate to availability
let proba_B ifelse-value ( prop_b * 2 < 0.6 ) [ prop_b * 2 ] [ 0.6 ]
; use a random float to determine which strategy type is chosen
set mates ( turtle-set mates ifelse-value ( random-float 1 < proba_B )
[ one-of availa-males with [  anadromous = 0 ] ]
[ one-of availa-males with [  anadromous = 1 ] ]  )
; count the current mates to break the while loop once
; the maximum number of mates is reached
set mate-count count mates
]
; have the female's males add her to their own mates agentset
ask mates [
set mates ( turtle-set mates myself )
]
if n-max < count mates [
print "Fewer available males than mates"
]
set a_threshM [a_threshM] of mates
]
end

to reproduce
ask females with [count mates > 0] [hatch 2  [
set mother myself
set motherThresh [a_threshF] of mother
set fatherThresh sum n-of 1 [a_threshM] of mother  
ifelse random 2 = 1 [set breed males
set color red
set a_threshM  (motherThresh + fatherThresh) / 2 + (random-normal 0 sqrt(0.5 * Va))
set e_threshM random-normal 0 (sqrt(Ve))
set z_threshM a_threshM + e_threshM
set condM random-normal mu_cond  sqrt(V_cond)
ifelse(condM > z_threshM)  [set anadromous 0] [set anadromous 1]
setxy random-xcor random-ycor
]
[set breed females
set color blue
set a_threshF  (motherThresh + fatherThresh) / 2 + (random-normal 0 sqrt(0.5 * Va))
set e_threshF random-normal 0 (sqrt(Ve))
set z_threshF a_threshF + e_threshF
set condF random-normal mu_cond  sqrt(V_cond)
ifelse(condF > z_threshF)  [set anadromous 0] [set anadromous 1]
setxy random-xcor random-ycor
]
] ask mates [die]
die]
end

你的女性"女儿"从母亲那里继承了mate-count。由于mate-countchoose-mateswhile循环的逻辑触发器,请尝试让女儿在孵化时重置mate-count

...
[ set breed females
set color blue
set mate-count 0
...

此外,雌性在繁殖后立即死亡 -go被召唤后剩下的唯一雌性尚未称为choose-mates程序。

您还可以考虑在go过程中将choose-matesreproduce分离为单独的ask females调用。事实上,雌性选择配偶并繁殖,这使她自己和她的配偶远离世界。然后,雌性二选择配偶,这不仅不包括雌性1的配偶,而且可能包括雌性一的产卵。最好执行以下操作:

ask females [
choose-mates
]
ask females [
reproduce 
]

最新更新