TheoreticalEcology / EcoPhyloSim

R package for simulation of biogeographical and phylogenetic data
http://theoreticalecology.github.io/EcoPhyloSim/
0 stars 0 forks source link

Mortality implementation #80

Open florianhartig opened 7 years ago

florianhartig commented 7 years ago

Comment Tankred: Right now the fitness can take values above 1. According to the mortality based reproduction, an individual can't die when its fitness is greater than or equal to 1. However, we are staying in this while loop till we reach numerOfRuns deaths. This seems to me like a huge ressource sink. The m_mortalityStrength variable tries to solve this problem. Every m_mortalityStrength'th step the randomly chosen individual dies, no matter its fitness. Still all steps in between can potentially "get stuck" for a long time.

TankredO commented 7 years ago

It works right now, so i am not really keen on changing it. However, if we change it, it might be worth to look at some kind of Roulette Wheel Selection with replacement. E.g. calculate all weights once (n x m, very expensive calculation of fitness) and then select according to fitness (n x m again, but inexpensive). Now comes the bad part (at least I don't know how to do it better): when drawing one individual, it must removed from the roulette list/array or whatever data structure. This is potentially n x m for each draw. To solve this we could use a hashmap. But a hashmap potentially uses massive memory. I am sure there must be a better way to do this. I'm just leaving this here to remember it later.