private static void TestRecuitSimule() { string problemFilepath = path + "tai12a" + ".dat"; QuadraticAssignment qap = new QuadraticAssignment(problemFilepath); QuadraticAssignmentSolution initialSol = qap.Identity; QuadraticAssignmentSolution best; RecuitSimule recuit = new RecuitSimule(qap); best = recuit.Execute(initialSol, 70000, 0.85f, 200); Console.WriteLine(recuit.Logs.FinalLog.ToString()); Console.WriteLine(recuit.Logs.ToStringImprovements()); }
private static void TestRecuitSimuleGA() { string problemFilepath = path + "tai12a" + ".dat"; QuadraticAssignment qap = new QuadraticAssignment(problemFilepath); //Seed it! RandomSingleton.Instance.Seed = 0; QuadraticAssignmentSolution initialSol = qap.Identity; RecuitSimule recuit = new RecuitSimule(qap); GeneticAlgorithmRecuit ga = new GeneticAlgorithmRecuit(recuit, 40, 15, 0.05d, 1, 3); ga.Verbose = true; ga.WithLogs = true; RecuitSimuleParameters bestParam = ga.Run(); QuadraticAssignmentSolution best = recuit.Execute(bestParam); Console.WriteLine("Best Params : " + bestParam.ToString()); Console.WriteLine("\nBest Solution : " + best.ToString()); Console.WriteLine("Fitness : " + best.Fitness); }
private static bool RunRecuit(bool verbose = true, RecuitSimuleParameters param = null) { algo = Algo.Recuit; bool interrupted = false; if (verbose) { param = GetParamRecuit(out interrupted); if (interrupted) { return(false); } //param = new RecuitSimuleParameters(qap.N); Console.WriteLine("Tout les paramètres sont entrées, commencer l'exécution ? ( o/n, y/n )"); Console.WriteLine(param.ToString()); string str = ""; if (!GetCorrectString(out str, (s) => IsValidation(s))) { return(false); } if (!IsYes(str)) { return(false); } } //Lancer l'exécution RecuitSimule recuit = new RecuitSimule(qap); recuit.Verbose = true; bestFitness = recuit.Execute(param).Fitness; Console.WriteLine("Paramètres :"); Console.WriteLine(param.ToString()); Console.WriteLine("Résultats :"); Console.WriteLine(recuit.Logs.FinalLog.ToString()); paramString = param.ToString(); resultString = recuit.Logs.FinalLog.ToString(); //Save Results SaveResults(); Console.WriteLine("Résultats sauvegardées dans " + GetResultPath() + "!"); //Save Logs recuit.Logs.SaveLogsTo(GetCSVPath()); Console.WriteLine("Logs sauvegardées dans " + GetCSVPath() + "!"); if (verbose) { Console.WriteLine("\nAppuyez sur une touche pour revenir au menu."); Console.ReadKey(); Console.WriteLine(); } return(true); }