示例#1
0
        /// <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()));
        }