Beispiel #1
0
        public void values_init()
        {
            //---pobranie danych z bazy danych---
            var db = new BazaDanychDataContext();
            IDictionary<Przedmiot, IList<Prowadzący>> prowadzacyZajecia;
            IList<Zajecia> genotyp;

            InitializeFromDataBase(db, this.comboBox1.Text, out genotyp, out prowadzacyZajecia);
            Application.DoEvents();

            //---przypisanie genotypu---
            Timetable.Genome = genotyp;

            //---randomy---
            DoubleRandomGenerator randMutation = new DoubleRandomGenerator();
            DoubleRandomGenerator randSelector = new DoubleRandomGenerator();
            IntegerRandomGenerator randGen = new IntegerRandomGenerator();
            IntegerRandomGenerator randMateUp = new IntegerRandomGenerator();
            IntegerRandomGenerator randGenSelector = new IntegerRandomGenerator();

            //---komponenty algorytmu---
            population = new List<Timetable>();
            mutation = new TimetableTeacherMutation(prowadzacyZajecia, randMutation, randGenSelector, 0.02);
            breeder = new TimetableFactory(mutation, randMateUp);
            evalSelector = new TimetableEvaluator();

            //Timetable primeChromosome = breeder.CreateNew();

            reproducer = new CrossOverReproducer<Timetable, TimetableLocus, Zajecia>(randMateUp, breeder, new CrossOverReproducer<Timetable, TimetableLocus, Zajecia>.Config() { ChildCount = 2, ParentCount = 2 });
            selector = new RouletSelector<Timetable, TimetableLocus, Zajecia>(evalSelector, randSelector);

            //---inicjacja populacji---  (calosciowy plan dla uczelni)
            //Application.DoEvents();
            for (int i = 0; i < MaxPopulationCount; i++)
                population.Add(breeder.CreateNew());

            //moze zrobic tak...
            //populacje duzych planow rozpic na N populacjie mniejszych planow

            //dla kazdego duzego planu
            //duzy plan uzyskany z populacji rozbic na mniejsze juz teraz
            //stworzyc populacje pomiejszych planow
            //przeprowadzic iteracje GA
            //potem wszystkie te plany skonkatenowac
            //odtworzyc populacje duzych planow
            //i ocenic...

            it = 0;

            this.wykres.Series[0].Points.Clear();
            this.wykres.Series[1].Points.Clear();
            this.comboBox1.Enabled = true;
            this.poprzedni.Enabled = false;
            this.nastepny.Enabled = true;
            wybranaGrupa_SelectedIndexChanged(null, null);
            this.dataGridView1.ReadOnly = false; this.dataGridView1.AllowUserToDeleteRows = true;
            this.dataGridView2.ReadOnly = false; this.dataGridView2.AllowUserToDeleteRows = true;
            this.dataGridView3.ReadOnly = false; this.dataGridView3.AllowUserToDeleteRows = true;
            this.dataGridView4.ReadOnly = false; this.dataGridView4.AllowUserToDeleteRows = true;
            this.dataGridView5.ReadOnly = false; this.dataGridView5.AllowUserToDeleteRows = true;
        }
 private static String GenerateIntegerRandomCode()
 {
     IntegerRandomGenerator ig = new IntegerRandomGenerator(111111, 999999);
     return ig.GetRandom().ToString();
 }