Ejemplo n.º 1
0
 public static void SaveStatisticsToFile()
 {
     using (var writer = new StreamWriter($"{CSV_SAVE_LOCATION_STATISTICS +PROBLEM_NAME+ DateTime.Now.ToFileTime()}{FILE_ANNOTATION_STATISTICS}{CSV_FILE_EXTENSION}", true))
         using (var csv = new CsvWriter(writer))
         {
             csv.WriteComment("STATYSTYKI");
             csv.NextRecord();
             csv.WriteHeader <CsvResult>();
             csv.NextRecord();
             csv.WriteRecords(CsvStatisticsHolder.GetInstance().results);
         }
 }
        private static void RunGeneticAlgorithm()
        {
            CsvStatisticsHolder.GetInstance().Reset();
            GeneticAlgorithm g    = new GeneticAlgorithm();
            TSPSpecimen      best = g.GeneticCycle();

            WriteLine("FINISH: " + best.objectiveFunction);

            int    b      = best.objectiveFunction;
            double avg    = CsvStatisticsHolder.GetInstance().results.Average(p => p.averageOfResults);
            double minavg = (CsvStatisticsHolder.GetInstance().results.Average(p => p.worstResult));
            double maxavg = (CsvStatisticsHolder.GetInstance().results.Average(p => p.bestResult));

            results.Add(new CsvTotalResult(b, maxavg, minavg, avg));
            Utilities.SaveStatisticsToFile();
        }