[mlpack-git] [mlpack/mlpack] NeuralEvolution - implemented gene, genome (#686)

Marcus Edel notifications at github.com
Sat Jul 2 19:28:25 EDT 2016


> +
> +  // Measure two genomes' weight difference.
> +  // TODO: what if one or two weights are disabled? 0 or still the weight?
> +  double WeightDiff(Genome& genome1, Genome& genome2) {
> +    double deltaW = 0;
> +    ssize_t coincident = 0;
> +
> +    for (ssize_t i=0; i<genome1.NumLink(); ++i) {
> +      int linkEnabledInGenome1 = (int) genome1.aLinkGenes[i].Enabled();
> +      ssize_t innovId = genome1.aLinkGenes[i].InnovationId();
> +      ssize_t idx = genome2.GetLinkIndex(innovId);
> +      bool linkContainedInGenome2 = (idx != -1);
> +
> +      if (linkContainedInGenome2) {
> +        int linkEnabledInGenome2 = (int) genome2.aLinkGenes[idx].Enabled();
> +        deltaW += std::abs(genome1.aLinkGenes[i].Weight() * linkEnabledInGenome1 - 

Neat idea, using the enabled bit.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/686/files/554a279b0089e4385dfb40077e578d6ae2a42ece#r69383713
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160702/dd20b06b/attachment.html>


More information about the mlpack-git mailing list