本文整理汇总了C#中Population.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Population.Any方法的具体用法?C# Population.Any怎么用?C# Population.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Population
的用法示例。
在下文中一共展示了Population.Any方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SolveStep
//.........这里部分代码省略.........
checkPopDupes();
/*
foreach (var eliteCritter in eliteCritters)
{
Tools.ToLinkedNodes(eliteCritter.Route.GetNodes(true));
}
/*
this.nonDominatedSort(this.population);
var ranks = this.population.GroupBy(g => g.Rank);
foreach (var rank in ranks)
{
foreach (var c1 in rank)
{
foreach (var c2 in rank)
{
Assert.That(!this.Dominates(c1, c2), "Members of a front should be non dominate to each other.");
}
}
}
sw.Stop();
this.result.Totaltime = sw.Elapsed;
ranks = this.population.GroupBy(g => g.Rank);
foreach (var rank in ranks)
{
foreach (var c1 in rank)
{
foreach (var c2 in rank)
{
Assert.That(!this.Dominates(c1, c2), "Members of a front should be non dominate to each other.");
}
}
}
*/
var distinct = new Population();
foreach (var c in this.population[0])
{
bool same = false;
foreach (var fitnessParameter in this.properties.Objectives)
{
if (
distinct.Any(
c2 => Math.Abs(c2.Fitness[fitnessParameter] - c.Fitness[fitnessParameter]) < Epsilon))
{
same = true;
}
}
if (!same)
{
distinct.Add(c);
}
}
this.result.Cardinality = distinct.Count;
/*
ranks = distinct.GroupBy(g => g.Rank);
foreach (var rank in ranks)
{
foreach (var c1 in rank)
{
foreach (var c2 in rank)
{
Assert.That(!this.Dominates(c1, c2), "Members of a front should be non dominate to each other.");
}
}
}
*/
this.population[0] = this.population[1];
this.result.Population = (Population)this.population[0].Clone();
// foreach (var critter in this.Population)
// {
// this.result.AverageFitness += critter.Fitness;
// }
// this.result.AverageFitness /= population.Count;
// var sorted = this.Population.OrderBy(z => z.Fitness.TotalJourneyTime);
// this.result.MinimumFitness = sorted.First().Fitness;
// this.result.BestPath = sorted.First().Route;
// Tools.SavePopulation(this.population.GetRange(0, 25), ++this.generation, this.properties);
// this.BestNode = Tools.ToLinkedNodes(this.Population[0].Route);
// Console.WriteLine("Average fitness: {0}", this.result.MinimumFitness);
// return false;
}