本文整理汇总了C#中HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinEncoding.GetTourLength方法的典型用法代码示例。如果您正苦于以下问题:C# PotvinEncoding.GetTourLength方法的具体用法?C# PotvinEncoding.GetTourLength怎么用?C# PotvinEncoding.GetTourLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinEncoding
的用法示例。
在下文中一共展示了PotvinEncoding.GetTourLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindBetterInsertionPlace
private static bool FindBetterInsertionPlace(
PotvinEncoding individual, IVRPProblemInstance instance, int tour, int city, int length,
out int insertionTour, out int insertionPlace) {
bool insertionFound = false;
insertionTour = -1;
insertionPlace = 1;
List<int> toBeDeleted = individual.Tours[tour].Stops.GetRange(city, length);
double distance = individual.GetTourLength(individual.Tours[tour]);
individual.Tours[tour].Stops.RemoveRange(city, length);
double removalBenefit = distance - individual.GetTourLength(individual.Tours[tour]);
int currentTour = 0;
while (currentTour < individual.Tours.Count && !insertionFound) {
int currentCity = 0;
while (currentCity <= individual.Tours[currentTour].Stops.Count && !insertionFound) {
distance = individual.GetTourLength(individual.Tours[currentTour]);
individual.Tours[currentTour].Stops.InsertRange(currentCity, toBeDeleted);
if (instance.TourFeasible(individual.Tours[currentTour], individual)) {
double lengthIncrease =
individual.GetTourLength(individual.Tours[currentTour]) - distance;
if (removalBenefit > lengthIncrease) {
insertionTour = currentTour;
insertionPlace = currentCity;
insertionFound = true;
}
}
individual.Tours[currentTour].Stops.RemoveRange(currentCity, length);
currentCity++;
}
currentTour++;
}
individual.Tours[tour].Stops.InsertRange(city, toBeDeleted);
return insertionFound;
}