public void EuclideanPathPerformanceTest(int numberOfPoints) { var path = PathGeneratorFactory.Create(TspPathType.Uniform2DRandom, new Size(10, 10), numberOfPoints); var transPath = path.Select(coordinate => coordinate.To2DPoint()).ToArray(); var euclideanPath = new EuclideanPath(transPath); var fastEuclideanPath = new FastEuclideanPath(transPath); var sequence = Enumerable.Range(0, numberOfPoints).ToArray(); Stopwatch standardStopwatch = new Stopwatch(); standardStopwatch.Start(); double distanceStandard = euclideanPath.GetPathLength(sequence, true); standardStopwatch.Stop(); Stopwatch fastStopwatch = new Stopwatch(); fastStopwatch.Start(); double distanceFast = euclideanPath.GetPathLength(sequence, true); fastStopwatch.Stop(); Assert.IsTrue(Math.Abs(distanceStandard - distanceFast) < 1E-06); Console.WriteLine("Ticks standard: " + standardStopwatch.ElapsedTicks.ToString()); Console.WriteLine("Ticks fast: " + fastStopwatch.ElapsedTicks.ToString()); }
private void OnPathTypeChanged() { int numberOfPoints = VerifyInput(); var path = PathGeneratorFactory.Create(SelectedPathType, new Size(10, 10), numberOfPoints); if (path == null) { Info = "Path generator not yet implemented :-("; return; } _initialPath = path.Select(coordinate => coordinate.To2DPoint()).ToArray(); _euclideanPath = new FastEuclideanPath(_initialPath); _shuffledTour = Enumerable.Range(0, _initialPath.Length).ToArray(); PlotTour(Enumerable.Range(0, _initialPath.Length).ToArray()); }