当前位置: 首页>>代码示例>>C#>>正文


C# EnumConverter.GetStandardValues方法代码示例

本文整理汇总了C#中System.ComponentModel.EnumConverter.GetStandardValues方法的典型用法代码示例。如果您正苦于以下问题:C# EnumConverter.GetStandardValues方法的具体用法?C# EnumConverter.GetStandardValues怎么用?C# EnumConverter.GetStandardValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.EnumConverter的用法示例。


在下文中一共展示了EnumConverter.GetStandardValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: backgroundWorker1_DoWork

    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
        int progress = 0;
            optrez.Clear();
            finalRez.Clear();
            alg = new PGA();
            OptimizationModel optModel = new OptimizationModel(func);
            EnumConverter InitialLoadTypeCollection = new EnumConverter(typeof(InitialLoadType));
            EnumConverter EndConditionTypeCollecton = new EnumConverter(typeof(EndCondition));
            EnumConverter MutationTypeCollecton = new EnumConverter(typeof(MutationType));
            EnumConverter SelectionTypeCollection = new EnumConverter(typeof(SelectionType));
            foreach (InitialLoadType il in InitialLoadTypeCollection.GetStandardValues())
            {
                foreach (EndCondition ec in EndConditionTypeCollecton.GetStandardValues())
                {
                    foreach (MutationType mt in MutationTypeCollecton.GetStandardValues())
                    {
                        foreach (SelectionType st in SelectionTypeCollection.GetStandardValues())
                        {
                            double[] f1m = new double[(int)numericUpDown8.Value];
                            double[] f2m = new double[(int)numericUpDown8.Value];
                            double[] fm = new double[(int)numericUpDown8.Value];
                            double[] x1m = new double[(int)numericUpDown8.Value];
                            double[] x2m = new double[(int)numericUpDown8.Value];
                            for (int i = 0; i < (int)numericUpDown8.Value; i++)
                            {
                                AlgorithmSettings settings = new AlgorithmSettings()
                                {
                                    InitialLoadType = il,
                                    OptModel = optModel,
                                    InitialPointCount = (int)numericUpDown1.Value,
                                    SelectionType = st,
                                    EndCondition = ec,
                                    MaxGenerationCount = (int)numericUpDown2.Value,
                                    SurvivedCount = (int)numericUpDown3.Value,
                                    MutationChance = (double)numericUpDown4.Value,
                                    CrossingGenNumber = (int)numericUpDown5.Value,
                                    Tolerance = (double)numericUpDown6.Value,
                                    MutationChanceAfterCrossing = (double)numericUpDown7.Value,
                                    MutationType = mt
                                };
                                alg.Run(settings);
                                double x1 = alg.Best.X1;
                                double x2 = alg.Best.X2;
                                double f1 = alg.Best.F;
                                double f2 = alg.CallCount;
                                double f = GetCriterion(f1, f2);
                                f1m[i] = f1;
                                f2m[i] = f2;
                                fm[i] = f;
                                x1m[i] = x1;
                                x2m[i] = x2;
                                optrez.Add(new OptRezult()
                                {
                                    I = il,
                                    E = ec,
                                    S = st,
                                    M = mt,
                                    F1 = f1,
                                    F2 = f2,
                                    X1 = x1,
                                    X2 = x2,
                                    F = f
                                });
                            }
                            progress++;
                            backgroundWorker1.ReportProgress(progress * 100 / 24);
                            finalRez.Add(new OptRezult()
                            {
                                I = il,
                                E = ec,
                                S = st,
                                M = mt,
                                X1 = x1m.Average(),
                                X2 = x2m.Average(),
                                F1 = f1m.Average(),
                                F2 = f2m.Average(),
                                F = fm.Average()

                            });
                        }
                    }
                }
            }
    }
开发者ID:OsAnYa,项目名称:GeneticAlgorithm,代码行数:85,代码来源:Form1.cs


注:本文中的System.ComponentModel.EnumConverter.GetStandardValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。