netlogoagent-based-modeling

All turtles are mating in NetLogo even after setting a condition


Edit: I solved this issue. The problem was that I had set adult = true while creating females.

I'm new to NetLogo and I'm having some problems for which I couldn't find an answer in the internet.

I have made colonies within which males and females live. Males have a constant size of 10 and females have sizes set by a random-normal distribution. I would like only females with size >= 10 to mate. However, when I run the model, all females (even those below size 10) are mating. Would much appreciate if the error in the code can be pointed-out. Below is my code. In the interest of your time, I'm pasting only the relevant parts. Also, please note that the model building is still in progress...

colonies-own [Avg-primary-sex-ratios Adult-sex-ratios colony-size]
males-own [Sperm-sex-ratios body-size home-colony num-of-children adult? genotype]
females-own [primary-sex-ratios mating-status? body-size home-colony num-of-exes num-of-children adult?] 

to make-females
ask colonies
[hatch-females round ((initial-colony-size * 90) / 100)
[
set shape "spider"
set color yellow
set home-colony myself
set size 0.8]
]
ask females
[
set body-size mean (list 6 (random-normal 10 2) 14)
set num-of-exes 0
set num-of-children 0
set adult? True
set mating-status? False
]
end

to-report initial-colony-size
report mean (list 20 (random-normal 60 5) 120)
end

to go
make-male-adults
make-female-adults
make-sperm
mate-with-an-adult-female
tick
end


to make-male-adults
ask males
[
if body-size >= 10 [set adult? True]
]
end

to make-female-adults
ask females
[
if body-size >= 10 [set adult? True]
]
end

to make-sperm ; males make a range of sperm-sex ratios ranging from 50:50 to 100:0 female:male sperm
ask males
[if adult?
[set sperm-sex-ratios mean (list (random-float 101)) ]
if sperm-sex-ratios <= 50 [set color black]
if sperm-sex-ratios > 50 and sperm-sex-ratios <= 70 [set color violet]
if sperm-sex-ratios > 70 [set color orange]
]
end

to mate-with-an-adult-female
ask males
[
if adult? 
[
ask females
[
if adult? and num-of-exes <= 4
[
set mating-status? True
set num-of-exes num-of-exes + 1
set color white]
]
]
]
end

I would like only those female turtles which pass a certain condition to mate.However, all female turtles are mating



Solution

  • I solved this issue. The problem was that I had set adult = true while creating females while setting-up the turtles.