コード例 #1
0
        public void CompareToShouldCompareOnTourLength(double tourLength1, double tourLength2, int compareResult)
        {
            // arrange
              var tour1 = new BestTour { TourLength = tourLength1, Tour = new[] { 1, 2, 3, 4 } };
              var tour2 = new BestTour { TourLength = tourLength2, Tour = new[] { 1, 2, 3, 4 } };

              // act
              var result = tour1.CompareTo(tour2);

              // assert
              Assert.AreEqual(compareResult, result);
        }
        protected bool CheckBestTour()
        {
            Ant    bestAnt        = antin.FindBestAnt();
            double tourLengthTemp = bestAnt.TourLength;

            if (tourLengthTemp < TourLength)
            {
                TourLength = tourLengthTemp;
                BestTour.Clear();
                for (int i = 0; i < bestAnt.Tour.Count; i++)
                {
                    BestTour.Add(bestAnt.Tour[i]);
                    BestIteration = iteration;
                }
                return(true);
            }
            return(false);
        }