<p>In <a href="https://github.com/mlpack/mlpack/pull/686#discussion_r70633242">src/mlpack/methods/ne/neat.hpp</a>:</p>
<pre style='color:#555'>&gt; +      }  
&gt; +    }
&gt; +  }
&gt; +
&gt; +  // Crossover two genome to get one genome.
&gt; +  void Crossover(Genome&amp; genome1, Genome&amp; genome2, Genome&amp; childGenome) {
&gt; +    if (CompareGenome(genome1, genome2)) {  // genome1 is better
&gt; +      CrossoverLinkAndNeuron(genome1, genome2, childGenome);
&gt; +    } else {
&gt; +      CrossoverLinkAndNeuron(genome2, genome1, childGenome);
&gt; +    }
&gt; +  }
&gt; +
&gt; +  // Measure two genomes&#39; disjoint (including exceed).
&gt; +  // NOTICE: we can separate into disjoint and exceed. But currently maybe it is enough.
&gt; +  double Disjoint(Genome&amp; genome1, Genome&amp; genome2) {
</pre>
<p>Let us distinguish between disjoint and excess here. At the same time, we can decrease the runtime, by not looping over the genomes twice:</p>

<pre><code>size_t disjoint = 0;
size_t excess = 0;

if (genome1.NumLink() &gt;= genome2.NumLink())
{
    DisjointExcess(genome1, genome2, disjoint, excess);
}
else
{
    DisjointExcess(genome2, genome1, disjoint, excess);
}


void DisjointExcess(Genome&amp; genome1, Genome&amp; genome2, size_t&amp; disjoint, size_t&amp; excess, size_t&amp; matching)
{
    size_t maxInovation = genome2.GetMaxInnovation();

    for (size_t i = 0; i &lt; genome1.NumLink(); ++i)
    {
        size_t innovationNumber = genome1.aLinkGenes[i].InnovationId();

        if (!genome2.ContainLink(innovId))
        {
            if (innovationNumber &gt; maxInovation)
            {
                excess += 1;
            }
            else
            {
                disjoint += 1;
            }
        }
        else
        {
            matching += 1;
        }
    }

    disjoint += genome2.NumLink() - matching;
}
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/686/files/ff45785b8669f82beb38ef5392f48bcdf5c83f6a#r70633242">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFDsXkWt5AX_-YJSu51YGNw_FMPEuks5qVPOQgaJpZM4IwJa6">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFEgKbwz_JV3jM4dQttzqv4tMPmjVks5qVPOQgaJpZM4IwJa6.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/686/files/ff45785b8669f82beb38ef5392f48bcdf5c83f6a#r70633242"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>