예제 #1
0
파일: Manager.cs 프로젝트: cckobal/BitNeat
        /// <summary>
        /// Performs lifecycles untill the fitness is reached
        /// </summary>
        /// <param name="fitness">The fitness to be reached</param>
        public Network TrainUntil(double fitness)
        {
            if (EvaluationFunction == null)
            {
                throw new Exception("EvaluationFuntion has to be set first!");
            }

            if (Mutator == null)
            {
                throw new Exception("Mutator has to be set first!");
            }

            //Perform lifecycles untill the fitness is reached
            while (CurrentPopulation.MaxFitness < fitness)
            {
                Next();
            }

            return(new Network(CurrentPopulation.GetFittestMember()));
        }