public GeneticPeriodicTabu(Problem.Problem problem, GeneticPeriodicTabuParameters parameters)
        {
            Problem = problem;
            Genetic = new GaTtp1(problem, parameters.GeneticParameters);

            var tabuParameters = new TabuParameters
            {
                NeighbourhoodSize      = parameters.TabuParameters.NeighbourhoodSize,
                NumAlgorithmIterations = 1,
                NumTabuSearches        = parameters.TabuParameters.NumTabuSearches,
                TabuSize = parameters.TabuParameters.TabuSize,
            };

            Parameters = parameters;
            Parameters.TabuParameters = tabuParameters;

            Tabu = new TabuTtp1(problem, tabuParameters);
        }
Esempio n. 2
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);
        }