Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            TSPFileLoader fileLoader = new TSPFileLoader();

            fileLoader.LoadAndListTSPFiles();
            TSPProblem problem = fileLoader.SelectAndLoadFile();

            //problem.PrintDistanceMatrix();

            Console.WriteLine("\nRandom Algorithm");
            Algorithm randomAlgorithm = new RandomAlgorithm(problem);

            randomAlgorithm.PerformAlgorithm();
            printAlgorithmResults(randomAlgorithm);

            Console.WriteLine("\nGreedy Algorithm");
            Algorithm greedyAlgorithm = new GreedyAlgorithm(problem);

            greedyAlgorithm.PerformAlgorithm();
            printAlgorithmResults(greedyAlgorithm);

            GeneticAlgorithmParameters parameters = readParameters();

            Algorithm geneticAlgorithm = new GeneticAlgorithm(problem)
            {
                Parameters = parameters,
                Selection  = new TournamentSelection(),
                Crossover  = new OrderedCrossover(),
                Mutation   = new InversionMutation()
            };

            geneticAlgorithm.PerformAlgorithm();
            printAlgorithmResults(geneticAlgorithm);
        }