コード例 #1
0
ファイル: Algorithm.cs プロジェクト: lightfaith/bia
 public override List<Element> Run(List<Element> population, Lib.func f, bool integer)
 {
     Element best = null;
     foreach (Element e in population)
     {
         if (best == null || e.Fitness > best.Fitness)
             best = e;
     }
     List<Element> result = new List<Element>();
     result.Add(best);
     result.AddPopulation(population.Count - 1, f, integer);
     return result;
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: lightfaith/bia
        private void cv02btnPopulate_Click(object sender, EventArgs e)
        {
            Functions.SetMeasures(cv02txtMin.Text, cv02txtMax.Text, cv02txtStep.Text);
            Functions.RandomizeRandom(2);

            int populsize;
            try { populsize = Int32.Parse(cv02txtPopulation.Text); }
            catch (Exception) { populsize = 10; }

            Lib.func f = Functions.GetFunctionByIndex(cv02cmbFunction.SelectedIndex);
            population = new List<Element>();
            population.AddPopulation(populsize, f, cv02checkInteger.Checked);
            population.ComputeFitness();

            cv02gridPopulation.DataSource = population;
            //foreach (DataGridViewColumn c in cv02gridPopulation.Columns)
            //    c.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            cv02gridPopulation.EmphasizeFitness();
            cv02gridPopulation.Refresh();
            il.Plot(f, Functions.Min, Functions.Max, Functions.Precision, false);
            il.DrawPoints(population, Functions.Min, Functions.Max, Functions.Precision);
            setAlgos();
        }