BoPeng / simuPOP

A general-purpose forward-time population genetics simulation environment.
http://bopeng.github.io/simuPOP/
GNU General Public License v2.0
31 stars 12 forks source link

change weights in heteroMating within each generation #42

Closed janavanhu closed 7 years ago

janavanhu commented 7 years ago

Dear Bo Peng,

thank you first of all for a great programme!

I am trying to simulate a population with overlapping generations and age specific female fecundity. I use a heteroMating Scheme with CloneMating and HomoMatings that use different parentChoosers and Offspring generators to have females of different age classes produce different numbers of offspring. I would like to determine the weight again each generation, as it depends on the number of females currently within each age group. Is it possible to do that?

Kind regards, Vanessa

BoPeng commented 7 years ago

The mating scheme itself does not provide this feature so you would have to use multiple mating schemes for this purpose. Basically, you can do something like:

for gen in range(1000):
    pop.evolve(...
        HeteroMating(..., weight=weight_func(gen), ...),
        gen = 1)
janavanhu commented 7 years ago

Dear Bo Peng,

thank you very much! That solves my issue!

All the Best, Vanessa

BoPeng commented 7 years ago

Great. The only problem is that if you have operators in preOps and postOps, they will need to be moved outside of the loop to avoid applying these operators repeatedly for each generation.