public void Execute(Logger.Logger logger) { void logGeneration(int generation, double bestFitness, double averageFitness, double worstFitness) { logger.LogGeneticPeriodicTabu(generation, bestFitness, averageFitness, worstFitness, null); } void logOutro(List <double> bestFitnesses) { logger.LogOutro(bestFitnesses); } void logTabuCycle(int tabuCycle, double bestFitness, double currentFitness) { logger.LogGeneticPeriodicTabu(tabuCycle, bestFitness, null, null, currentFitness); } var populations = new List <List <IIndividual> >(); for (var i = 0; i < Parameters.GeneticParameters.NumAlgorithmIterations; i++) { populations.Add(Genetic.InitializePopulation().Select(indiv => { return(Tabu.Execute(logTabuCycle, logOutro, indiv)[0]); }).ToList()); } Genetic.Execute(logGeneration, logOutro, Parameters.TabuParameters.NumTabuSearches, populations); }
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); }