2

I'm trying to implement a genetic algorithm on my own which optimizes two vectors. There is a boundary condition, where a has always to be bigger than b. The entries of the vectors are in the range of 1 to 15. My implementation worked for 1 vector, but the genetic algorithm doesn't converge for 2 vectors. The vectors are tested in a physical model which give out a standard deviation which should be minimal at 0. It is possible to reach this value and im trying to find it with the genetic algorithm I wrote.

I could break down the problem to recombination and mutation: When recombinating or mutating b has the possibility to get greater than a. The physical model which tests the vectors doesn't make sense anymore at this point so the fitness value sinks, although it was good before.

For mutation I could solve the problem with bad style to only allow values which keep b smaller than a. For recombination though I don't get how to solve this problem withouth breaking the idea of a genetic algorithm.

e.g. the parents are:

a1 = 1,1,9,9 and a2 = 9,9,1,1.

b1 = 1,3,1,3 and b2 = 3,1,3,1

a1' = 1,1,1,1 and a2' = 9,9,9,9

b1' = 1,3,3,1 and b2' = 3,1,1,3

Then b1' is bigger than a1'.

The algorithm converges to a point where it jumps back to low fitness levels as the solutions a and b seem to be very similar to each other, so the algorithm converges until a certain point, fails and then starts again.

I think I'm missing the point somewhere but can't find it.

Andy
  • 81
  • 6
  • This might not make sense depending on other aspects of your model, but one possible resolution would be to let the encoding be of two indistinguishable vectors, of which the bigger one gets named `a` and the smaller one `b` for the purposes of evaluation (that is, when vector 2 becomes bigger than vector 1, the evaluation automatically swaps them) – Ben Voigt Feb 17 '18 at 23:18
  • @BenVoigt They may not be comparable at all... – user58697 Feb 18 '18 at 12:16
  • I don't think it's 'bad style' for any of your variation operators to reject candidates that are invalid. If your recombination rule produces a candidate that breaks the rule, discard it and try again (up to a maximum number of retries). This is how the [evtree](http://www.jstatsoft.org/v61/i01/) algorithm works, for example. – nekomatic Feb 21 '18 at 09:07

0 Answers0