title: Avoid a GA fitness function with diverging goals getting stuck
body: <p>I'm working on a genetic algorithm as a sort of having-fun-with-programming exercise.</p>
  
  <p>The problem is about mapping two texts in different languages one to another by sentences. Since different translations can start and end sentences in different places, there is a large, but not perfect correspondence between the texts.</p>
  
  <p>So, take for example two strings:</p>
  
  <pre><code>a X. a a Y. a aaa a. X a a. a aa. aaa a Y aa.
  
  X b bb. b Y bb bbb b X bb. bb. b. bb Y. bbb b.
  </code></pre>
  
  <p>where X and Y are anchors and As and Bs language specific words. The gene I'm working on takes all existing sentence breaks (full stops excluding the finishing ones) as binary values; the example above has six sentences in both texts, so ten bits are needed. Working manually, not understanding the text itself, I would assume the best answer is:</p>
  
  <pre><code>10011 11010
  </code></pre>
  
  <p>(1 - no change, 0 - dot removed and sentences merged) which would result in:</p>
  
  <pre><code>a X. a a Y a aaa a X a a. a aa. aaa a Y aa.
  
  X b bb. b Y bb bbb b X bb. bb b. bb Y bbb b.
  </code></pre>
  
  <p>My fitness function evaluates four conditions, as follows:</p>
  
  <ol>
  <li>The number of sentences should be as high as possible.</li>
  <li>There must be an equal number of sentences in both texts.</li>
  <li>The lengths of sentences should be as close as possible.</li>
  <li>As many anchors as possible should be found in the same sentence in both texts (anchors are for example character names in a sample novel I'm using).</li>
  </ol>
  
  <p>However, I'm not getting the result I'm hoping for since the condition 2, which is very important, takes over no matter what I do and evolution stops. If I don't heavily tweak what's happening, I end up either merging the whole thing into one huge sentence (gene 00000 00000 above) or finding the first matching number of sentences and getting stuck.</p>
  
  <p>In general, how can this problem be overcome? How can I make my fitness function not stuck when a list of conditions that work against each other is needed? Should the process be divided into two stages? How can I then reintroduce condition 2 after some evolution? Should I evaluate it every N generations?</p>