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 SetOptSequenceGlobalGridPoints() { var euclideanPath = new FastEuclideanPath(_globalGridPoints); var optimizer = TspOptimizerFactory.Create (TspOptimizerAlgorithm.BranchAndBoundOptimizer, Enumerable.Range(0, _globalGridPoints.Length).ToArray(), euclideanPath, _config); optimizer.OptimalSequence.Subscribe(seq => _globalGridPointSequence = seq); optimizer.Start(_token, _action); GlobalMinPath = euclideanPath.GetPathLength(_globalGridPointSequence, true); }