Exemplo n.º 1
0
        private void Improve()
        {
            Random number = new Random();

            _currentImproveTour = new AlgorithmTour(Tour);

            while (_runtime.ElapsedMilliseconds < 11500)
            {
                if (number.Next(99) >= 60)
                {
                    RandomStrat();
                }
                else
                {
                    GreedyStrat();
                }
            }
        }
Exemplo n.º 2
0
        private void NearestNeighbor(int startingPointIndex)
        {
            var outputList = new List <Vertex> {
                _vertices[startingPointIndex]
            };
            var tempList = new List <Vertex>(_vertices);

            tempList.Remove(outputList.First());

            var count = tempList.Count;

            for (int i = 0; i < count; i++)
            {
                tempList.Sort
                (
                    (x, y) => x.DistanceToVertex(outputList[i]).CompareTo(y.DistanceToVertex(outputList[i]))
                );
                outputList.Add(tempList.First());
                tempList.RemoveAt(0);
            }
            _vertices = outputList;
            Tour      = new AlgorithmTour(outputList);
        }