コード例 #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);
        }
コード例 #2
0
 public GeneticAlgorithmInstance(TSPProblem problem, ISelection selection, ICrossover crossover, IMutation mutation)
 {
     this.problem    = problem;
     this.selection  = selection;
     this.crossover  = crossover;
     this.mutation   = mutation;
     randomGenerator = new Random();
 }
コード例 #3
0
 public GreedyAlgorithm(TSPProblem problem) : base(problem)
 {
 }
コード例 #4
0
 public Algorithm(TSPProblem problem)
 {
     this.Problem = problem;
 }
コード例 #5
0
 public RandomAlgorithm(TSPProblem problem) : base(problem)
 {
 }
コード例 #6
0
 public GeneticAlgorithm(TSPProblem problem) : base(problem)
 {
 }