本文整理汇总了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
{