Christmas: Slices Of Slices
Over Christmas, I built a prototype version of the genetic algorithm that uses binary values. I fixed most issues but I am currently having a problem with the crossover function of the genetic algorithm. It seems that Go has no convenient way of appending or merging elements from two slices of slices.
Currently I have created a matrix that represents the whole population. It’s a simple slices of slices that forms a matrix (e.g. genePopulation). Each slice in the matrix represents an individual from the population and it’s sub-slice defines that individuals chromosome. During genetic crossover, the genes from each individuals chromosome are swapped at certain points to create hybrids of the individuals which are referred to as the children. Doing this crossover efficiently in a slice of slices is proving a challenge. What needs to be done is grab two slices from the genePopulation, then pick a point within the two slices at which the elements from one [:3]slice, will be merged with the elements from another [3:]slice to create a new child. Attempts have been made using the inbuilt functions for merge and append which have all failed. Attempts to manually do this through new slices proved troublesome as the assignment operator passes a reference to the subsection of the old slices which leads to the overwriting of the values for individuals in the population.
When I deal with this problem, I can then focus on parallelising the genetic algorithm and getting the HFC (Hierarchical Fair Competition) structure of the algorithm implemented. The planned completion date for this is this week.