Beispiel #1
0
        public override FoodType Mutate()
        {
            FoodType ret      = _mutationFunc(this.Food);
            double   _fitness = Bee <FoodType> .GetFitness(ret, _fitnessFunc);

            if (this.Fitness.Equals(defaultFitness) || _fitness < this.Fitness || (useLahc && this.lahc.Update(_fitness)))
            {
                this.Fitness = _fitness;
                this.Food    = ret;
                this._timeSinceLastImprovement = 0;
            }
            else
            {
                this._timeSinceLastImprovement += 1;
                //Solution has not improved
                if (this._timeSinceLastImprovement >= this._nonImprovementLimit)
                {
                    this.ChangeToOnlooker();
                }
            }
            return(this.Food);
        }
Beispiel #2
0
        public virtual FoodType Mutate()
        {
            FoodType ret      = _mutationFunc(this.Food);
            double   _fitness = Bee <FoodType> .GetFitness(ret, _fitnessFunc);

            if (this.Fitness.Equals(defaultFitness) | (Movement == Search.Direction.Optimization && _fitness < this.Fitness) ||
                (Movement == Search.Direction.Divergence && _fitness > this.Fitness))
            {
                this.Fitness = _fitness;
                this.Food    = ret;
                this._timeSinceLastImprovement = 0;
            }
            else
            {
                this._timeSinceLastImprovement += 1;
                //Solution has not improved
                if (this._timeSinceLastImprovement >= this._nonImprovementLimit)
                {
                    this.ChangeToOnlooker();
                }
            }
            return(this.Food);
        }