Exemplo n.º 1
0
        private void performAddPolygon(Gene gene)
        {
            if (gene.Polygons.Count >= this.NrOfPolygons)
            {
                return;
            }
            double oldNegativeFitness           = gene.NegativeFitness;
            AddPolygonMutationChanges bigChange = null;

            for (int i = 0; i < NrOfMutationsTries; i++)
            {
                AddPolygonMutationChanges changes = gene.AddPolygon();
                if (changes != null && gene.NegativeFitness > oldNegativeFitness)
                {
                    gene.RestoreMutation(changes, oldNegativeFitness);
                }
                else if (changes != null)
                {
                    oldNegativeFitness = gene.NegativeFitness;
                    bigChange          = changes;
                    gene.RestoreMutation(changes, changes.OldNegativeFitness);
                }
            }
            gene.ApplyMutation(bigChange);
        }