Esempio n. 1
0
        /// <summary>
        /// Internal method for the iteration of the swarm.
        /// </summary>
        /// <param name="init">true if this is an initialisation iteration.</param>
        protected void IterationPSO(bool init)
        {
            TaskGroup group = EngineConcurrency.Instance.CreateTaskGroup();

            for (int i = 0; i < m_populationSize; i++)
            {
                NeuralPSOWorker worker = new NeuralPSOWorker(this, i, init);
                if (!init && IsMultiThreaded)
                {
                    EngineConcurrency.Instance.ProcessTask(worker, group);
                }
                else
                {
                    worker.Run();
                }
            }
            if (IsMultiThreaded)
            {
                group.WaitForComplete();
            }
            UpdateGlobalBestPosition();
        }
        /// <summary>
        /// Handle an individual particle.
        /// </summary>
        /// <param name="i">The particle index.</param>
        /// <param name="init">True if this is the init pass.</param>
        protected void HandleParticle(int i, bool init)
        {
            NeuralPSOWorker worker = new NeuralPSOWorker(this, i, init);

            worker.Run();
        }
 /// <summary>
 /// Handle an individual particle.
 /// </summary>
 /// <param name="i">The particle index.</param>
 /// <param name="init">True if this is the init pass.</param>
 protected void HandleParticle(int i, bool init)
 {
     NeuralPSOWorker worker = new NeuralPSOWorker(this, i, init);
     worker.Run();
 }
Esempio n. 4
0
        /// <summary>
        /// Internal method for the iteration of the swarm. 
        /// </summary>
        /// <param name="init">true if this is an initialisation iteration.</param>
        protected void IterationPSO(bool init)
        {
            TaskGroup group = EngineConcurrency.Instance.CreateTaskGroup();

            for (int i = 0; i < m_populationSize; i++)
            {
                NeuralPSOWorker worker = new NeuralPSOWorker(this, i, init);
                if (!init && IsMultiThreaded)
                {
                    EngineConcurrency.Instance.ProcessTask(worker, group);
                }
                else
                {
                    worker.Run();
                }
            }
            if (IsMultiThreaded)
            {
                group.WaitForComplete();
            }
            UpdateGlobalBestPosition();
        }