Added functions to calculate diversity for each generation