示例#1
0
        public void RunNSGAII <S>()
            where S : ContinuousVector, new()
        {
            NSGAII <S> algorithm = new NSGAII <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);
                //Console.WriteLine("Number of Dominating Improvements: {0}", algorithm.NumberOfDominatingImprovements);
                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 RunNSGAII()
        {
            NSGAII <ContinuousVector> algorithm = new NSGAII <ContinuousVector>(new NDNDProblem());

            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;
        }