示例#1
0
        public void RunGDE3 <S>()
            where S : ContinuousVector, new()
        {
            GDE3 <S> algorithm = new GDE3 <S>(GetProblem());

            algorithm.PopulationSize = 100;

            algorithm.Initialize();

            ClearStatusInfo();

            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress = true;
            worker.DoWork += (s1, e1) =>
            {
                while (!algorithm.IsTerminated)
                {
                    algorithm.Evolve();
                    worker.ReportProgress(0);
                }
            };
            worker.ProgressChanged += (s1, e1) =>
            {
                txtStatus1.Text = string.Format("Current Generation: {0}", algorithm.CurrentGeneration);
                txtStatus2.Text = string.Format("Size of Archive: {0}", algorithm.NondominatedArchiveSize);
            };
            worker.RunWorkerCompleted += (s1, e1) =>
            {
                NondominatedPopulation <S> archive = algorithm.NondominatedArchive;
                DisplayParetoFront(archive);
            };
            worker.RunWorkerAsync();
        }
示例#2
0
        static void RunGDE3()
        {
            GDE3 <ContinuousVector> algorithm = new GDE3 <ContinuousVector>(new TNKProblem());

            algorithm.PopulationSize = 100;


            algorithm.Initialize();

            while (!algorithm.IsTerminated)
            {
                algorithm.Evolve();
                Console.WriteLine("Current Generation: {0}", algorithm.CurrentGeneration);
                Console.WriteLine("Size of Archive: {0}", algorithm.NondominatedArchiveSize);
            }
            ContinuousVector finalSolution = algorithm.GlobalBestSolution;
        }