예제 #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
        private void ctrlListSolutions_DoubleClick(object sender, EventArgs e)
        {
            if (_controller.CurrProblem != null && ctrlListSolutions.SelectedIndices.Count > 0)
            {
                int             solInd = ctrlListSolutions.SelectedIndices[0];
                StudentSolution sol    = _controller.CurrProblem.ListSolutions[solInd];

                frmShowSolution frm = new frmShowSolution();

                frm.SolutionCode = procesSolutionCode(sol.SolutionCode);

                frm.ShowDialog();
            }
        }
예제 #3
0
        public double CalculateSimilarityMeasure(StudentSolution s1, StudentSolution s2)
        {
            string code1 = s1.SolutionCode;
            string code2 = s2.SolutionCode;
            int    len1  = code1.Length;
            int    len2  = code2.Length;

            int[,] sol = new int[2, len2 + 1];
            int current = 1;

            for (int i = 0; i <= len2; i++)
            {
                sol[0, i] = i;
            }

            for (int i = 1; i <= len1; i++)
            {
                sol[current, 0] = i;
                for (int j = 1; j <= len2; j++)
                {
                    int cost = 1;
                    if (code1[i - 1] == code2[j - 1])
                    {
                        cost = 0;
                    }

                    sol[current, j] = sol[(current + 1) & 1, j] + 1;
                    if (sol[current, j] > sol[current, j - 1] + 1)
                    {
                        sol[current, j] = sol[current, j - 1] + 1;
                    }
                    if (sol[current, j] > sol[(current + 1) & 1, j - 1] + cost)
                    {
                        sol[current, j] = sol[(current + 1) & 1, j - 1] + cost;
                    }
                }
                if (current == 1)
                {
                    current = 0;
                }
                else
                {
                    current = 1;
                }
            }
            int sumOfLengths = len1 + len2;

            return(1.0 * (sumOfLengths - sol[(current + 1) & 1, len2]) / sumOfLengths);
        }
        public double CalculateSimilarityMeasure(StudentSolution s1, StudentSolution s2)
        {
            return(0.0);

            int[,] ret = new int[s1.SolutionLines.Count + 1, s2.SolutionLines.Count + 1];

            for (int i = 0; i <= s1.SolutionLines.Count; i++)
            {
                ret[i, 0] = i;
            }
            for (int i = 0; i <= s2.SolutionLines.Count; i++)
            {
                ret[0, i] = i;
            }

            double suma = 0.0;
            int    cnt  = 0;

            for (int i = 1; i <= s1.SolutionLines.Count; i++)
            {
                for (int j = 1; j <= s2.SolutionLines.Count; j++)
                {
                    double ld = LineDistance(s1.SolutionLines[i - 1].ToString(), s2.SolutionLines[j - 1].ToString());
                    ret[i, j] = ret[i - 1, j - 1];
                    if (ld < 0.90)
                    {
                        ret[i, j]++;
                    }

                    suma += ld;
                    cnt++;

                    if (ret[i - 1, j] + 1 < ret[i, j])
                    {
                        ret[i, j] = ret[i - 1, j] + 1;
                    }
                    if (ret[i, j - 1] + 1 < ret[i, j])
                    {
                        ret[i, j] = ret[i, j - 1] + 1;
                    }
                }
            }

            int sum = s1.SolutionLines.Count + s2.SolutionLines.Count;

            return(1.0 * (sum - ret[s1.SolutionLines.Count, s2.SolutionLines.Count]) / sum);
        }
예제 #5
0
 public double CalculateSimilarityMeasure(StudentSolution s1, StudentSolution s2)
 {
     return(0.0);
 }