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); }
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); }
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); }
public static void Add(FrontResult f1, FrontResult f2) { f1.HyperVolume += f2.HyperVolume; f1.Time += f2.Time; }