如何在人口中选择配偶的情况下创建多代复制

问题描述 投票:0回答:1

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

我让help here让女性从可用的男性池(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
netlogo
1个回答
2
投票

你的女性“女儿”从母亲那里继承了mate-count。由于mate-countwhilechoose-mates循环的逻辑触发器,尝试让女儿在孵化时重置他们的mate-count

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

此外,女性在复制后立即死亡 - 在被称为go之后离开的唯一女性还没有称为choose-mates手术。

你也可以考虑在你的choose-mates程序中将reproduceask females分离成单独的go调用。就像这样,女性选择配偶和繁殖,从而将自己和她的伴侣从世界中移除。然后,女性选择配偶,这不仅不包括女性1的配偶,而且可能包括女性配偶。做一些事情可能会更好:

  ask females [
    choose-mates
  ]
  ask females [
    reproduce 
  ]
© www.soinside.com 2019 - 2024. All rights reserved.