示例#1
0
 protected void OnBtnStart10Clicked(object sender, System.EventArgs e)
 {
     //Mal ne Exception, will ich eh alles anders machen
     statusbar.Push(1,"Ditt jeht noch nich, keule.");
     Problem bin = new Griewank();
     bin.countIndividuals = (int)txt_countIndividuals.Value;
     Genome a = new GenomeReal(5,-50,50);
     Genome b = new GenomeReal(5,-50,50);
     List<Genome> childs = new List<Genome>(2);
     childs.Add(a);
     childs.Add(b);
     Console.WriteLine(a.AsString());
     Console.WriteLine(b.AsString());
     bin.MutateBinary(childs);
 }
示例#2
0
    protected void OnBtnStartClicked(object sender, EventArgs e)
    {
        btn_Start.Sensitive = false;
        txt_Output.Buffer.Clear();
        try
        {
            Problem problem = null;

            switch (cbo_Problem.Active)
            {
                case 0 :	problem = new TravelingSalesMan(); break;
                case 1 :	problem = new Griewank(); break;
                case 2 :	problem = new Ackley(); break;
                case 3 :	problem = new Nullstelle(); break;
            }

            if (problem == null)
                throw new NullReferenceException();

            problem.countGene = (int)txt_countGenes.Value;
            problem.maxGenerations = (int)txt_maxGeneration.Value;
            problem.countIndividuals = (int)txt_countIndividuals.Value;
            problem.countChilds = (int)txt_countChilds.Value;
            problem.recombinationProbability = txt_recombProb.Value;

            if (cbo_Encryption.Active == 1)
            {
                problem.RecombBinaryIsSinglePoint = (cbo_recombBinary.Active == 0)? true : (cbo_recombBinary.Active == 1)? false : (bool?)null;
            }
            if (cbo_Encryption.Active == 2)
            {
                problem.RecombRealIsIntermidiate = cbo_recombReal.Active == 0;
            }

            problem.InvertOnMutate = rb_Invert.Active ? true : false;

            problem.minAllelValue = problem.minAllelValue == 0 ? 1 : problem.minAllelValue;
            problem.maxAllelValue = problem.maxAllelValue == 0 ? problem.countGene + 1 : problem.maxAllelValue;

            problem.SelPropType = rb_Fitness.Active ? main.Helper.Enums.SelPropType.Fitness : main.Helper.Enums.SelPropType.Ranking;
            problem.SelType = (main.Helper.Enums.SelType)cbo_SelType.Active;
            problem.Encryption = (main.Helper.Enums.Encryption)cbo_Encryption.Active;
            problem.TournamentMemberCount = (int)txt_TournamentMemberCount.Value;

            Evolution evol = new Evolution(problem);

            //Methode zum behandeln des Fortschritt-Events zuweisen
            evol.OnProgress += new Evolution.OnProgressEvent(OnEvolutionProgressChanged);

            // Laufzeitmessung
            watch.Start();

            evol.Compute();

            //Laufzeitauswertung
            watch.Reset();

            txt_Output.Buffer.Text = problem.Output.ToString();

            btn_Start.Sensitive = true;
        }
        catch (Exception ex)
        {
            txt_Output.Buffer.Text += "\r\n\r\nFehler: " + ex.Message + "\r\n\r\n" + ex.StackTrace;
            btn_Start.Sensitive = true;
        }
    }