本文整理汇总了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);
}