Exemple #1
0
 public Kontener(Kontener old)
 {
     this.wartosci = old.wartosci.Select(item => (string)item.Clone()).ToList();
     this.cross    = old.cross;
     this.first    = old.first;
     this.LiczWartosci();
 }
Exemple #2
0
        public Kontener Run()
        {
            TheBest = ko.Test();
            Best    = new Kontener(ko);
            for (int i = 0; i < 500; i++)
            {
                Kontener temp = MakeStep();

                int sw = ko.Test();

                if (temp.first != "")
                {
                    ko = temp;
                }
                int iiii = ko.Test();

                if (iiii < TheBest)
                {
                    TheBest = iiii;
                    Best    = new Kontener(ko);
                    Console.WriteLine();
                    Console.WriteLine(i);
                    Console.WriteLine(TheBest);
                    Console.WriteLine((double)TheBest / 100.0);
                }
            }

            return(Best);
        }
Exemple #3
0
        public Kontener insert(int from, int to)
        {
            Kontener result = new Kontener(this);

            string temp = result.wartosci[from];

            result.wartosci.RemoveAt(from);
            result.wartosci.Insert(to, temp);

            return(result);
        }
Exemple #4
0
        private Kontener MakeStep()
        {
            int      min  = ko.Test();
            Kontener best = ko;

            foreach (var x in ko.wartosci)
            {
                int number = ko.wartosci.IndexOf(x);
                for (int i = 0; i < ko.wartosci.Count; i++)
                {
                    if (i == number)
                    {
                        continue;
                    }
                    Kontener temp = ko.insert(number, i);
                    if (temp.Test() <= min)
                    {
                        best = temp;
                        min  = temp.Test();
                    }
                }
            }

            if (best.Test() == ko.Test())
            {
                if (Enumerable.SequenceEqual(best.wartosci, Best.wartosci))
                {
                    Console.WriteLine("\npowtorzenie");
                }

                Random rnd  = new Random();
                int    size = ko.wartosci.Count();

                swap(rnd.Next() % size, rnd.Next() % size);

                best = ko;
            }

            return(best);
        }
Exemple #5
0
        static void  Main()
        {
            CrossOligos ol = new CrossOligos();

            OligoMeta meta = new OligoMeta();


            string first = Prepare("10.in", meta);

            ol.GenerateMap(meta, first);

            Kontener kon = new Kontener(meta, ol);

            kon.first = first;

            kon.LiczWartosci();


            Algorytm alg = new Algorytm(kon);

            alg.Run();
        }
Exemple #6
0
 public Algorytm(Kontener kon)
 {
     ko = kon;
 }