Example #1
0
        public int Eval(ISolution solution)
        {
            int tmp;

            if (!memento.TryGetValue(solution.GetId(), out tmp))
            {
                tmp = DirectEval(solution);
                memento.Add(solution.GetId(), tmp);
            }
            return(tmp);
        }
Example #2
0
        public List <ISolution> BuildPath(ISolution one, ISolution two)
        {
            List <ISolution> heap = new List <ISolution>();

            if (one.GetId() != two.GetId())
            {
                int[] sol1 = new int[one.GetSize()];
                int[] sol2 = new int[two.GetSize()];
                Array.Copy(one.GetVec(), sol1, sol1.Length);
                Array.Copy(two.GetVec(), sol2, sol2.Length);
                for (int i = 0; i < sol1.Length; i++)
                {
                    if (sol1[i] != sol2[i])
                    {
                        int j, temp;
                        for (j = i; j < sol1.Length - 1; j++)
                        {
                            if (sol1[j] == sol2[i])
                            {
                                break;
                            }
                        }
                        temp = sol1[i]; sol1[i] = sol1[j]; sol1[j] = temp;
                        heap.Add(new Solution(sol1));
                    }
                }
                heap.Remove(heap[heap.Count - 1]);
            }
            return(heap);
        }
Example #3
0
 public int Distance(ISolution one, ISolution two)
 {
     if (one.GetId() == two.GetId())
     {
         return(0);
     }
     return(BuildPath(one, two).Count + 1);
 }
Example #4
0
 public int Distance(ISolution one, ISolution two)
 {
     if (one.GetId() == two.GetId())
     {
         return(0);
     }
     else
     //{
     //    int counter = 0;
     //    int[] sol1 = new int[one.GetSize()];
     //    Array.Copy(one.GetVec(), sol1, sol1.Length);
     //    for (int i = 0; i < sol1.Length; i++)
     //    {
     //        if (sol1[i] != two.GetVec()[i])
     //        {
     //            int j, temp;
     //            for (j = i; j < sol1.Length - 1; j++)
     //            {
     //                if (sol1[j] == two.GetVec()[i])
     //                    break;
     //            }
     //            temp = sol1[i]; sol1[i] = sol1[j]; sol1[j] = temp;
     //            counter++;
     //        }
     //    }
     //    return counter;
     //}
     {
         int counter = 0;
         for (int i = 0; i < one.GetVec().Length; i++)
         {
             if (one.GetVec()[i] != two.GetVec()[i])
             {
                 counter++;
             }
         }
         return(counter);
     }
 }
 public static IEnumerable <string> GetAdditionalConfigurationFiles(this ISolution solution)
 {
     return(solution.GetSettingsStore()
            .GetAdditionalConfigurationFiles(solution.GetId()));
 }