Example #1
0
 //3.1 DE/selbest/1 scheme
 public void d_evolve_selbest_1(DecisionVector v, DecisionVector sbest, DecisionVector v1, DecisionVector v2, double F, double X)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = sbest.CurrentVector[i] + F * (v1.CurrentVector[i] - v2.CurrentVector[i]);
     }
 }
Example #2
0
 //4.DE/best/2 scheme
 public void d_evolve_best_2(DecisionVector v, DecisionVector vbest, DecisionVector v1, DecisionVector v2, DecisionVector v3, DecisionVector v4, double F)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = vbest.CurrentVector[i] + F * (v1.CurrentVector[i] + v2.CurrentVector[i] - v3.CurrentVector[i] - v4.CurrentVector[i]);
     }
 }
Example #3
0
 //1. DE/rand/1 scheme
 public void d_evole_r_1(DecisionVector v, DecisionVector v1, DecisionVector v2, DecisionVector v3, double F)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = v1.CurrentVector[i] + F * (v2.CurrentVector[i] - v3.CurrentVector[i]);
     }
 }
Example #4
0
 //2.1 DE/current to selbest/1 scheme
 public void d_evolve_rand_selbest_1(DecisionVector v, DecisionVector sbest, DecisionVector v2, DecisionVector v3, double F, double X)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = v.CurrentVector[i] + X * (sbest.CurrentVector[i] - v.CurrentVector[i]) + F * (v2.CurrentVector[i] - v3.CurrentVector[i]);
     }
 }
Example #5
0
 //11. combine linear weight between randtolocalbest to rand/1
 public void d_evolve_randtolocalbest_to_rand_1(DecisionVector v, DecisionVector lbest, DecisionVector v1, DecisionVector v2, DecisionVector v3, DecisionVector v4, DecisionVector v5, double F, double X, double W)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = (1 - W) * (lbest.CurrentVector[i] + X * (lbest.CurrentVector[i] - v.CurrentVector[i]) + F * (v1.CurrentVector[i] - v2.CurrentVector[i])) + W * (v3.CurrentVector[i] + F * (v4.CurrentVector[i] - v5.CurrentVector[i]));
     }
 }
Example #6
0
 //12. combine linear weight between localbest to rand/1
 public void d_evolve_rand1_to_localbest(DecisionVector v, DecisionVector lbest, DecisionVector v1, DecisionVector v2, DecisionVector v3, DecisionVector v4, DecisionVector v5, double F, double X, double W)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = W * lbest.CurrentVector[i] + (1 - W) * v1.CurrentVector[i] + F * (v1.CurrentVector[i] - v2.CurrentVector[i]);
     }
 }
Example #7
0
 //9. combine linear weight between randtolocalBest and randtoBest
 public void d_evolve_rand_localBest_TO_rand_to_Best(DecisionVector v, DecisionVector lbest, DecisionVector vbest, DecisionVector v1, DecisionVector v2, DecisionVector v3, DecisionVector v4, double X, double F, double W)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = (1 - W) * (v.CurrentVector[i] + X * (lbest.CurrentVector[i] - v.CurrentVector[i]) + F * (v2.CurrentVector[i] - v3.CurrentVector[i])) + W * (v.CurrentVector[i] + X * (vbest.CurrentVector[i] - v.CurrentVector[i]) + F * (v2.CurrentVector[i] - v3.CurrentVector[i]));
     }
 }
Example #8
0
 //5.DE/rand/2 scheme
 public void d_evolve_rand_2(DecisionVector v, DecisionVector v1, DecisionVector v2, DecisionVector v3, DecisionVector v4, DecisionVector v5, double F)
 {
     for (int i = 0; i < v.Dimension; i++)
     {
         v.TrialVector[i] = v1.CurrentVector[i] + F * (v2.CurrentVector[i] - v3.CurrentVector[i]) + F * (v4.CurrentVector[i] - v5.CurrentVector[i]);
     }
 }
Example #9
0
        public void randomtrialvector(DecisionVector v)
        // diff way to generate new vector
        {
            Random rnd = new Random();

            for (int i = 0; i < v.Dimension; i++)
            {
                v.TrialVector[i] = rnd.NextDouble();
            }
        }
Example #10
0
 public void Crossover_1point(DecisionVector v, double coRate, Random rnd)
 {
     for (int i = 0; i < v.Dimension; i++) // consider each dimension เลยนะ
     {
         if (rnd.NextDouble() >= coRate)
         {
             v.TrialVector[i] = v.CurrentVector[i];
         }
     }
 }
Example #11
0
        public Population(int nVec, int nDim)
        {   // construct a population with nVec vector,
            // each vector with nDim dimension
            Member = nVec;
            Vector = new DecisionVector[Member]; // declare size of Vector (array)

            lBestVectorIndex = new int[Member];
            sBestVectorIndex = new int[Member];

            for (int i = 0; i < Member; i++)
            {   //Initialize vectors and each vector has nDim dimension
                Vector[i] = new DecisionVector(nDim);
            }
        }
Example #12
0
        public void Crossover_2point(DecisionVector v, double coRate, Random rnd)
        {
            int start_p = rnd.Next(v.Dimension);
            int L       = 0;

            do
            {
                L++;
            }while ((rnd.NextDouble() <= coRate) && (start_p + L < v.Dimension));
            for (int i = start_p; i < start_p + L; i++)
            {
                v.TrialVector[i] = v.CurrentVector[i];
            }
        }
Example #13
0
        public override double Objective(DecisionVector P, int trial)
        {
            double obj = 0;

            //evaluate the objective value corresponding to the position of the Vector
            if (trial == 0)
            {
                for (int i = 0; i < P.Dimension; i++)
                {
                    obj += 0.001 * Math.Pow(P.CurrentVector[i], 2) + 2 * Math.Sin(P.CurrentVector[i]);
                }
            }
            if (trial == 1)
            {
                for (int i = 0; i < P.Dimension; i++)
                {
                    obj += 0.001 * Math.Pow(P.TrialVector[i], 2) + 2 * Math.Sin(P.TrialVector[i]);
                }
            }
            return(obj);
        }
Example #14
0
 public virtual void LocalSearchVector(DecisionVector p, ref Random rnd)
 {
 }
Example #15
0
 public virtual double Objective(DecisionVector p, int trial)
 {       //empty function to be override in the problem specific definition
     //to calculate objective function of a particle
     return(0);
 }