initialize() {
initializeSLiMModelType("nonWF");
initializeSex();
defineConstant("K", 500); // carrying capacity
}
reproduction() {
// monogamous mating between whoever is around
males = p1.subsetIndividuals(sex="M");
females = p1.subsetIndividuals(sex="F");
pairs = min(size(males), size(females));
// sample down to the number of pairs; this also shuffles the individuals
males = sample(males, pairs);
females = sample(females, pairs);
// mate pairs, with a mean litter size of 2.5
for (m in males, f in females)
p1.addCrossed(f, m, count=rpois(1, 2.5));
// everybody has reproduced; don't do any more reproduction this tick
self.active = 0;
}
1 early() {
sim.addSubpop("p1", K);
}
early() {
p1.fitnessScaling = K / p1.individualCount;
}
2000 late() { }
It might not do exactly what you want. In general, the first step should be to work out *exactly* what you want to have happen, with pencil and paper. Who mates with who, what happens if the sex ratio is unbalanced, etc.? Once you know exactly what you want to have happen, I find the correct implementation in code is generally much clearer. Happy modeling!
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/620762bb-bab3-4d2c-b437-5a346a947a7cn%40googlegroups.com.