Genetic Algorithms in Elixir Book Club!

I think it would be possible to have all valid rows and all valid columns but still not have all valid sub-grids.

I don’t think that’s your issue with efficiency though.

FWIW my naive solution is struggling as well. I’m just using a list of integers 1..9 with length 81 as the board. The puzzle input is processed with each wildcard/blank replaced by random integer 1..9 to generate the chromosome. Crossover is at a random point in the list. Mutation is a potential problem. The way the lib is setup in the book the mutation function is hard coded and not modifiable per problem. In this case we can’t shuffle the genes outright because the puzzle provides some fixed values. Should mutation/2 and maybe even crossover/2 be part of the behaviour callbacks?
For now I’ve just set the mutation rate to zero. I’m using a wholesale population reset if the temperature drops below a certain value and a generation limit to terminate if perfect fitness is not found. Can’t figure out why but for some reason after the first time it resets it then resets after every generation automatically unless I reset with a really high default temperature. It’s still not getting anywhere close to a full solution though. I think the best fitness I’ve seen is 7 out of a needed 27. I haven’t let it run more than a few hundred generations yet though.