示例#1
0
        protected internal override bool Success()
        {
            if (_success)
            {
                return(true);
            }
            GAIndividual best             = _populations[_currentPopulation][_bestIndividual];
            float        predictedFitness = best.GetFitness();

            _predictorGA.EvaluateSolutionIndividual((PushGPIndividual)best);
            _bestMeanFitness = best.GetFitness();
            if (_bestMeanFitness <= 0.1)
            {
                _success = true;
                return(true);
            }
            best.SetFitness(predictedFitness);
            return(false);
        }
示例#2
0
        /// <summary>
        /// NOTE: This is entirely copied from PushGP, except EvaluateIndividual
        /// was changed to PredictIndividual, as noted below.
        /// </summary>
        protected internal override void Evaluate()
        {
            float totalFitness = 0;

            _bestMeanFitness = float.MaxValue;
            for (int n = 0; n < _populations[_currentPopulation].Length; n++)
            {
                GAIndividual i = _populations[_currentPopulation][n];
                PredictIndividual(i, false);
                totalFitness += i.GetFitness();
                if (i.GetFitness() < _bestMeanFitness)
                {
                    _bestMeanFitness = i.GetFitness();
                    _bestIndividual  = n;
                    _bestSize        = ((PushGPIndividual)i)._program.ProgramSize();
                    _bestErrors      = i.GetErrors();
                }
            }
            _populationMeanFitness = totalFitness / _populations[_currentPopulation].Length;
        }