예제 #1
0
        private void DisplayStatistics(StrategyBase strategy)
        {
            // then display the final results
            Dispatcher.BeginInvoke(new Action(() =>
            {
                stopwatch.Stop();

                // test it and display scores
                var tester = new StrategyTester(strategy, ProgramConfiguration.TestSettings);

                double average, stdDev, coeffVariation;
                tester.GetStatistics(out average, out stdDev, out coeffVariation);

                string scoreResults =
                    "\nAverage score: " + average.ToString("0") +
                    "\nStandard Deviation: " + stdDev.ToString("0") +
                    "\nCoeff. of Variation: " + coeffVariation.ToString("0.0000");

                gaResultTB.Text = "Solution found in " + totalGenerations + " generations\nElapsed: " +
                                  stopwatch.Elapsed.Hours + "h " +
                                  stopwatch.Elapsed.Minutes + "m " +
                                  stopwatch.Elapsed.Seconds + "s " +
                                  "\n\nTest Results:" + scoreResults;
            }),
                                   DispatcherPriority.Background);
        }
예제 #2
0
        private void TestStrategy(IStrategy strategy)
        {
            OutputTextBlock.Text = "Testing...";

            Task.Run(() =>
            {
                double avg, stdDev, coeffVariation;
                StrategyTester.GetStatistics(strategy, out avg, out stdDev, out coeffVariation);

                Dispatcher.Invoke(() =>
                {
                    OutputTextBlock.Text = $"Test results:\nAverage score: {avg.ToString("0")}\nStandard deviation: {stdDev.ToString("0")}\nCoefficient of variation: {coeffVariation.ToString("0.0000")}";
                }, DispatcherPriority.Background);
            });
        }