Ejemplo 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();
        }
Ejemplo n.º 2
0
        /// <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();
 }
Ejemplo 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();
        }