示例#1
0
        public double CalculateSimilarityMeasure(StudentSolution sol1, StudentSolution sol2)
        {
            if (lastRow.Length < sol2.SolutionCode.Length)
            {
                Array.Resize <int>(ref lastRow, sol2.SolutionCode.Length);
                Array.Resize <int>(ref currentRow, sol2.SolutionCode.Length);
            }

            for (int j = 0; j < sol2.SolutionCode.Length; j++)
            {
                currentRow[j] = j;
            }

            Swap <int[]>(ref currentRow, ref lastRow);

            for (int i = 0; i < sol1.SolutionCode.Length; i++)
            {
                currentRow[0] = i;

                for (int j = 1; j < sol2.SolutionCode.Length; j++)
                {
                    currentRow[j] = lastRow[j] + 1;
                    currentRow[j] = Math.Min(currentRow[j], currentRow[j - 1] + 1);
                    currentRow[j] = Math.Min(currentRow[j], lastRow[j - 1] + (sol1.SolutionCode[i] == sol2.SolutionCode[j] ? 0 : 1) + 1);
                }

                Swap <int[]>(ref currentRow, ref lastRow);
            }

            return(1.0 - (double)currentRow[sol2.SolutionCode.Length - 1] / (sol1.SolutionCode.Length + sol2.SolutionCode.Length));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
 public double CalculateSimilarityMeasure(StudentSolution sol1, StudentSolution sol2)
 {
     return((_rnd.Next() % 10000) / 10000.0);
 }
示例#5
0
 public double CalculateSimilarityMeasure(StudentSolution sol1, StudentSolution sol2)
 {
     return(0.5);
 }
示例#6
0
        public void addStudentSolution(string code, string id)
        {
            StudentSolution newSol = new StudentSolution(code, id);

            _listSolutions.Add(newSol);
        }
示例#7
0
        public void addStudentSolution(FileInfo fi)
        {
            StudentSolution newSol = new StudentSolution(fi);

            _listSolutions.Add(newSol);
        }