private static List <_2opt.NET.Point> GetRandomizedPoints(int count, int xlim, int ylim) { var points = new List <_2opt.NET.Point>(); while (points.Count < count) { var point = new _2opt.NET.Point(rng.Next(xlim), rng.Next(ylim)); if (!points.Contains(point)) { points.Add(point); } } return(points); }
private static List <_2opt.NET.Point> MutateIntersectingLines(List <_2opt.NET.Point> points, List <Tuple <Line, Line> > intersectingLines) { var pairIndex = rng.Next(intersectingLines.Count); Tuple <Line, Line> pair = intersectingLines[pairIndex]; //Debug.WriteLine($"Intersecting pair: {pair.Item1} {pair.Item2}"); Line line1; Line line2; if (rng.Next(1) == 1) { line1 = pair.Item1; line2 = pair.Item2; } else { line1 = pair.Item2; line2 = pair.Item1; } _2opt.NET.Point left = line1.Points[0]; _2opt.NET.Point right = line2.Points[1]; for (int i = 0; i < points.Count; i++) { if (points[i] == left) { points[i] = right; } else if (points[i] == right) { points[i] = left; } } return(points); }