예제 #1
0
        public FocalParticle(EFunction functionType, EConstrictionFactor constrictionType, List <AbstractPSOParticle> swarm, bool isFocalParticle) : base(functionType, constrictionType)
        {
            this.swarm           = swarm;
            this.IsFocalParticle = isFocalParticle;

            foreach (AbstractPSOParticle abs in swarm)
            {
                if (((FocalParticle)abs).IsFocalParticle)
                {
                    focalParticle = abs;
                    break;
                }
            }
        }
        public override void UpdateSpeed()
        {
            //Selecionar partícula mais "relevante"
            AbstractPSOParticle bestParticle = neighbors.OrderBy(x => x.PersonalBest).First();

            //Fazer as matemágicas
            for (int i = 0; i < Parameters.DIMENSION_AMOUNT; i++)
            {
                Velocity[i] = constriction.CalculateVelocity
                              (
                    Velocity[i], random.NextDouble(), random.NextDouble(),
                    Position[i], bestParticle.PositionPBest[i], PositionPBest[i]
                              );
            }
        }
예제 #3
0
        public override void UpdateSpeed()
        {
            //FocalParticle seleciona a particula mais "influente"
            AbstractPSOParticle bestParticle = null;

            if (IsFocalParticle)
            {
                bestParticle = swarm[0];

                for (int j = 0; j < Parameters.PARTICLE_AMOUNT; j++)
                {
                    if (swarm[j].PersonalBest < bestParticle.PersonalBest)
                    {
                        bestParticle = swarm[j];
                    }
                }
            }

            for (int i = 0; i < Parameters.DIMENSION_AMOUNT; i++)
            {
                if (IsFocalParticle)
                {
                    Velocity[i] = constriction.CalculateVelocity
                                  (
                        Velocity[i], random.NextDouble(), random.NextDouble(),
                        Position[i], PositionPBest[i], bestParticle.PositionPBest[i]
                                  );
                }
                else
                {
                    Velocity[i] = constriction.CalculateVelocity
                                  (
                        Velocity[i], random.NextDouble(), random.NextDouble(),
                        Position[i], focalParticle.Position[i], PositionPBest[i]
                                  );
                }
            }
        }
예제 #4
0
 public Swarm(ETopology topology, EFunction function, EConstrictionFactor constrictionFactor)
 {
     AbstractPSOParticle.ClearStaticFields();
     ParticleList = AbstractPSOParticle.CreateSwarm(topology, function, constrictionFactor, Parameters.PARTICLE_AMOUNT);
 }