示例#1
0
        // Method to run, time and print results from TwoOpt test
        public static void RunTwoOpt(TSPInstance test)
        {
            // start stopwatch
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // create new tour from NearestNeighbour.
            List <PointF> twoOpt = test.TwoOpt(test.NearestNeighbour(test.originalCitiesData));

            // Stop timer
            stopwatch.Stop();
            long elaspedTime = stopwatch.ElapsedMilliseconds;

            // Print results
            PrintResult(elaspedTime, test.CalculateLength(twoOpt), test.Correct(twoOpt));
        }
示例#2
0
        // Method to run, time and print results from nearest neighbour test
        public static void RunNearestNeighbour(TSPInstance test)
        {
            // Start timer
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // create new tour from original read-in data, using nearest neighbour algorithm
            List <PointF> nn = test.NearestNeighbour(test.originalCitiesData);

            // Stop timer
            stopwatch.Stop();
            long elaspedTime = stopwatch.ElapsedMilliseconds;

            // print results
            // calculate total length of tour
            // check if solution is correct (no duplicates/dimensions are correct/everything exists in the list)
            PrintResult(elaspedTime, test.CalculateLength(nn), test.Correct(nn));
        }