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


C# Population.Any方法代码示例

本文整理汇总了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;
        }
开发者ID:NoxHarmonium,项目名称:rmitjourneyplanner,代码行数:101,代码来源:EaJourneyPlanner.cs


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