private void btnTest_Click(object sender, EventArgs e) { try { var algorithmPlugin = SelectedAlgorithmPlugin; if (algorithmPlugin.HasAlgorithm(2)) { var f = new PartitioningParametersForm(); if (f.ShowDialog() != DialogResult.OK) { return; } var partitioningParameters = new PartitioningParameters(f.M1, f.M2); var algorithm = algorithmPlugin.CreateAlgorithm(2, partitioningParameters); if (algorithm == null) { return; } Test_result tr = new Test_result(fileStorage, fileStorage, algorithm, partitioningParameters); tr.ShowDialog(); } } catch { } }
private void btnAlgorithm_Click(object sender, EventArgs e) { try { var algorithmPlugin = SelectedAlgorithmPlugin; if (algorithmPlugin.HasAlgorithm(2)) { var solutionVisualiserPlugin = SelectedSolutionVisualiserPlugin; PartitioningParameters parameters = null; if (SelectedSolutionMatrixData != null) { parameters = SelectedSolutionMatrixData.Data.Item1; } else if (SelectedMatrixData != null) { var f = new PartitioningParametersForm(); if (f.ShowDialog() != DialogResult.OK) { return; } parameters = new PartitioningParameters(f.M1, f.M2); } var algorithm = algorithmPlugin.CreateAlgorithm(2, parameters); if (algorithm == null) { return; } var matrix = SelectedMatrix; var solution = algorithm.Run(matrix); if (solutionVisualiserPlugin.HasSolutionVisualizer(2)) { var solutionVisualiser = solutionVisualiserPlugin.CreateSolutionVisualizer(2); solutionVisualiser.VisualizeSolution(matrix, solution); } } } catch { } }
public Test_result(IMatrixReadStorage <int, EmptyData> storage, IMatrixReadStorage <int, SolutionData> datastorage, IAlgorithm <int> algorithm, PartitioningParameters parameters) { results = new AllResults(); InitializeComponent(); foreach (var matrixData in storage.ReadMatrixes()) { string name = matrixData.Name; IMatrix <int> matrix = matrixData.Matrix; int n = matrixData.Matrix.Size(0); int m = matrixData.Matrix.Size(1); int M1 = parameters[0]; int M2 = parameters[1]; Int64 start = Stopwatch.GetTimestamp(); ISolution solution = algorithm.Run(matrix); double time = (Stopwatch.GetTimestamp() - start) / (double)Stopwatch.Frequency; double crit = MinMaxCriterium.Calculate(matrix, solution); double w = Utilities.W(matrix, parameters); double diff = crit - w; results.AddElem(new Note(name, n, m, M1, M2, crit, diff, 0, time, false)); } foreach (var matrixData in datastorage.ReadMatrixes()) { string name = matrixData.Name; IMatrix <int> matrix = matrixData.Matrix; int n = matrixData.Matrix.Size(0); int m = matrixData.Matrix.Size(1); PartitioningParameters dataParameters = matrixData.Data.Item1; int M1 = dataParameters[0]; int M2 = dataParameters[1]; double goodCrit = matrixData.Data.Item3; Int64 start = Stopwatch.GetTimestamp(); ISolution solution = algorithm.Run(matrix); double time = (Stopwatch.GetTimestamp() - start) / (double)Stopwatch.Frequency; double crit = CoreUtilities.Utilities.Max(new SplittedMatrix(matrix, solution)); double w = Utilities.W(matrix, dataParameters); double diff = crit - w; double goodDiff = crit - goodCrit; results.AddElem(new Note(name, n, m, M1, M2, crit, diff, goodDiff, time, true)); } results.GetGroups(GroupedResults); }