Esempio n. 1
0
        static private void _MCERoutine(object arg)
        {
            //MessageBox.Show("I am thread " + arg.ToString() + "!");
            int verticesNumber = graph.VerticesNumber;

            Tour bestTour = new Tour(verticesNumber);

            bestTour.FillRandomData();
            double minTourLength = graph.GetTourLength(bestTour);

            for (int i = 0; i < iteratonsNumber; i++)
            {
                Tour tempTour = new Tour(verticesNumber);
                tempTour.FillRandomData();
                double currentTourLength = graph.GetTourLength(tempTour);

                if (currentTourLength < minTourLength)
                {
                    minTourLength = currentTourLength;
                    bestTour.CopyTour(tempTour);
                }
            }

            routineOutput[(int)arg]             = new RoutineOutput();
            routineOutput[(int)arg].RoutineTour = bestTour;
            routineOutput[(int)arg].TourWeight  = graph.GetTourLength(bestTour);
        }
Esempio n. 2
0
        private static void _GARoutine(object arg)
        {
            //MessageBox.Show("I am thread " + arg.ToString() + "!");

            Population population = new Population(capacity, graph);

            population.InitializeRandom();

            for (int i = 0; i < iterationsNumber; i++)
            {
                population.NextGeneration();
            }

            Tour bestTour = population.GetFittest();

            routineOutput[(int)arg]             = new RoutineOutput();
            routineOutput[(int)arg].RoutineTour = bestTour;
            routineOutput[(int)arg].TourWeight  = graph.GetTourLength(bestTour);
        }