Beispiel #1
0
 private void Step_Animate_Swarm(Color[] pColor, int s)
 {
     //Animation.GraphPane.CurveList.Clear();
     for (int pType = 0; pType < 4; pType++)
     {
         double[] xx = new double[((ArrayList)AniS[s]).Count];
         double[] yy = new double[((ArrayList)AniS[s]).Count];
         for (int i = 0; i < ((ArrayList)AniS[s]).Count; i++)
         {
             if (((Particle)((ArrayList)AniS[s])[i]).type == pType)
             {
                 xx[i] = ((Particle)((ArrayList)AniS[s])[i]).Objective[0];
                 yy[i] = ((Particle)((ArrayList)AniS[s])[i]).Objective[1];
             }
         }
         DrawGraph.CreateXYScatter(Animation, xx, yy, "spType" + pType.ToString(), "Animation_StepS", pColor[pType]);
     }
     if ((s % 50 == 0) || (s == Ani.Count))
     {
         Animation.GraphPane.XAxis.Scale.MaxAuto = true;
         Animation.GraphPane.XAxis.Scale.MinAuto = true;
         Animation.GraphPane.YAxis.Scale.MaxAuto = true;
         Animation.GraphPane.YAxis.Scale.MinAuto = true;
     }
     else
     {
         Animation.GraphPane.XAxis.Scale.MaxAuto = false;
         Animation.GraphPane.XAxis.Scale.MinAuto = false;
         Animation.GraphPane.YAxis.Scale.MaxAuto = false;
         Animation.GraphPane.YAxis.Scale.MinAuto = false;
     }
 }
Beispiel #2
0
        private void MOPSOrun_Click(object sender, EventArgs e)
        {
            double[]  index;
            ArrayList Average;

            double[]  PSOparas = new double[19];
            ArrayList Pareto   = new ArrayList();
            DateTime  start    = DateTime.Now;

            PSOparas[0]  = Convert.ToDouble(this.PSOiter.Value);
            PSOparas[1]  = Convert.ToDouble(this.PSOnumParticles.Value);
            PSOparas[2]  = Convert.ToDouble(this.PSOwmin.Text);
            PSOparas[3]  = Convert.ToDouble(this.PSOwmax.Text);
            PSOparas[4]  = Convert.ToDouble(this.PSOnb.Value);
            PSOparas[5]  = Convert.ToDouble(this.PSOcp.Text);
            PSOparas[6]  = Convert.ToDouble(this.PSOcg.Text);
            PSOparas[7]  = Convert.ToDouble(this.PSOcl.Text);
            PSOparas[8]  = Convert.ToDouble(this.PSOcn.Text);
            PSOparas[9]  = Convert.ToDouble(this.nElite.Text);
            PSOparas[10] = Convert.ToDouble(this.percTopE.Text);
            PSOparas[11] = Convert.ToDouble(this.percBotE.Text);
            PSOparas[12] = Convert.ToDouble(this.percGapU.Text);

            PSOparas[13] = Convert.ToDouble(this.ptype1.Text);
            PSOparas[14] = Convert.ToDouble(this.ptype2.Text);
            PSOparas[15] = Convert.ToDouble(this.ptype3.Text);
            PSOparas[16] = Convert.ToDouble(this.ptype4.Text);
            PSOparas[17] = Convert.ToDouble(this.randomS.Text);
            PSOparas[18] = Convert.ToDouble(this.nRep.Text);


            //for (int strategy = 1; strategy < 7; strategy++)
            //for (int strategy = 5; strategy < 6; strategy++)
            MainClass.PSO(problem, PSOparas, (int)moveS.Value, this.cAnimation.Checked, out index, out Pareto, out Ani, out AniS, out Average);

            TimeSpan finish = DateTime.Now - start;

            PSOGraph.GraphPane.CurveList.Clear();
            for (int i = 0; i < Average.Count; i++)
            {
                DrawGraph.CreateXY(PSOGraph, index, (double[])Average[i], pColor[i + 1], i + 1);
            }

            double[] xx = new double[Pareto.Count];
            double[] yy = new double[Pareto.Count];
            for (int i = 0; i < Pareto.Count; i++)
            {
                xx[i] = ((Particle)Pareto[i]).Objective[0];
                yy[i] = ((Particle)Pareto[i]).Objective[1];
            }
            PSO_Pareto.GraphPane.CurveList.Clear();
            DrawGraph.CreateXYScatter(PSO_Pareto, xx, yy, "Pareto Front", "Non-dominated front", Color.Blue);

            ObjVal.Text       = finish.ToString();
            NumberPareto.Text = Pareto.Count.ToString();
            // Enable animation function
            if (this.cAnimation.Checked)
            {
                this.AniStep.Enabled     = true;
                this.AniStepRun.Enabled  = true;
                this.PSO_dynamic.Enabled = true;
                this.AniSpeed.Enabled    = true;
            }
            else
            {
                this.AniStep.Enabled     = false;
                this.AniStepRun.Enabled  = false;
                this.PSO_dynamic.Enabled = false;
                this.AniSpeed.Enabled    = false;
            }
        }