public GaThenSaTtp1(Problem.Problem problem, GaThenSATtp1Parameters parameters)
        {
            Problem = problem;
            Genetic = new GaTtp1(problem, parameters.GeneticParameters);

            var annealingParams = new AnnealingParameters
            {
                InitialTemperature                = parameters.AnnealingParameters.InitialTemperature,
                NeighbourhoodSize                 = parameters.AnnealingParameters.NeighbourhoodSize,
                NumAlgorithmIterations            = 1,
                NumAnnealingCycles                = parameters.AnnealingParameters.NumAnnealingCycles,
                TemperaturePercentageDropPerCycle = parameters.AnnealingParameters.TemperaturePercentageDropPerCycle,
            };

            Parameters = parameters;
            Parameters.AnnealingParameters = annealingParams;

            Annealing = new AnnealingTtp1(problem, annealingParams);
        }
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);
        }