Exemplo n.º 1
0
        private void OutputAvg(GeneticTS geneticTS, List <List <double> > bestMaster, List <List <double> > avgMaster, string experimentName)
        {
            if (!File.Exists("output.csv"))
            {
                File.Create("output.csv").Close();
            }
            StreamWriter data = new StreamWriter("output.csv", true);

            string[] expInfo = geneticTS.GetExperimentInfo();
            foreach (var line in expInfo)
            {
                data.WriteLine(line);
            }
            data.WriteLine("");
            data.WriteLine(experimentName);
            data.WriteLine("Best Fitness " + "," + "Average Fitness");
            //Depth
            for (int i = 0; i < bestMaster.Max(x => x.Count) - 1; i++)
            {
                //Breadth
                double avgBest = 0;
                double avgAvg  = 0;
                for (int k = 0; k < bestMaster.Count; k++)
                {
                    avgBest += (i >= bestMaster[k].Count) ? bestMaster[k].Last() : bestMaster[k][i];
                    avgAvg  += (i >= avgMaster[k].Count) ? avgMaster[k].Last() : avgMaster[k][i];
                }
                data.WriteLine(avgBest / bestMaster.Count + "," + avgAvg / avgMaster.Count);
            }
            data.WriteLine("");
            data.Close();
            data.Dispose();
        }
Exemplo n.º 2
0
        private void Output1(GeneticTS geneticTS, List <double> bestMaster, List <double> avgMaster, string experimentName)
        {
            if (!File.Exists("output.csv"))
            {
                File.Create("output.csv").Close();
            }
            StreamWriter data = new StreamWriter("output.csv", true);

            string[] expInfo = geneticTS.GetExperimentInfo();
            foreach (var line in expInfo)
            {
                data.WriteLine(line);
            }
            data.WriteLine("");
            data.WriteLine(experimentName);
            data.WriteLine("Best Fitness " + "," + "Average Fitness");
            for (int i = 0; i < bestMaster.Count; i++)
            {
                data.WriteLine(bestMaster[i] + ", " + avgMaster[i]);
            }
            data.WriteLine("");
            data.Close();
            data.Dispose();
        }