示例#1
0
文件: Particle.cs 项目: Bilzac/457a
        public Particle Clone()
        {
            Particle p = new Particle(this.particle_number);

            this.x.CopyTo(p.x, 0);
            this.velocity.CopyTo(p.velocity, 0);

            p.SetFitness(this.fitness);
            return p;
        }
示例#2
0
文件: Particle.cs 项目: Bilzac/457a
        // constructor
        public Particle(int p_number)
        {
            // init random
            r = new Random();

            // init array
            this.x = new double[10];
            this.velocity = new double[10];

            // init pbest, velocity
            this.pbest = null; //high number
            this.lbest = null;

            // store particle number
            this.particle_number = p_number;

            // populate x value with random numbers from -10.0 to 10.0
            for (int i = 0; i < 10; i++)
            {
                r = new Random(p_number + i + r.Next());
                this.x[i] = r.Next(-10, 10) * r.NextDouble(); // x[i]
                this.velocity[i] = 0.0;
            }
        }
示例#3
0
文件: Particle.cs 项目: Bilzac/457a
 // set personal best pbest
 public void SetPBest(Particle pbest)
 {
     this.pbest = pbest;
 }
示例#4
0
文件: Particle.cs 项目: Bilzac/457a
 // set local best lbest
 public void SetLBest(Particle lbest)
 {
     this.lbest = lbest;
 }