Example #1
0
        private static void TestTabou()
        {
            string problemFilepath  = path + "tai40a" + ".dat";
            QuadraticAssignment qap = new QuadraticAssignment(problemFilepath);

            //Seed it!
            //RandomSingleton.Instance.Seed = 0;
            //QuadraticAssignmentSolution initialSol = QuadraticAssignmentSolution.GetIdentity(qap.N);

            RandomSingleton.Instance.Seed = 6;
            QuadraticAssignmentSolution initialSol = new QuadraticAssignmentSolution(qap.N);


            MethodeTabou.MethodTabou tabou = new MethodeTabou.MethodTabou(qap);
            tabou.Verbose = true;

            QuadraticAssignmentSolution best = tabou.Run(
                initialSol,
                80,
                500);

            Console.WriteLine(tabou.Logs.FinalLog.ToString());

            Console.WriteLine(tabou.Logs.ToStringImprovements());

            //Console.WriteLine("Best : " + best.ToString());
            //Console.WriteLine("Fitness : " + best.Fitness);
        }
Example #2
0
        private static bool RunTabou(bool verbose = true, TabouParameters param = null)
        {
            algo = Algo.Tabou;
            bool interrupted = false;

            if (verbose)
            {
                param = GetParamTabou(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
            MethodeTabou.MethodTabou tabou = new MethodeTabou.MethodTabou(qap);

            tabou.Verbose = true;

            bestFitness = tabou.Run(param).Fitness;

            Console.WriteLine("Paramètres :");
            Console.WriteLine(param.ToString());

            Console.WriteLine("Résultats :");
            Console.WriteLine(tabou.Logs.FinalLog.ToString());

            paramString  = param.ToString();
            resultString = tabou.Logs.FinalLog.ToString();

            //Save Results
            SaveResults();
            Console.WriteLine("Résultats sauvegardées dans " + GetResultPath() + "!");

            //Save Logs
            tabou.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);
        }