Exemplo n.º 1
0
        private bool AddToMap(Individual toAdd)
        {
            var features = new int[NumFeatures];

            for (int i = 0; i < NumFeatures; i++)
            {
                features[i] = GetFeatureIndex(i, toAdd.Features[i]);
            }
            string index = string.Join(":", features);

            bool replacedElite = false;

            if (!EliteMap.ContainsKey(index))
            {
                _eliteIndices.Add(index);
                EliteMap.Add(index, toAdd);
                CellCount.Add(index, 0);
                replacedElite = true;
            }
            else if (EliteMap[index].Fitness < toAdd.Fitness)
            {
                EliteMap[index] = toAdd;
                replacedElite   = true;
            }

            CellCount[index] += 1;
            return(replacedElite);
        }
Exemplo n.º 2
0
        private bool AddToMap(Individual toAdd)
        {
            string index = GetIndex(toAdd);

            bool replacedElite = false;

            if (!EliteMap.ContainsKey(index))
            {
                toAdd.IsNovel = true;
                toAdd.Delta   = toAdd.Fitness;
                _eliteIndices.Add(index);
                EliteMap.Add(index, toAdd);
                CellCount.Add(index, 0);
                replacedElite = true;
            }
            else if (EliteMap[index].Fitness < toAdd.Fitness)
            {
                toAdd.Delta     = toAdd.Fitness - EliteMap[index].Fitness;
                EliteMap[index] = toAdd;
                replacedElite   = true;
            }

            CellCount[index] += 1;
            return(replacedElite);
        }