Well, this turned out to be much more complicated than expected! The
change needed to your model is simple; just drop this modifyChild()
callback into your script:
// disallow too many offspring from one parent
// note reproductiveOutput has already been incremented when this is called!
// so to get a maximum of 10, return F when it is already greater than 10!
if ((parent1.reproductiveOutput > 10) | (parent2.reproductiveOutput > 10))
The reason it was complicated is that this work exposed a bug in SLiM
that I needed to fix: when a modifyChild() callback rejected a proposed
child, the reproductiveOutput counters for the parents nevertheless got
incremented. That bug prevented the code above from working at all;
since individuals were so often rejected as parents, their
reproductiveOutput counters would spin upward like crazy – even if the
offspring had been rejected because the *other* parent's
reproductiveOutput value was too high. So everybody soon got
disqualified as a parent, and SLiM couldn't generate any offspring at
all any more, and it would terminate after a million failed tries.
I have now fixed that bug and pushed the fix to GitHub. So, the above
code will work, but ONLY if you run it against the current GitHub head
version of SLiM. Sorry for the added complication. Instructions for
building from sources (both slim and SLiMgui) are in chapter 2 of the
manual. This bug fix will be released in SLiM 3.7, which will probably
be out in a couple of weeks but no definite date has been chosen yet.
I hope this helps; happy modeling!
BY THE WAY: for anyone else reading this, I fixed another bug with
reproductiveOutput as well; or at least it was arguably a bug. When a
parent generates an offspring through selfing or cloning,
reproductiveOutput was incremented by *two*. I think that was
intentional, perhaps to represent the passing on of two chromosomes'
worth of genetic material when you self/clone, as opposed to passing on
just one chromosomes' worth when you produce an offspring through
biparental mating. However, I don't think it's the right behavior for
most users, and I don't think it's likely to be what most people would
expect when they hear the property name "reproductiveOutput"; most
people think "how many offspring have I been the parent of?", however
those offspring were generated. So that's what the bahevior is now –
selfing/cloning now increments the reproductiveOutput of the parent by
1, not 2. This will break backward compatibility for anyone who was
relying on it being 2 in this case, but my guess is very few people were
using this at all since it was only added in SLiM 3.5. If anyone has a
strong objection to this change, please email me off-list to discuss
Benjamin C. Haller
Olivia Johnson wrote on 10/26/21 8:10 AM: