public TspSolution Execute(TsPoint[] points) { var sortedPoints = points.OrderBy(p => p.X).ThenBy(p => p.Y); var firstPoint = sortedPoints.First(); var solution = new TspSolution(firstPoint); foreach (var point in sortedPoints.Skip(1)) solution.AddNext(point); solution.Close(); return solution; }
public TspSolution Execute(TsPoint[] points) { TspSolution current = null; var sortedPoints = points.OrderBy(p => p.X + p.Y).ToArray(); for (double ts = .5; ts < 1.00; ts = ts + .01) { var newSolution = new TspSolver01(ts).Execute(sortedPoints); if (current == null || newSolution.Distance < current.Distance) current = newSolution; } if (current != null) current.OutputToDebug(); return current; }