Beispiel #1
0
        /// <summary>
        /// Sorts the combination of parents and child population set based on Pareto Fron Ranking.
        /// </summary>
        /// <param name="population">Parent solution set.</param>
        /// <param name="offspringPop">Offspring solution set.</param>
        /// <param name="lowerLimits">List of lower limits.</param>
        /// <param name="upperLimits">List of upper limits.</param>
        /// <returns></returns>
        public static List <List <double> > Sorting(List <List <double> > populationList, List <List <double> > offspringList, List <double> lowerLimits, List <double> upperLimits)
        {
            int numVar = lowerLimits.Count;
            int numObj = populationList.Count - numVar;

            Algorithm algorithm = CreateAlgorithm(numObj, lowerLimits, upperLimits);

            //change solutions list to solutionSet
            SolutionSet population   = SolutionListToPop(populationList, algorithm, numVar);
            SolutionSet offspringPop = SolutionListToPop(offspringList, algorithm, numVar);

            // Creating the solutionSet union of solutionSet and offSpring
            SolutionSet union = ((SolutionSet)population).union(offspringPop);

            // Ranking the union
            Ranking ranking = new Ranking(union);

            int         remain = population.size();
            int         index  = 0;
            SolutionSet front  = null;

            population.clear();

            // Obtain the next front
            front = ranking.getSubfront(index);
            //*
            while ((remain > 0) && (remain >= front.size()))
            {
                //Assign crowding distance to individuals
                Distance.crowdingDistanceAssignment(front, algorithm.problem_.numberOfObjectives_);
                //Add the individuals of this front
                for (int k = 0; k < front.size(); k++)
                {
                    population.@add(front[k]);
                }
                //Decrement remain
                remain = remain - front.size();

                //Obtain the next front
                index++;
                if (remain > 0)
                {
                    front = ranking.getSubfront(index);
                }
            }

            // Remain is less than front(index).size, insert only the best one
            if (remain > 0)
            {
                // front contains individuals to insert
                Distance.crowdingDistanceAssignment(front, algorithm.problem_.numberOfObjectives_);
                IComparer comp = new CrowdingDistanceComparator();
                front.solutionList_.Sort(comp.Compare);
                for (int k = 0; k < remain; k++)
                {
                    population.@add(front[k]);
                }
                // for
                remain = 0;
            }

            List <List <double> > pList = PopToSolutionList(population);

            return(PopToSolutionList(population));
        }
Beispiel #2
0
        //changes solution list to solution set
        private static SolutionSet SolutionListToPop(List<List<double>> populationList, Algorithm algorithm, int numVar)
        {
            int popSize = populationList[0].Count;
            int numObj = populationList.Count - numVar;

            SolutionSet population = new SolutionSet(popSize);
            Solution newSolution;

            for (int j = 0; j < popSize; j++)
            {
                newSolution = new Solution(algorithm.problem_);
                for (int i = 0; i < numVar; i++)
                {
                    newSolution.variable_[i].value_ = populationList[i][j];
                }
                population.add(newSolution);
            }
            for (int j = 0; j < population.size(); j++)
            {
                for (int i = 0; i < numObj; i++)
                {
                    population[j].objective_[i] = populationList[i + numVar][j];
                }
            }
            return population;
        }
Beispiel #3
0
        //changes solution list to solution set
        private static SolutionSet SolutionListToPop(List <List <double> > populationList, Algorithm algorithm, int numVar)
        {
            int popSize = populationList[0].Count;
            int numObj  = populationList.Count - numVar;

            SolutionSet population = new SolutionSet(popSize);
            Solution    newSolution;

            for (int j = 0; j < popSize; j++)
            {
                newSolution = new Solution(algorithm.problem_);
                for (int i = 0; i < numVar; i++)
                {
                    newSolution.variable_[i].value_ = populationList[i][j];
                }
                population.add(newSolution);
            }
            for (int j = 0; j < population.size(); j++)
            {
                for (int i = 0; i < numObj; i++)
                {
                    population[j].objective_[i] = populationList[i + numVar][j];
                }
            }
            return(population);
        }