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


C# Route.isValid方法代码示例

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


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

示例1: executeStrategy


//.........这里部分代码省略.........

                    if (ordersSelectedForGeneticSwap.Contains(randomOrder))
                        continue;

                    ordersSelectedForGeneticSwap.Add(randomOrder);

                } while (ordersSelectedForGeneticSwap.Count * 2 < numberOfGenesThatAreTransferred - 1);

                List<int> indicesToBeSwaped = new List<int>(); // Change into a array [2], to keep track which index belongs where
                foreach (Order order in ordersSelectedForGeneticSwap)
                {
                    indicesToBeSwaped.Add(bestBoyAbominationOffspring.Orders.FindIndex(o => o == order));
                    indicesToBeSwaped.Add(bestGirlAbominationOffspring.Orders.FindIndex(o => o == order));
                }
                indicesToBeSwaped.Sort();

                Route newBoyAbominationOffspring = new Route(originalRoute.Day);
                Route newGirlAbominationOffspring = new Route(originalRoute.Day);

                for (int index = 0; index < originalRoute.Orders.Count - 1; index++)
                {
                    if (indicesToBeSwaped.Contains(index)) // Erm.. What?
                    {
                        newBoyAbominationOffspring.AddOrder(bestGirlAbominationOffspring.Orders[index]);
                        newGirlAbominationOffspring.AddOrder(bestBoyAbominationOffspring.Orders[index]);
                    }
                    else
                    {
                        newBoyAbominationOffspring.AddOrder(bestBoyAbominationOffspring.Orders[index]);
                        newGirlAbominationOffspring.AddOrder(bestGirlAbominationOffspring.Orders[index]);
                    }
                }

                if (newBoyAbominationOffspring.isValid() && !newGirlAbominationOffspring.isValid()) // One is allowed
                    if (bestBoyAbominationOffspring.TravelTime < bestGirlAbominationOffspring.TravelTime)
                        bestGirlAbominationOffspring = newBoyAbominationOffspring;
                    else
                        bestBoyAbominationOffspring = newBoyAbominationOffspring;
                else if (!newBoyAbominationOffspring.isValid() && newGirlAbominationOffspring.isValid()) // Other one allowed
                    if (bestBoyAbominationOffspring.TravelTime < bestGirlAbominationOffspring.TravelTime)
                        bestGirlAbominationOffspring = newGirlAbominationOffspring;
                    else
                        bestBoyAbominationOffspring = newGirlAbominationOffspring;
                else if (!newBoyAbominationOffspring.isValid() && !newGirlAbominationOffspring.isValid()) // Neither is allowed
                {
                    numOfGenerationsToMake--;
                    continue;
                }

                bool newGirlAbominationOffspringIstheBest = newBoyAbominationOffspring.TravelTime <= newGirlAbominationOffspring.TravelTime;
                if (boyAbominationIsTheBest)
                {
                    if (newGirlAbominationOffspringIstheBest)
                    {
                        if (bestGirlAbominationOffspring.TravelTime < newGirlAbominationOffspring.TravelTime)
                        {
                            bestGirlAbominationOffspring = newGirlAbominationOffspring;

                            if (bestBoyAbominationOffspring.TravelTime < newBoyAbominationOffspring.TravelTime)
                            {
                                bestBoyAbominationOffspring = newBoyAbominationOffspring;
                            }
                        }
                    }
                    else
                    {
开发者ID:Gliath,项目名称:GroteOpdrachtOpt,代码行数:67,代码来源:GeneticOneRandomRouteStrategy.cs


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