示例#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;
                }
            }
        }
示例#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]);
                }
            }
        }