# Genetic Algorithms in Elixir: Ch 3 chromosome metadata not maintained (~p 144)

**URL:** <https://forum.devtalk.com/t/genetic-algorithms-in-elixir-ch-3-chromosome-metadata-not-maintained-p-144/3418>\
**Category:** PragProg Customers\
**Tags:** suggestion, book-genetic-algorithms-in-elixir\
**Created:** [25 October 2020 03:49 UTC](https://forum.devtalk.com/t/genetic-algorithms-in-elixir-ch-3-chromosome-metadata-not-maintained-p-144/3418 "2020-10-25T03:49:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![patrickdm](https://forum.devtalk.com/user_avatar/forum.devtalk.com/patrickdm/32/629_2.png) [@patrickdm](https://forum.devtalk.com/u/patrickdm)\
**Post date:** [25 October 2020 04:33 UTC](https://forum.devtalk.com/t/genetic-algorithms-in-elixir-ch-3-chromosome-metadata-not-maintained-p-144/3418/2 "2020-10-25T04:33:36Z")

</div>

I’ve also stumped upon the missing size when I tried to use it in `crossover/2` as `p1.size` instead of recalculating `length(p1.genes)` at each iteration. I took a while to figure out it was not retained after initializing the chromosome’s population.

About the chromosome update you mention, we can discuss if you really want the age to increase after a crossover (when you get a kind of new chromosome) or if we should consider a new generation only after a mutation. But I think this are not so relevant aspects in respect of the main code’s objective.

Similar consideration goes for the silly optimization I made in `evaluate/3`, when I opted to use the precalculated fitness for the last sorting step:

```auto
...
|> Enum.sort_by(& &1.fitness, &>=/2)

```

---

_[View the full topic](https://forum.devtalk.com/t/genetic-algorithms-in-elixir-ch-3-chromosome-metadata-not-maintained-p-144/3418)._
