Пример #1
0
        public static void SaveAsJson(string outputPath, string seriesName, FrontResult testResult)
        {
            var json = JsonConvert.SerializeObject(testResult);

            var saveDirectory = outputPath + "\\" + seriesName;

            if (!Directory.Exists(saveDirectory))
            {
                Directory.CreateDirectory(saveDirectory);
            }

            File.WriteAllText(saveDirectory + "\\" + testResult.SeriesName + ".json", json);
        }
Пример #2
0
        public static FrontResult CreatTestResult(NsgaResult nsgaResult, Configuration configuration)
        {
            var testResult = new FrontResult
            {
                Iterations          = configuration.MaxIterations,
                PopulationSize      = configuration.PopulationSize,
                MutationProbability = configuration.MutationProbability,
                Time         = nsgaResult.Log.SolvingTime,
                ResultPoints = nsgaResult.Fronts.SelectMany(f => f).Select(g => CreateResultPoint((GroupDietIndividual)g)).ToList(),
                SeriesName   = CreateName(configuration)
            };

            return(testResult);
        }
Пример #3
0
        public static void SaveParetoAsJson(string outputPath, FrontResult testResult)
        {
            var json = JsonConvert.SerializeObject(testResult);

            var saveDirectory = outputPath + "\\pareto\\";

            var filesInOutputDir = Directory.GetFiles(saveDirectory);
            var fileIndex        = 0;
            var fileName         = "pareto.json";

            while (filesInOutputDir.Any(path => path.EndsWith(fileName)))
            {
                fileIndex++;
                fileName = $"pareto_{fileIndex}.json";
            }

            if (!Directory.Exists(saveDirectory))
            {
                Directory.CreateDirectory(saveDirectory);
            }

            File.WriteAllText(saveDirectory + "\\fileName", json);
            File.WriteAllText($"{saveDirectory}\\{fileName}", json);
        }
Пример #4
0
 public static void Add(FrontResult f1, FrontResult f2)
 {
     f1.HyperVolume += f2.HyperVolume;
     f1.Time        += f2.Time;
 }