Bug Report

Mar 27, 2012 at 6:22 AM

I think I found a bug in GeneVectorIndividual.cs in GenomeLength setter the original code is:

            set
            {
                var s = (GeneVectorSpecies)Species;
                var newGenome = new VectorGene[value];
                Array.Copy(genome, 0, newGenome, 0, genome.Length < newGenome.Length ? genome.Length : newGenome.Length);
                for (var x = genome.Length; x < newGenome.Length; x++)
                {
                    if (genome[x] == null)
                    {
                        genome[x] = (VectorGene)s.GenePrototype.Clone(); // not reset
                    }
                }
                genome = newGenome;
            }

The red lines are wrong since the new gene prototype clones should be added to newGenome and not genome the fix is:

            set
            {
                var s = (GeneVectorSpecies)Species;
                var newGenome = new VectorGene[value];
                Array.Copy(genome, 0, newGenome, 0, genome.Length < newGenome.Length ? genome.Length : newGenome.Length);
                for (var x = genome.Length; x < newGenome.Length; x++)
                {
                    if (newGenome[x] == null)
                    {
                        newGenome[x] = (VectorGene)s.GenePrototype.Clone(); // not reset
                    }
                }
                genome = newGenome;
            }

This issue is raised only when trying to work with lists, in vectors there is not problem since the length is set and equal

Roey

Coordinator
Apr 10, 2012 at 5:05 PM

Roey,

You are right! I've reported the bug to the ECJ team, and I'll try and post a new version here as soon as I have a smidgen of free time.

Thanks!

Ben