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


C# PotvinEncoding.GetTourLength方法代码示例

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


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