private void TableAndGraph_Load(object sender, EventArgs e)
        {
            UpdateGenIndex(DataStorage.selectionType);

            // SelectionSchemeChoose combobox
            SelectionSchemeChooseCB.Items.Add("Roulette wheel selection");
            SelectionSchemeChooseCB.Items.Add("Random selection");
            SelectionSchemeChooseCB.Items.Add("Rank selection");
            SelectionSchemeChooseCB.Items.Add("Tournament selection");

            ////// Selection tables
            SelectionDGV.DataSource           = Selection.InitializeTable();
            SelectionDGV.Columns[0].Width     = 50;
            SelectionAdditionalDGV.DataSource = Selection.InitializeAdditionalTable();
            SelectionTypeLB.Text     = DataStorage.selectionType;
            mainSelectionTable       = SelectionDGV.DataSource as DataTable;
            additionalSelectionTable = SelectionAdditionalDGV.DataSource as DataTable;
            toolTip1.SetToolTip(SelectionTypeLB, DataStorage.selectionToolTip[genIndex]);


            // Crossover tables
            CrossoverDGV.DataSource       = Crossover.InitializeTable();
            CrossoverDGV.Columns[0].Width = 50;
            CrossoverTypeLB.Text          = DataStorage.crossoverType;
            CrosoverRateLB.Text           = "Crossover rate: " + DataStorage.crossoverRate.ToString() + "%";
            crossOverTable = CrossoverDGV.DataSource as DataTable;
            toolTip1.SetToolTip(CrossoverTypeLB, DataStorage.GetCrossoverToolTip());

            // Mutation tables
            MutationDGV.DataSource       = Mutation.InitializeTable();
            MutationDGV.Columns[0].Width = 50;
            MutationTypeLB.Text          = DataStorage.mutationType;
            MutationRateLB.Text          = "Mutation rate: " + DataStorage.mutationRate.ToString() + "%";
            mutationTable = MutationDGV.DataSource as DataTable;
            toolTip1.SetToolTip(MutationTypeLB, DataStorage.GetMutationToolTip());

            ShowFitnessFunLB.Text        = DataStorage.fitnessFunction;
            SelectionSchemeChooseCB.Text = DataStorage.selectionType;

            maximaSaved = new int[DataStorage.generationCount, 4];

            ConductGeneticAlgorithm();
        }
Пример #2
0
        private void TSPTableAndGraph_Load(object sender, EventArgs e)
        {
            UpdateGenIndex(DataStorage.selectionType);

            // SelectionSchemeChoose combobox
            this.SelectionSchemeChooseCB.Items.Add("Roulette wheel selection");
            this.SelectionSchemeChooseCB.Items.Add("Random selection");
            this.SelectionSchemeChooseCB.Items.Add("Rank selection");
            this.SelectionSchemeChooseCB.Items.Add("Tournament selection");

            // Selection tables
            SelectDGV.DataSource           = Selection.InitializeTable();
            AdditionalSelectDGV.DataSource = Selection.InitializeAdditionalTable();
            this.SelectionTypeLB.Text      = DataStorage.selectionType;
            mainSelectionTable             = SelectDGV.DataSource as DataTable;
            additionalSelectionTable       = AdditionalSelectDGV.DataSource as DataTable;
            toolTip1.SetToolTip(SelectionTypeLB, DataStorage.selectionToolTip[genIndex]);

            // Crossover tables
            CrossDGV.DataSource       = Crossover.InitializeTable();
            this.CrossoverTypeLB.Text = DataStorage.crossoverType;
            this.CrosoverRateLB.Text  = "Crossover rate: " + DataStorage.crossoverRate.ToString() + "%";
            crossOverTable            = CrossDGV.DataSource as DataTable;
            toolTip1.SetToolTip(CrossoverTypeLB, DataStorage.GetCrossoverToolTip());

            // Mutation tables
            MutDGV.DataSource        = Mutation.InitializeTable();
            this.MutationTypeLB.Text = DataStorage.mutationType;
            this.MutationRateLB.Text = "Mutation rate: " + DataStorage.mutationRate.ToString() + "%";
            mutationTable            = MutDGV.DataSource as DataTable;
            toolTip1.SetToolTip(MutationTypeLB, DataStorage.GetMutationToolTip());

            // Initializing the selection scheme choose combobox
            this.SelectionSchemeChooseCB.Text = DataStorage.selectionType;

            // Matrix containing the minimum distance from each generation for each selection scheme
            minimaSaved     = new int[DataStorage.generationCount, 4];
            minimaPathSaved = new string[DataStorage.generationCount, 4];

            // What are we waiting for, set start the games
            ConductGeneticAlgorithm();
        }