0

I am implementing the Genetic Algorithm in python to decode a message. in every generation, I print the maximum fitting score of the population. But after reaching about a specific number it stops growing. For example, I see these numbers:

Generation0: 17, Generation1: 20, ..., Generation50: 110, Generation51: 120,..., Generation100 = 120.

I select the crossover point and mutations randomly, but it did not improve my algorithm. Can anyone give me a suggestion to avoid this problem? I think this is the repetition problem. Also, I tried to add chromosomes with a low fitting score to parents of the next offspring when this problem happens, but it had not a great impact.

Thanks.

Maryam
  • 119
  • 1
  • 1
  • 6
  • you lost me my friend!. – v78 Mar 30 '20 at 09:51
  • @v78 What do you mean? Do you have any suggestions? – Maryam Mar 30 '20 at 09:57
  • Do you know what the optimal fitting score is? Also what do you mean by "decode a message"? – Olivier Mar 30 '20 at 10:04
  • @Olivier I want to decode a message that was encoded and see what it is actually: for example in an encoded message every character is replaced by another character( a: c, b: y, ,...). and optimal fitting score is the number of all vocabs in encoded message. (around 300) – Maryam Mar 30 '20 at 10:38
  • But if you don't know the original message, how do you compute the fitting score? – Olivier Mar 30 '20 at 10:44
  • @Olivier I have a global words file that it contains all possible words that happen to be in a message. ( actually it is homework so they gave it to us.) – Maryam Mar 30 '20 at 10:47
  • So you're looking for a letter permutation that mazimizes the number of valid decoded words? How do you do the crossover and mutation? Be careful not to create invalid chromosomes (no repetition allowed in the permutation). – Olivier Mar 30 '20 at 10:56
  • @Olivier yes, Ido. I used a dictionary as chromosome. It contains the equal character in decoded text: For example: chromozom1: {a: b, b: y, c: d,..., z: a}. I choose two random points and do crossover. Also, I use a random number of alphabets and change their equal characters. – Maryam Mar 30 '20 at 11:17
  • For permutation chromosomes, you should use [crossovers that preserve valid permutations](https://en.wikipedia.org/wiki/Crossover_(genetic_algorithm)#Crossover_for_ordered_lists). The same is true for mutations; you can use a swap mutation for example. – Olivier Mar 30 '20 at 11:41
  • There is another issue. When evaluating the fitting score, a solution that gives almost valid words should get a higher score than one that gives only garbage. For example, if a solution gives "almzst dzne", it should get a good score (say, 1.8) while a solution that gives "foljes ghkw" should get 0. – Olivier Mar 30 '20 at 11:43

0 Answers0