예제 #1
0
파일: AutoTester.cs 프로젝트: JanJPK/PEA_1
        /// <summary>
        ///     Przyjmuje listę kilku testów i zwraca dla każdego wynik.
        /// </summary>
        /// <param name="tests">Testy do wykonania.</param>
        /// <param name="form">Referencja do interfejsu (potrzebne do wyświetlania informacji o postępach).</param>
        /// <returns>Wyniki testów.</returns>
        public static IEnumerable <TestResult> Multiple(List <Test> tests, FormMain form)
        {
            startTime = form.Date;
            form.ShowProgress("Start pracy. Ilość zadań: " + tests.Count());
            List <TestResult> testResults = new List <TestResult>();

            foreach (Test test in tests)
            {
                TestResult testResult = new TestResult(test);
                for (int i = 0; i < test.TestAmount; i++)
                {
                    SalesmanData data =
                        new SalesmanData(DataGenerator.Salesman(test.CityAmount, test.LowerBound, test.UpperBound));
                    SalesmanBnB salesman = new SalesmanBnB(data);

                    Clock.Start();
                    salesman.Start();
                    double time = Clock.StopAndReturn();

                    testResult.Times.Add(time);
                    form.ShowProgress("Zadanie " + (tests.IndexOf(test) + 1) + "; wykonane testy: " + (i + 1) + " z " +
                                      test.TestAmount);
                }
                form.ShowProgress("Wykonane zadania: " + (tests.IndexOf(test) + 1) + " z " + tests.Count);
                testResults.Add(testResult);
            }

            return(testResults);
        }
예제 #2
0
 /// <summary>
 ///     Start komiwojażera.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonSalesman_Click(object sender, EventArgs e)
 {
     if (salesmanData != null)
     {
         if (checkBoxSalesmanBnB.Checked)
         {
             salesmanBnB = new SalesmanBnB(salesmanData);
             Clock.Start();
             salesmanBnB.Start();
             textBoxSalesmanBnB.Text = Clock.StopAndReturn().ToString();
         }
     }
     else
     {
         MessageBox.Show("Dane nie zostały wczytane!", "Błąd",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #3
0
파일: AutoTester.cs 프로젝트: JanJPK/PEA_1
        /// <summary>
        ///     Pojedynczy test.
        /// </summary>
        /// <param name="test"></param>
        /// <returns>Uśredniony wynik.</returns>
        public static double Single(Test test)
        {
            List <double> times = new List <double>();

            for (int i = 0; i < test.TestAmount; i++)
            {
                SalesmanData data =
                    new SalesmanData(DataGenerator.Salesman(test.CityAmount, test.LowerBound, test.UpperBound));
                SalesmanBnB salesman = new SalesmanBnB(data);

                Clock.Start();
                salesman.Start();
                double time = Clock.StopAndReturn();
                times.Add(time);
            }

            return(times.Average());
        }