public void AppendStatsToLog(ResultsStatsGeneration genStat) { using (StreamWriter w = File.AppendText(filePath)) { w.WriteLine("Generation #" + genStat.GenerationNo); w.WriteLine("Population Fitness:"); foreach (int mapFitnessValue in genStat.mapFitnessValues) w.WriteLine(mapFitnessValue.ToString()); w.WriteLine(); } }
public void AddGenerationStats(int generationNo, List<BuildDecisionsChromosome> chromosomes) { if(generationNo == 0 && File.Exists(filePath)) File.WriteAllText(filePath, String.Empty); ResultsStatsGeneration genStat = new ResultsStatsGeneration(); genStat.GenerationNo = generationNo; foreach (BuildDecisionsChromosome buildDecisionsChromosome in chromosomes) genStat.mapFitnessValues.Add(buildDecisionsChromosome.Fitness); genStat.mapFitnessValues.Sort((i, i1) => i1.CompareTo(i)); generationStats.Add(genStat); AppendStatsToLog(genStat); }