Beispiel #1
0
        public void UpdatePopulation(bool saveFitnessLog = false)
        {
            if (saveFitnessLog)
            {
                GlobalBestLog = new List <double>();
            }

            for (int i = 0; i < Bee.FoodSourceList.Count; i++)
            {
                EmployedParticleList[i].DeployFoodSourceForParticle(i);
                ScoutParticleList[i].DeployFoodSourceForParticle(i);
            }

            for (int i = 0; i < Parameters.ITERATION_AMOUNT; i++)
            {
                Bee.CalculateFoodSourceFitness();
                Bee.CalculateFoodSourceProbability();
                Bee.SortFoodSourceByProbability();

                EmployedParticleList.ForEach(x =>
                {
                    x.SendEmployedBees();
                    x.UpdateFitness();
                });

                OnlookerParticleList.ForEach(x =>
                {
                    x.SendOnlookerBees();
                    x.UpdateFitness();
                });

                ScoutParticleList.ForEach(x =>
                {
                    x.SendScoutBees();
                });

                if (saveFitnessLog)
                {
                    GlobalBestLog.Add(Bee.GlobalBestFitness);
                }

                Console.WriteLine(i + " " + Bee.GlobalBestFitness);
            }
        }
Beispiel #2
0
 public void InitializeSwarm()
 {
     ScoutParticleList.ForEach(x => x.Initialize());
     OnlookerParticleList.ForEach(x => x.Initialize());
     EmployedParticleList.ForEach(x => x.Initialize());
 }