Ejemplo n.º 1
0
        private float GetBestFitness()
        {
            bool taken = false;

            FitnessLock.Enter(ref taken);
            var ret = BestFitness;

            FitnessLock.Exit(true);
            return(ret);
        }
Ejemplo n.º 2
0
        private void Root_FitnessFunctionEvaluated(Job job, int gen, float fitness)
        {
            bool taken = false;

            if (Maximize)
            {
                FitnessLock.Enter(ref taken);
                if (BestFitness < fitness)
                {
                    BestFitness = fitness;
                }
                FitnessLock.Exit(true);
            }
            else
            {
                FitnessLock.Enter(ref taken);
                if (BestFitness > fitness)
                {
                    BestFitness = fitness;
                }
                FitnessLock.Exit(true);
            }
        }