0

For a current project, I want to use genetic algorithms - currently I had a look at the jenetics library.

How can I force that some genes are dependent on each other? I want to map CSS on the gene, f.e. I have genes indicating if an image is displayed, and in case it is also the respective height and width. So I want to have those genes as a group togheter, as it would make no sense that after a crossover, the chrosome would indicate something like "no image" - height 100px - width 0px.

Is there a method to do so? Or maybe another library (in java) which supports this?

Many thanks!

beatngu13
  • 7,201
  • 6
  • 37
  • 66
lydiaP
  • 123
  • 1
  • 13
  • Wouldn't it be better to just ignore those ? Wouldn't leaving them untied somewhat improve the random side of the genetic algorithm ? –  May 30 '18 at 11:50
  • So you mean, to let the algorithm generate those chromosomes and then prove if they are reasonable? That could also be an option, but for efficancy I would like to already impose those constraints at the generation. – lydiaP May 30 '18 at 11:55
  • FWIW, a lot of real genes are 'junk' or only have value when other genes are turned on . – Pete Kirkham May 30 '18 at 13:53

2 Answers2

1

You want to embed more knowledge into your system to reduce the search space.

If it would be knowledge about the structure of the solution, I would propose taking a look at grammatical evolution (GE). Your knowledge appears to be more about valid combinations of codons, so GE is not easily applicable.

It might be possible to combine a few features into a single codon, but this may be undesirable and/or unfeasible (e.g. due to great number of possible combinations).

But in fact you don't have an issue here:

  • it's fine to have meaningless genotypes — they will be removed due to the selection pressure
  • it's fine to have meaningless codon sequences — it's called "bloat"; bloat is quite common to some evolutionary algorithms (usually discussed in the context of genetic programming) and is not strictly bad; fighting with bloat too much can reduce the search performance
werediver
  • 4,667
  • 1
  • 29
  • 49
0

If you know how your genome is encoded - that is, you know which sequences of chromosomes form groups - then you could extend (since you mention jenetics) io.jenetics.MultiPointCrossover to avoid splitting groups. (Source code available on GitHub.)

It could be as simple as storing ranges of genes which form groups if one of the random cut indexes would split a group, adjusting the index to the nearest end of the group. (Of course this would cause a statistically higher likelihood of cuts at the ends of groups; it would probably be better to generate a new random location until it doesn't intersect a group.)

But it's also valid (as Pete notes) to have genes which aren't meaningful (ignored) based on other genes; if the combination is anti-survival it will be selected out.

DavidW
  • 1,413
  • 10
  • 17
  • Thanks for the answer - but it doesn't answer all aspects of my questions - as even if I group them to not be separated, inside the group the respective values can still bee meaningless. I'm thinking about implementing a logic inside the Mapper which reads the chromosome, so that some genes are decoded depending on previous ones. Would this make sense for you? – lydiaP Jun 06 '18 at 12:00