示例#1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title      = "Open Matrix File";
            openFileDialog1.DefaultExt = "xlsx";
            openFileDialog1.Filter     = "Excel files (*.xlsx)|*.xlsx";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                label1.Text = openFileDialog1.FileName;
            }

            OpenExcel      a        = new OpenExcel(label1.Text);
            featureModel   fmO      = new featureModel(a.OldMatrix);
            PaireSet       newPairs = new PaireSet(a.newPairs);
            Compare        c        = new Compare(fmO, newPairs, a.ChangedFeatureList);
            FilterTestCase f        = new FilterTestCase(c);

            for (int i = 0; i < c.NewPairs.Count; i++)
            {
                listBox1.Items.Add(c.NewPairs[i].Feature1 + "," + c.NewPairs[i].Feature2);
            }
            listBox2.DataSource = f.RetestableTestCases;
            listBox3.DataSource = f.ReUsableTestCases;
            listBox4.DataSource = f.ObsoleteTestCases;
            listBox5.DataSource = GetPairsList(c.Changed);
            listBox6.DataSource = GetPairsList(c.SamePairs);
            listBox7.DataSource = GetPairsList(c.RemovedPairs);
            int[]    rowcol = new int[2];
            string[] arg    = new string[1];
            arg[0]        = "Regression";
            rowcol[0]     = f.Matrix.GetLength(0);
            rowcol[1]     = f.Matrix.GetLength(1);
            NSGAII.Matrix = f.Matrix;
            NSGAII.RowCol = rowcol;
            NSGAII.Main(arg);
        }
示例#2
0
文件: Form1.cs 项目: masuodfathi/jm
        private void Button1_Click(object sender, EventArgs e)
        {
            CleareLabel();

            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Title      = "Open Matrix File";
            openFileDialog1.DefaultExt = "xlsx";
            openFileDialog1.Filter     = "Excel files (*.xlsx)|*.xlsx";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileName = getFileName(openFileDialog1.FileName.Split('\\').Last());
                string path = openFileDialog1.FileName;
                CurrentFileName = path.Split('\\').Last();
                label1.Text     = path;

                OpenExcel a = new OpenExcel(label1.Text);
                fmO = new featureModel(a.OldMatrix);
                PaireSet newPairs = new PaireSet(a.newPairs);
                compair = new Compare(fmO, newPairs, a.ChangedFeatureList);
                filter  = new FilterTestCase(compair);

                Faults = setFaults(compair.ChangedPairs.Count);

                List <string> list1Source = new List <string>();
                for (int i = 0; i < compair.NewPairs.Count; i++)
                {
                    list1Source.Add(compair.NewPairs[i].Feature1 + "," + compair.NewPairs[i].Feature2);
                }

                listBox1.DataSource = list1Source;
                listBox2.DataSource = filter.RetestableTestCases;
                listBox3.DataSource = filter.ReUsableTestCases;
                listBox4.DataSource = filter.ObsoleteTestCases;
                listBox5.DataSource = GetPairsList(compair.ChangedPairs);
                listBox6.DataSource = GetPairsList(compair.SamePairs);
                listBox7.DataSource = GetPairsList(compair.RemovedPairs);
                int[]    rowcol = new int[2];
                string[] arg    = new string[1];
                arg[0] = "Regression";

                rowcol[0]     = filter.Matrix.GetLength(0);
                rowcol[1]     = filter.Matrix.GetLength(1);
                NSGAII.Matrix = filter.Matrix;

                NSGAII.RowCol = rowcol;
                NSGAII.Main(arg);

                //JMetalCSharp.Core.SolutionSet s = new JMetalCSharp.Core.SolutionSet();
                List <string> fun = new List <string>();
                Var = NSGAII.variables;
                fun = NSGAII.fun;
                //fun.Sort();
                listBox8.DataSource = Var;
                listBox9.DataSource = SeperateFun(fun);



                RC = new computingRandom(fmO, compair, filter, Faults);
                double Randomreusability = RC.GetReusability(fmO.Pairs, RC.Variable.ToList());
                LRCover.Text = RC.UnCoverage;
                LRCost.Text  = RC.Cost;
                LRFDE.Text   = RC.FDE.ToString();
                string[] algo = listBox9.Items[0].ToString().Split("\t"[0]);

                int[] ourVariable = new int[compair.TestName.Count];
                ourVariable = SetOurVariable(filter.removedTest, Var[0]);


                computingRandom mr = new computingRandom();

                double MyFDE         = mr.GetFDE(ourVariable, Faults, compair.ChangedPairs);
                double MyReusability = mr.GetReusability(fmO.Pairs, ourVariable.ToList(), compair.ChangedPairs.Count);
                //double MyReusability = mr.GetReusability(compair.ChangedPairs, ourVariable.ToList(),compair.ChangedPairs.Count);
                Reusability    = (MyReusability - Randomreusability) / Randomreusability;
                MyFDE          = Math.Round(MyFDE, 2);
                Reusability    = Math.Round(Reusability, 2);
                Lcoverage.Text = algo[0];
                Lcost.Text     = algo[1].Trim();
                LFDE.Text      = MyFDE.ToString();


                //Appearence -------------------------------------------------------------
                if (Convert.ToDouble(RC.UnCoverage) > Convert.ToDouble(algo[0]))
                {
                    tick1.Text      = "\u2714";
                    tick1.ForeColor = Color.FromArgb(80, 200, 80);
                }
                else
                {
                    tick1.Text      = "X";
                    tick1.ForeColor = Color.FromArgb(200, 80, 80);
                }
                if (Convert.ToDouble(RC.Cost) > Convert.ToDouble(algo[1]))
                {
                    tick2.Text      = "\u2714";
                    tick2.ForeColor = Color.FromArgb(80, 200, 80);
                }
                else
                {
                    tick2.Text      = "X";
                    tick2.ForeColor = Color.FromArgb(200, 80, 80);
                }
                if (Convert.ToDouble(RC.FDE) < Convert.ToDouble(MyFDE))
                {
                    tick3.Text      = "\u2714";
                    tick3.ForeColor = Color.FromArgb(80, 200, 80);
                }
                else
                {
                    tick3.Text      = "X";
                    tick3.ForeColor = Color.FromArgb(200, 80, 80);
                }
                //Appearence -------------------------------------------------------------
                //SaveCompairViaRandom
                SaveCompairViaRandom(MyReusability, Randomreusability);
                saveResult(path);

                int    numberoftest = 0;
                string variable     = Var[0];
                for (int i = 0; i < Var[0].Length; i++)
                {
                    if (variable[i].ToString() == "1")
                    {
                        numberoftest++;
                    }
                }
                //int numberOfSelectedTest =  filter.RetestableTestCases.Count;
                double            newCover = 1 - Convert.ToDouble(algo[0]);
                VersionEvaluation Ve       = new VersionEvaluation(fmO.Pairs, compair.initialSamePairs, newPairs.PairsList.Count, numberoftest, Faults, compair.ChangedPairs, MyFDE, MyReusability, newCover);
                SaveVersionEval   SEV      = new SaveVersionEval(Ve.M5, Ve.M6, Ve.M7, Ve.M8, CurrentFileName);
                SEV.Run();

                Dolabel();
            }
        }