public SimilarityResult Analyze(ICodeSimilarityMetricCalculator selMetric, ProgrammingProblem problem) { DateTime current = DateTime.Now; SimilarityResult result = new SimilarityResult(problem, selMetric); for (int i = 0; i < problem.NumSol; i++) { for (int j = 0; j < problem.NumSol; j++) { if (i != j) { StudentSolution sol1 = result.getSimilarityObject(i, j).Solution1; StudentSolution sol2 = result.getSimilarityObject(i, j).Solution2; double measure = selMetric.CalculateSimilarityMeasure(sol1, sol2); result.setSimilarity(i, j, measure); result.setSimilarity(j, i, measure); } else { result.setSimilarity(i, i, 1.0); // neæemo ga usporeðivati sa samim sobom } } } System.Windows.Forms.MessageBox.Show("Runtime: " + DateTime.Now.Subtract(current).ToString()); return(result); }
public SimilarityResult BatchAnalyze(ICodeSimilarityMetricCalculator selMetric, ProgrammingProblem problem) { DateTime current = DateTime.Now; SimilarityResult result = new SimilarityResult(problem, selMetric); StudentSolution[] solutions = new StudentSolution[problem.NumSol]; for (int i = 0; i < problem.NumSol; i++) { solutions[i] = result.getSimilarityObject(i, i).Solution1; } double [,] tmp = new double[problem.NumSol, problem.NumSol]; tmp = selMetric.BatchSimilarityMeasure(solutions); for (int i = 0; i < problem.NumSol; i++) { for (int j = 0; j < problem.NumSol; j++) { if (i != j) { double measure = tmp[i, j]; result.setSimilarity(i, j, measure); result.setSimilarity(j, i, measure); } else { result.setSimilarity(i, i, 1.0); // neæemo ga usporeðivati sa samim sobom } } } System.Windows.Forms.MessageBox.Show("Runtime: " + DateTime.Now.Subtract(current).ToString()); return(result); }