Ejemplo n.º 1
0
        private static void GeneticPeriodicTabuTtp1(Problem.Problem problem, string algorithmSrcFilePath,
                                                    string outputFilePath,
                                                    string logOutputType)
        {
            var geneticTtp1Params = Loader.Loader.LoadGeneticTtp1Params(algorithmSrcFilePath);

            if (geneticTtp1Params == null)
            {
                Console.WriteLine("Error reading genetic ttp1's configuration src file.");
                return;
            }

            Console.WriteLine("Done reading genetic ttp1's configuration src file.");

            var tabuTtp1Params = Loader.Loader.LoadTabuTtp1Params(algorithmSrcFilePath);

            if (tabuTtp1Params == null)
            {
                Console.WriteLine("Error reading genetic ttp1's configuration src file.");
                return;
            }

            Console.WriteLine("Done reading genetic ttp1's configuration src file.");

            var hybridParams = new GeneticPeriodicTabuParameters
            {
                GeneticParameters = geneticTtp1Params,
                TabuParameters    = tabuTtp1Params,
            };

            var logger = new Logger.Logger(outputFilePath, logOutputType);

            try
            {
                logger.LogGeneticPeriodicTabuIntro(hybridParams);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Error writing to the log output file.");
                return;
            }

            var hybrid = new GeneticPeriodicTabu(problem, hybridParams);

            hybrid.Execute(logger);
        }
Ejemplo n.º 2
0
        private static void SimulatedAnnealingTtp1(Problem.Problem problem, string algorithmSrcFilePath,
                                                   string outputFilePath, string logOutputType)
        {
            var algorithmParams = Loader.Loader.LoadAnnealingTtp1Params(algorithmSrcFilePath);

            if (algorithmParams == null)
            {
                Console.WriteLine("Error reading annealing ttp1's configuration src file.");
                return;
            }

            Console.WriteLine("Done reading annealing ttp1's configuration src file.");

            var logger = new Logger.Logger(outputFilePath, logOutputType);

            try
            {
                logger.LogAnnealingTtp1Intro(algorithmParams);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Error writing to annealing ttp1's log output file.");
                return;
            }

            var algorithm = new AnnealingTtp1(problem, algorithmParams);

            void logAnnealingCycle(int annealingCycle, double globalBestFitness, double bestFitness, double currentFitness)
            {
                logger.LogGeneticThenSaTtp1(annealingCycle, globalBestFitness, null, null, bestFitness, currentFitness);
            }

            void logOutro(List <double> bestFitnesses)
            {
                logger.LogOutro(bestFitnesses);
            }

            algorithm.Execute(logAnnealingCycle, logOutro);
        }
Ejemplo n.º 3
0
        private static void GeneticTtp1(Problem.Problem problem, string algorithmSrcFilePath, string outputFilePath,
                                        string logOutputType)
        {
            var algorithmParams = Loader.Loader.LoadGeneticTtp1Params(algorithmSrcFilePath);

            if (algorithmParams == null)
            {
                Console.WriteLine("Error reading genetic ttp1's configuration src file.");
                return;
            }

            Console.WriteLine("Done reading genetic ttp1's configuration src file.");

            var logger = new Logger.Logger(outputFilePath, logOutputType);

            try
            {
                logger.LogGeneticTtp1Intro(algorithmParams);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Error writing to the log output file.");
                return;
            }

            void logGeneration(int generation, double bestFitness, double averageFitness, double worstFitness)
            {
                logger.LogGeneticTtp1Generation(generation, bestFitness, averageFitness, worstFitness);
            }

            void logOutro(List <double> bestFitnesses)
            {
                logger.LogOutro(bestFitnesses);
            }

            var algorithm = new GaTtp1(problem, algorithmParams);

            algorithm.Execute(logGeneration, logOutro);
        }
Ejemplo n.º 4
0
        private static void TabuSearchTtp1(Problem.Problem problem, string algorithmSrcFilePath, string outputFilePath,
                                           string logOutputType)
        {
            var algorithmParams = Loader.Loader.LoadTabuTtp1Params(algorithmSrcFilePath);

            if (algorithmParams == null)
            {
                Console.WriteLine("Error reading tabu ttp1's configuration src file.");
                return;
            }

            Console.WriteLine("Done reading tabu ttp1's configuration src file.");

            var logger = new Logger.Logger(outputFilePath, logOutputType);

            try
            {
                logger.LogTabuTtp1Intro(algorithmParams);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("Error writing to tabu ttp1's log output file.");
                return;
            }

            void logTabuSearch(int numTabuSearch, double bestFitness, double currentFitness)
            {
                logger.LogTabuTtp1Search(numTabuSearch, bestFitness, currentFitness);
            }

            void logOutro(List <double> bestFitnesses)
            {
                logger.LogOutro(bestFitnesses);
            }

            var algorithm = new TabuTtp1(problem, algorithmParams);

            algorithm.Execute(logTabuSearch, logOutro);
        }