コード例 #1
0
        /// <summary>
        /// Author: Philipp Klein
        /// </summary>
        public void getParameter()
        {
            int count = 0;

            StopCriterion[] stop = new StopCriterion[3];
            AlgoSettings algoSettings = new AlgoSettings();

            algoSettings.strategy = (SelectionStrategy)sele.SelectedValue;
            algoSettings.populationSize = (uint)popu.Value;
            algoSettings.crossoverCount = Convert.ToUInt32(cross.Text);
            algoSettings.mutationRate = (float)muta.Value;

            if (Number_of_generations.IsChecked == true)
            {
                maxGeneration gen = new maxGeneration(Convert.ToUInt32(numGen.Text));
                stop[count] = gen;
                count++;
            }
            if (Runtime__s_.IsChecked == true)
            {
                Runtime run = new Runtime(Convert.ToUInt32(runTime.Text));
                stop[count] = run;
                count++;
            }
            if (Fitness__ms_.IsChecked == true)
            {
                Fitness fit = new Fitness(Convert.ToUInt32(fitness.Text));
                stop[count] = fit;
                count++;
            }
            StopCriterion[] s = new StopCriterion[count];

            for (int i = 0; i < count; i++)
                s[i] = stop[i];

            algoSettings.stop = s;
        }
コード例 #2
0
        /// <summary>
        /// Author: Philipp Klein
        /// </summary>
        /// <param name="algoSettings"></param>
        public void setParameter(AlgoSettings algoSettings)
        {
            sele.SelectedValue = algoSettings.strategy;
            popu.Value = algoSettings.populationSize;
            cross.Text = algoSettings.crossoverCount.ToString();
            muta.Value = algoSettings.mutationRate;

            maxGeneration m = new maxGeneration(1);
            Runtime r = new Runtime(1);
            Fitness f = new Fitness(1);

            for (int i = 0; i < algoSettings.stop.Length; i++)
            {
                if (algoSettings.stop[i].GetType().IsAssignableFrom(m.GetType()))
                {
                    Number_of_generations.IsChecked = true;
                    numGen.Text = ((maxGeneration)algoSettings.stop[i]).maxGen.ToString();
                }
                if (algoSettings.stop[i].GetType().IsAssignableFrom(r.GetType()))
                {
                    Runtime__s_.IsChecked = true;

                    runTime.Text = ((Runtime)algoSettings.stop[i]).runtime.ToString();

                }
                if (algoSettings.stop[i].GetType().IsAssignableFrom(f.GetType()))
                {
                    Fitness__ms_.IsChecked = true;
                    fitness.Text = ((Fitness)algoSettings.stop[i]).fitness.ToString();
                }
            }
        }