示例#1
0
文件: Swarm.cs 项目: xiaoxiongnpu/PSO
        /// <summary>
        /// Updates the GlobalBestSolution property.
        /// </summary>
        public void UpdateBestGlobalSolution()
        {
            //Find the best solution in this iteration.
            ISolution iterationBest = this.GlobalBestSolution;

            foreach (IParticle particle in this.Particles)
            {
                if (particle.CurrentSolution.BetterThan(iterationBest))
                {
                    iterationBest = particle.CurrentSolution;
                }
            }
            if (iterationBest.BetterThan(this.GlobalBestSolution))
            {
                this.GlobalBestSolution = iterationBest.Copy();
            }
        }