예제 #1
0
        private void generateLines()
        {
            Location[] bestSolutionSoFar = _bestSolutionSoFar;
            Location.GetTotalDistance(_startLocation, bestSolutionSoFar);

            _tspSegments.Clear();

            if (bestSolutionSoFar.Length > 0)
            {
                var actualLocation = _startLocation;
                int index          = 0;
                int dropCount      = 0;

                foreach (var destination in _AddEndLocation(bestSolutionSoFar))
                {
                    var line = new TSPSegment()
                    {
                        start = new Vector2(actualLocation.X, actualLocation.Y), end = new Vector2(destination.X, destination.Y)
                    };
                    if (line.LineLength() > kJumpThreshold)
                    {
                        line.type = TSPSegment.LineType.Jump;
                    }
                    else
                    {
                        line.type = TSPSegment.LineType.Draw;
                    }

                    _tspSegments.Add(line);

                    actualLocation = destination;
                    index++;
                }

                Debug.WriteLine("Total long jumps: " + dropCount);
                Debug.WriteLine("Segments added: " + _tspSegments.Count);
            }
        }
예제 #2
0
        private void generateLines()
        {
            Location[] bestSolutionSoFar = _bestSolutionSoFar;
            Location.GetTotalDistance(_startLocation, bestSolutionSoFar);

            _tspSegments.Clear();

            if (bestSolutionSoFar.Length > 0)
            {
                var actualLocation = _startLocation;
                int index = 0;
                int dropCount = 0;

                foreach (var destination in _AddEndLocation(bestSolutionSoFar))
                {
                    var line = new TSPSegment() { start = new Vector2(actualLocation.X, actualLocation.Y), end = new Vector2(destination.X, destination.Y) };
                    if (line.LineLength() > kJumpThreshold)
                    {
                        line.type = TSPSegment.LineType.Jump;
                    }
                    else
                    {
                        line.type = TSPSegment.LineType.Draw;
                    }

                    _tspSegments.Add(line);

                    actualLocation = destination;
                    index++;
                }

                Debug.WriteLine("Total long jumps: " + dropCount);
                Debug.WriteLine("Segments added: " + _tspSegments.Count);
            }
        }