Ejemplo n.º 1
0
        protected void UpdateNeighbours(int i, MoChromosome offSpring)
        {
            int cnt = 0;

            for (int j = 0; j < this.neighbourSize; j++)
            {
                int          weightindex = neighbourTable[i][j];
                MoChromosome sol         = mainpop[weightindex];

                double d = UpdateCretia(weightindex, offSpring);
                double e = UpdateCretia(weightindex, sol);

                if (isCave == true)
                {
                    if (d < e)
                    {
                        offSpring.CopyTo(mainpop[weightindex]);
                        cnt++;
                    }
                }
                else
                {
                    if (d > e)
                    {
                        offSpring.CopyTo(mainpop[weightindex]);
                        cnt++;
                    }
                }

                if (cnt >= nr)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        protected void UpdateNeighbours(int i, MoChromosome offSpring)
        {
            for (int j = 0; j < this.neighbourSize; j++)
            {
                int          weightindex = neighbourTable[i][j];
                MoChromosome sol         = mainpop[weightindex];

                double d = UpdateCretia(weightindex, offSpring);
                double e = UpdateCretia(weightindex, sol);
                if (d < e)
                {
                    offSpring.CopyTo(mainpop[weightindex]);
                }
            }
        }