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


C# Population.Initialize方法代码示例

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


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

示例1: RunGA


//.........这里部分代码省略.........
            List<IIndividual> initPop = new List<IIndividual>(popSize);
            for (int i = 0; i < popSize; i++)
            {
                initPop.Add(new MLRIndividual(_maxIndVars, _totVar, fitnessCriteria, _maxVIF, _decisionThreshold, _mandateThreshold));
                //initPop.Add(new MLRIndividual(_maxIndVars, _totVar, fitnessCriteria, _maxVIF));
            }

            Population population = new Population(initPop);

            population.CrossoverMethod = new MLROnePointCrossover(crossoverRate);

            if (fitnessCriteria == FitnessCriteria.Akaike)
            {
                population.Comparer = new AscendSort();
                AICSelector aicSelector = new AICSelector();
                aicSelector.Comparer = population.Comparer;
                population.Selector = aicSelector;
            }
            else if (fitnessCriteria == FitnessCriteria.AICC)
            {
                population.Comparer = new AscendSort();
                AICCSelector aiccSelector = new AICCSelector();
                aiccSelector.Comparer = population.Comparer;
                population.Selector = aiccSelector;
            }
            else if (fitnessCriteria == FitnessCriteria.BIC)
            {
                population.Comparer = new AscendSort();
                BICSelector bicSelector = new BICSelector();
                bicSelector.Comparer = population.Comparer;
                population.Selector = bicSelector;
            }
            else if (fitnessCriteria == FitnessCriteria.Press)
            {
                population.Comparer = new AscendSort();
                PressSelector pressSelector = new PressSelector();
                pressSelector.Comparer = population.Comparer;
                population.Selector = pressSelector;
            }
            else if (fitnessCriteria == FitnessCriteria.AdjustedR2)
            {
                population.Comparer = new DescendSort();
                AdjR2Selector adjR2Selector = new AdjR2Selector();
                adjR2Selector.Comparer = population.Comparer;
                population.Selector = adjR2Selector;
            }
            else if (fitnessCriteria == FitnessCriteria.R2)
            {
                population.Comparer = new DescendSort();
                R2Selector r2Selector = new R2Selector();
                r2Selector.Comparer = population.Comparer;
                population.Selector = r2Selector;
            }
            else if (fitnessCriteria == FitnessCriteria.RMSE)
            {
                population.Comparer = new AscendSort();
                RMSESelector rmseSelector = new RMSESelector();
                rmseSelector.Comparer = population.Comparer;
                population.Selector = rmseSelector;
            }
            else if (fitnessCriteria == FitnessCriteria.Sensitivity)
            {
                population.Comparer = new DescendSort();
                SensitivitySelector sensitivitySelector = new SensitivitySelector();
                sensitivitySelector.Comparer = population.Comparer;
                population.Selector = sensitivitySelector;
            }
            else if (fitnessCriteria == FitnessCriteria.Specificity)
            {
                population.Comparer = new DescendSort();
                SpecificitySelector specificitySelector = new SpecificitySelector();
                specificitySelector.Comparer = population.Comparer;
                population.Selector = specificitySelector;
            }
            else if (fitnessCriteria == FitnessCriteria.Accuracy)
            {
                population.Comparer = new DescendSort();
                AccuracySelector accuracySelector = new AccuracySelector();
                accuracySelector.Comparer = population.Comparer;
                population.Selector = accuracySelector;
            }

            population.ChromosomeComparer = new CompareChromosomes();

            population.Initialize();

            population.Mutator = new MLRMutator(mutationRate, _totVar);

            //GALib.GAManager ga = new GALib.GAManager();
            _gaManager = new GALib.GAManager();
            _gaManager.Init(population);
            _gaManager.NumberOfGenerations = numGen;
            _gaManager.GAProgress += new GAManager.GAProgressHandler(GAUpdate);
            _gaManager.GAComplete += new GAManager.GACompleteHandler(GAComplete);

            GAManager ga = new GAManager();
            _runThread = new Thread(_gaManager.Run);
            _runThread.Start();
            //list = ga.Run(population);
        }
开发者ID:wrbrooks,项目名称:VB3,代码行数:101,代码来源:frmModel.cs


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