/// <summary>
        /// Configuration GA.
        /// </summary>
        /// <param name="problemConfig">Problem represention</param>
        /// <returns>GA</returns>
        public static IEVA[] SetGA(IProblemConfig[] problemConfig, bool parlelization)
        {
            Console.WriteLine("Custom Genetic algorithm.");
            var termination = ParameterSetter.SetTermination(problemConfig[0]);
            var crossover   = ParameterSetter.SetXover(problemConfig[0]);
            var xoverProb   = ParameterSetter.SetFloat("Xover Probability", 0, 1);

            var mutation     = ParameterSetter.SetMutation(problemConfig[0]);
            var mutationProb = ParameterSetter.SetFloat("Mutation Probability", 0, 1);

            var selection = ParameterSetter.SetSelection(problemConfig[0]);
            var elitizmus = ParameterSetter.SetElite(problemConfig[0]);

            var executor = problemConfig[0].CreateExecutor();
            var popSize  = ParameterSetter.SetPositiveIntParameter("Pop size", 2);

            IEVA[] evas = new IEVA[problemConfig.Length];

            int i = 0;

            foreach (var config in problemConfig)
            {
                // creates population with curr. popSize
                var population = new Population(popSize, config.CreateIndividual, config.CreateEmptyIndividual);

                // new operators
                var fitness = config.CreateFitness();

                evas[i++] = new GeneticAlgorithm(population, fitness, selection, crossover, mutation, elitizmus, termination, executor, mutationProb, xoverProb);
            }

            return(evas);
        }
        static void Main(string[] args)
        {
            bool running = true;

            while (running)
            {
                Console.Clear();

                Console.WriteLine("Evolution image approximation.");

                var paralelization = ParameterSetter.SetBool("Parallelization");

                // Logger rate
                var logRate = ParameterSetter.SetPositiveIntParameter("Logger rate", 1);

                // load input image
                var inputFileName = ParameterSetter.SetFileNameParameter("image");

                var problemConfigName = ParameterSetter.SetProblemCOofig();


                if (paralelization)
                {
                    RunParallelImage(problemConfigName, inputFileName, logRate, paralelization);
                }
                else
                {
                    RunImage(problemConfigName, inputFileName, logRate, paralelization);
                }

                Console.WriteLine("EVOLVED");
                running = ParameterSetter.SetBool("RESTART");
            }
        }
        /// <summary>
        /// Parallel EA.
        /// </summary>
        /// <param name="problemConfigName">Problem represention.</param>
        /// <param name="inputFileName">Input image</param>
        /// <param name="logRate">logger rate</param>
        public static void RunParallelImage(Type problemConfigName, string inputFileName, int logRate, bool parallelization)
        {
            var img = Image.FromFile(inputFileName) as Bitmap;

            var blockSize = ParameterSetter.SetPositiveIntParameter("Block size", 5);

            Bitmap[] targets = Split_Concate.SplitImg(img, blockSize);

            var consoleProblemConfigs = new IImageProblemConfig[targets.Length];
            var evas = new IEVA[targets.Length];


            var configuration = new Configuration[targets.Length];

            for (int i = 0; i < targets.Length; i++)
            {
                consoleProblemConfigs[i] = Activator.CreateInstance(problemConfigName) as IImageProblemConfig;
                consoleProblemConfigs[i].Initialize(i);

                consoleProblemConfigs[i].Initialize(targets[i], inputFileName);

                configuration[i] = new Configuration();
            }

            evas = Configuration.SetEVA(consoleProblemConfigs, parallelization);

            for (int i = 0; i < targets.Length; i++)
            {
                configuration[i].SetGenerationInfoLog(evas[i], consoleProblemConfigs[i], logRate);
                consoleProblemConfigs[i].ConfigGATermination(evas[i]);
            }

            IIndividual[] bestInds = new IIndividual[targets.Length];

            var stopwatch = Stopwatch.StartNew();

            /**/
            Parallel.For(0, evas.Length, index => {
                evas[index].Run();

                bestInds[index] = evas[index].BestIndividual;

                // configuration[index].Saveinfo(inputFileName, index);
            });

            /*/
             *
             * for (var index = 0; index < evas.Length; index++)
             * {
             *  evas[index].Run();
             *
             *  bestInds[index] = evas[index].BestIndividual;
             *
             * //  Configuration.Saveinfo(inputFileName,);
             *
             * }
             *
             *
             * /**/
            stopwatch.Stop();


            Console.WriteLine("Total time: " + stopwatch.Elapsed);
            var result = Split_Concate.ConcateImgs(bestInds, blockSize, img.Width, img.Height);

            var m_destFolder = Configuration.CreateDirectory(inputFileName, "result_final");

            var fileName = m_destFolder + "/" + "final" + ".png";

            result.Save(fileName);
        }