private async void SaveOptimizationResult() { var dlg = new SaveFileDialog { DefaultExt = "json", Filter = "Json (*.json)|*.json" }; if (dlg.ShowDialog() == true) { await IOOperations.SaveAsync <OptimizationResult>(dlg.FileName, OptimizationResult); SetStatusMessage("Result saved."); } }
private async void SaveDataset() { var dlg = new SaveFileDialog { DefaultExt = "json", Filter = "Json (*.json)|*.json" }; if (dlg.ShowDialog() == true) { await IOOperations.SaveAsync <TestcaseBlockerDataset>(dlg.FileName, Dataset); SetStatusMessage("Dataset saved."); } }
public static async Task SaveDataset(TestcaseBlockerDataset dataset) { if (dataset is null) { Console.WriteLine("Cannot save an empty dataset. First generate or load a dataset."); return; } Console.Write("Enter filename without extension: "); string filename = Console.ReadLine(); var path = Path.Combine(GetDataPath(), filename + ".json"); Console.WriteLine($"Saving dataset to {path}"); await IOOperations.SaveAsync <TestcaseBlockerDataset>(path, dataset); }
public static async Task RunOptimization(TestcaseBlockerDataset dataset) { if (dataset is null) { Console.WriteLine("Cannot run optimization for an empty dataset. First generate or load a dataset."); return; } var debugOutput = true; Console.Write("Suppress output information for each generation (y)? "); if (Console.ReadLine().ToLower() == "y") { debugOutput = false; } var watch = new Stopwatch(); watch.Start(); var optimizer = new Optimizer(dataset); if (debugOutput) { optimizer.ChromosomeEvaluated += Optimizer_ChromosomeEvaluated; optimizer.GenerationEvaluated += Optimizer_GenerationEvaluated; } else { optimizer.GenerationEvaluated += Optimizer_GenerationProgress; } var result = optimizer.Optimize(); var duration = TimeSpan.FromMilliseconds(watch.ElapsedMilliseconds); watch.Stop(); var resolvedBlockers = string.Join(",", result.ResolvedBlockers.Select(x => x.Name).ToList()); if (resolvedBlockers.Length > 100) { resolvedBlockers = resolvedBlockers.Substring(0, 97) + "..."; } var resolvedTestcases = string.Join(",", result.ResolvedTestcases.Select(x => x.Id).ToList()); if (resolvedTestcases.Length > 100) { resolvedTestcases = resolvedTestcases.Substring(0, 97) + "..."; } var resolvedTestcasesIncludingUnblocked = string.Join(",", result.ResolvedTestcasesIncludingUnblocked.Select(x => x.Id).ToList()); if (resolvedTestcasesIncludingUnblocked.Length > 100) { resolvedTestcasesIncludingUnblocked = resolvedTestcasesIncludingUnblocked.Substring(0, 97) + "..."; } Console.WriteLine(); Console.WriteLine($"Duration : {duration.ToString()} (including output)"); Console.WriteLine($"Best solution fitness : {result.Fitness}"); Console.WriteLine($"Resolved Blockers : ({result.NumberOfResolvedBlockers}/{result.Cost}) [{resolvedBlockers}]"); Console.WriteLine($"Resolved Testcases : ({result.NumberOfResolvedTestcases}/{result.Value}) [{resolvedTestcases}]"); Console.WriteLine($"Resolved Testcases w/unblocked: ({result.NumberOfResolvedTestcasesIncludingUnblocked}/{result.ValueIncludingUnblocked}) [{resolvedTestcasesIncludingUnblocked}]"); Console.WriteLine(); Console.Write("Save result (y|n)? "); var saveResult = Console.ReadLine().Trim().ToLower(); if (saveResult == "y") { Console.Write("Enter filename without extension: "); string filename = Console.ReadLine(); var path = Path.Combine(GetDataPath(), filename + ".json"); Console.WriteLine($"Saving result to {path}"); await IOOperations.SaveAsync <OptimizationResult>(path, result); } }