Search⌘ K
AI Features

Tracking Statistics in Your Framework

Explore how to implement statistics tracking in genetic algorithm frameworks using Elixir. Understand how to collect, update, and access evolution data such as fitness scores to monitor algorithm progress and convergence patterns.

Adding tracking feature in our framework

Before we can access the different statistics of evolution, we need to ensure our algorithm tracks them after every generation. To do this, we will have to implement a new function statistics that runs immediately after your population is evaluated and updates the statistics server appropriately.

Start by updating evolve/4 in lib/genetic.ex to call statistics/2, like this:

C++
def evolve(population, problem, generation, opts \\ []) do
population = evaluate(population, &problem.fitness_function/1, opts)
statistics(population, generation, opts)
best = hd(population)
# ...
end

Next, we need to implement statistics/3. To customize the statistics we take between generations, we can accept a ...