예제 #1
0
        //==============================================================================
        static int best(Swarm SW)
        {
            // Find the rank of the best position
            // 	Remember that f is Math.Abs(fitness-ObjectiveValue)
            // 	We want to minimise it
            int s = 0;
            int best = 0;

            for (s = 1; s < SW.S; s++)
            {
                if (betterThan(SW.P[s].f, SW.P[best].f) == 1)
                    best = s;
            }
            return best;
        }
예제 #2
0
        //==============================================================================
        static int worst(Swarm SW)
        {
            // Find the rank of the worst position
            int s = 0;
            int worst = 0;

            for (s = 1; s < SW.S; s++)
            {
                if (betterThan(SW.P[worst].f, SW.P[s].f) == 1)
                    worst = s;
            }
            return worst;
        }