Inheritance/Population Simulation.

Over the past few weeks I have been considering trying to write a sort of population simulator - ie, you have a sample of say 100 individuals (very basic individuals) and you let it run. They have some genes (currently the code has two, but it could be expanded) and these genes affect how long they live, how sexually mature they become, basically how likely they are to pass on their genetics. It would therefore show a sort of selection, and because of this would also show a population maximum.

This weekend I decided to finally start writing this, and so far it is going well. It currently has a hard set population maximum (5,000, but it can be changed in the code), however I am planning on changing this so it has a set amount of food in the environment, and as individuals grow they take up more food depending on their gene code, and then when they die this food (- some which cannot be released) is given back into the environment. If the food runs out, some organisms may have an ability to survive without, but others won't - so they will die out but the survivors will have more food.

At the moment, it creates 100 individuals with two random genes - x and y - which determine their survival characteristics. Currently it is based around the following equations;

age_{max} = 2000|sin(\frac{x}{10}) \cdot cos(\frac{y}{10})|

age_{spread} = 1000|sin(\frac{y}{10}) \cdot cos(\frac{x}{10})|

This means that as the x and y values change, the maximum age and spread change - so certain configurations will be more stable than others. The probability of reproduction is modeled as a normal distribution using;

\frac{1}{spread\cdot \sqrt{2\pi}} e^{-\frac{(age - \frac{age_{max}}{2})^{2}}{2\cdot age_{spread}^2}}

This gives a probability of reproduction, so the survival is sort of down to chance. If an individual reproduces then their genes change as they are passed on (only slightly) so the most successful genes are likely to survive. At the moment (without the food construct) individuals die at their maximum age multiplied by a factor which is dependent on the number of individuals in the population;

age_{relmax} = age_{max} * (1-\frac{pop^3}{pop_{max}^3})

So, as the number of individuals increases, the age at which individuals dies gets smaller - so in the graphs we see a boom bust population change, as when it gets too big individuals die, and when it gets too low they live longer.

Hopefully this new project will continue to grow. For now, the source is on github, and an image of the program is shown below.


The population reaches a stable position which is just below the max capacity.
The population reaches a stable position which is just below the max capacity.

Christmas and New Years!

I just wanted to take this time to wish everyone a very (late) Merry Christmas, and a Happy New Year +6! I hope everything over the last year went well, and that the year ahead will be even better!

ChemKit is currently in hiatus as I have mock exams coming up and other work to do (dreaded coursework soon, the problem of doing science A Levels!). I am also thinking of writing some sort of population simulator to aid with biology - think of it as in you have a population of say 100 organisms who have different genetic fingerprints (say 20 digits long). Each digit has a specific advantage or disadvantage, and they may affect each other in different ways. Sexual reproduction could be shown through the combination of different genetics to produce offspring, and through probabilities the likelihood of a member reaching sexual maturity could be shown, hence showing inheritance. I could then have certain factors which could change (and maybe be affected by the organisms - ie a lot of organisms might lead to an increase in temperature) which would then show selection. As the different genes would be interfering it could mean that many solutions are stable (think of it like equation solutions) and this could show speciation as the populations diverge.

In terms of reading, recently I have read "Life's Greatest Secret" by Matthew Cobb, "All the Light We Cannot See" by Anthony Doerr, "Human Universe" by Brian Cox and "The Secret War" by Max Hastings. I enjoyed each of these books, and looking back on it now I have apparently been reading quite varied recently. I am currently reading "All Hell Let Loose" by Max Hastings, and I am going to be reading "The Mysterious World of the Human Genome" by Frank Ryan, "Life Unfolding" by Jamie A. Davis, and possibly having a reread of Metro 2033.

Anyway, as said, I hope you all had a nice Christmas and have a brilliant new year.