예제 #1
0
        public void Initialize()
        {
            double high = function.BOUNDARY_MAX * 0.1;
            double low  = function.BOUNDARY_MIN * 0.1;

            //Random distribution around the search space
            for (int i = 0; i < Position.Length; i++)
            {
                Position[i] = (function.BOUNDARY_MAX - function.BOUNDARY_MIN) * random.NextDouble() + function.BOUNDARY_MIN;
            }

            PersonalBestPosition = (double[])Position.Clone();

            PersonalBestFitness = function.CalculateFitness(Position);

            if (GlobalBestFitness == 0 && GlobalBestPosition == null)
            {
                GlobalBestPosition = (double[])PersonalBestPosition.Clone();
                GlobalBestFitness  = PersonalBestFitness;
            }

            UpdateFitness();
        }
예제 #2
0
        public virtual void Initialize()
        {
            double high = function.BOUNDARY_MAX * 0.1;
            double low  = function.BOUNDARY_MIN * 0.1;

            //Random distribution around the search space
            for (int i = 0; i < Position.Length; i++)
            {
                Position[i] = (function.BOUNDARY_MAX - function.BOUNDARY_MIN) * random.NextDouble() + function.BOUNDARY_MIN;
                Velocity[i] = (high - low) * random.NextDouble() + low;
            }

            PositionPBest = (double[])Position.Clone();

            PersonalBest = function.CalculateFitness(Position);

            if (GlobalBest == 0 && PositionGBest == null)
            {
                PositionGBest = (double[])PositionPBest.Clone();
                GlobalBest    = PersonalBest;
            }

            UpdateFitness();
        }