Beispiel #1
0
        public static void RunPerformanceOverTimeTest(Cities cities, int time, int populationSize, int matingPoolSize,
                                                      int tournamentSize, int mutationProbability, int mutationType,
                                                      string path)
        {
            path += cities.AdjacencyMatrix.GetLength(0) + "_Genetic_" + time + "s_" + populationSize + "os_" + matingPoolSize + "mat_" + tournamentSize +
                    "trnm_" + mutationProbability + "%_" + (mutationType == 0 ? "invert" : "swap") + ".txt";
            StringBuilder algorithmResultsSB = new StringBuilder();

            algorithmResultsSB.Append("|BADANIE PRZEBIEGU ALGORYTMU W ZALEŻNOŚCI OD CZASU|" + Environment.NewLine);
            LinkedList <Pair <int, int> > algorithmResults = Genetic.AnalyzePerformance(cities, time, populationSize,
                                                                                        matingPoolSize, tournamentSize,
                                                                                        mutationProbability, mutationType);
            float bestDistance = (float)cities.BestDistance;

            foreach (var result in algorithmResults)
            {
                string relativeError = ((((float)result.Second - bestDistance) / bestDistance) * 100.0f).ToString();
                algorithmResultsSB.Append(result.First + ";" + relativeError + Environment.NewLine);
            }
            WriteOutputToFile(path, algorithmResultsSB.ToString());
        }