/// <summary> /// Performs the operation /// </summary> /// <param name="obj">Object representing a SolutionSet.</param> /// <returns>An object representing a <code>SolutionSet<code> with the selected parents</returns> public override object Execute(object obj) { SolutionSet population = (SolutionSet)obj; int populationSize = (int)Parameters["populationSize"]; SolutionSet result = new SolutionSet(populationSize); //->Ranking the union Ranking ranking = new Ranking(population); int remain = populationSize; int index = 0; SolutionSet front = null; population.Clear(); //-> Obtain the next front front = ranking.GetSubfront(index); while ((remain > 0) && (remain >= front.Size())) { //Asign crowding distance to individuals distance.CrowdingDistanceAssignment(front, problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { result.Add(front.Get(k)); } //Decrement remaint 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 containt individuals to insert distance.CrowdingDistanceAssignment(front, problem.NumberOfObjectives); front.Sort(crowdingComparator); for (int k = 0; k < remain; k++) { result.Add(front.Get(k)); } remain = 0; } return(result); }
/// <summary> /// Runs the SMS-EMOA algorithm. /// </summary> /// <returns>A <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { int populationSize = -1; int maxEvaluations = -1; int evaluations; double offset = 100.0; QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the indicators object (see below) SolutionSet population; SolutionSet offspringPopulation; SolutionSet union; Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); JMetalCSharp.Utils.Utils.GetDoubleValueFromParameter(this.InputParameters, "offset", ref offset); //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; population.Add(newSolution); } // Generations ... while (evaluations < maxEvaluations) { // select parents offspringPopulation = new SolutionSet(populationSize); List <Solution> selectedParents = new List <Solution>(); Solution[] parents = new Solution[0]; while (selectedParents.Count < 2) { object selected = selectionOperator.Execute(population); try { Solution parent = (Solution)selected; selectedParents.Add(parent); } catch (InvalidCastException e) { parents = (Solution[])selected; selectedParents.AddRange(parents); } } parents = selectedParents.ToArray <Solution>(); // crossover Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents); // mutation mutationOperator.Execute(offSpring[0]); // evaluation Problem.Evaluate(offSpring[0]); Problem.EvaluateConstraints(offSpring[0]); // insert child into the offspring population offspringPopulation.Add(offSpring[0]); evaluations++; // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union (non-dominated sorting) Ranking ranking = new Ranking(union); // ensure crowding distance values are up to date // (may be important for parent selection) for (int j = 0; j < population.Size(); j++) { population.Get(j).CrowdingDistance = 0.0; } SolutionSet lastFront = ranking.GetSubfront(ranking.GetNumberOfSubfronts() - 1); if (lastFront.Size() > 1) { double[][] frontValues = lastFront.WriteObjectivesToMatrix(); int numberOfObjectives = Problem.NumberOfObjectives; // STEP 1. Obtain the maximum and minimum values of the Pareto front double[] maximumValues = utils.GetMaximumValues(union.WriteObjectivesToMatrix(), numberOfObjectives); double[] minimumValues = utils.GetMinimumValues(union.WriteObjectivesToMatrix(), numberOfObjectives); // STEP 2. Get the normalized front double[][] normalizedFront = utils.GetNormalizedFront(frontValues, maximumValues, minimumValues); // compute offsets for reference point in normalized space double[] offsets = new double[maximumValues.Length]; for (int i = 0; i < maximumValues.Length; i++) { offsets[i] = offset / (maximumValues[i] - minimumValues[i]); } // STEP 3. Inverse the pareto front. This is needed because the original //metric by Zitzler is for maximization problems double[][] invertedFront = utils.InvertedFront(normalizedFront); // shift away from origin, so that boundary points also get a contribution > 0 for (int j = 0, lj = invertedFront.Length; j < lj; j++) { var point = invertedFront[j]; for (int i = 0; i < point.Length; i++) { point[i] += offsets[i]; } } // calculate contributions and sort double[] contributions = HvContributions(invertedFront); for (int i = 0; i < contributions.Length; i++) { // contribution values are used analogously to crowding distance lastFront.Get(i).CrowdingDistance = contributions[i]; } lastFront.Sort(new CrowdingDistanceComparator()); } // all but the worst are carried over to the survivor population SolutionSet front = null; population.Clear(); for (int i = 0; i < ranking.GetNumberOfSubfronts() - 1; i++) { front = ranking.GetSubfront(i); for (int j = 0; j < front.Size(); j++) { population.Add(front.Get(j)); } } for (int i = 0; i < lastFront.Size() - 1; i++) { population.Add(lastFront.Get(i)); } // This piece of code shows how to use the indicator object into the code // of SMS-EMOA. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if (indicators != null && requiredEvaluations == 0) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } } // Return as output parameter the required evaluations SetOutputParameter("evaluations", requiredEvaluations); // Return the first non-dominated front Ranking rnk = new Ranking(population); Result = rnk.GetSubfront(0); return(Result); }
public override SolutionSet Execute() { double contrDE = 0; double contrSBX = 0; double contrBLXA = 0; double contrPol = 0; double[] contrReal = new double[3]; contrReal[0] = contrReal[1] = contrReal[2] = 0; IComparer <Solution> dominance = new DominanceComparator(); IComparer <Solution> crowdingComparator = new CrowdingComparator(); Distance distance = new Distance(); Operator selectionOperator; //Read parameter values JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); //Init the variables population = new SolutionSet(populationSize); evaluations = 0; selectionOperator = Operators["selection"]; Offspring[] getOffspring; int N_O; // number of offpring objects getOffspring = (Offspring[])GetInputParameter("offspringsCreators"); N_O = getOffspring.Length; contribution = new double[N_O]; contributionCounter = new int[N_O]; contribution[0] = (double)(populationSize / (double)N_O) / (double)populationSize; for (int i = 1; i < N_O; i++) { contribution[i] = (double)(populationSize / (double)N_O) / (double)populationSize + (double)contribution[i - 1]; } // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; newSolution.Location = i; population.Add(newSolution); } while (evaluations < maxEvaluations) { // Create the offSpring solutionSet // Create the offSpring solutionSet offspringPopulation = new SolutionSet(2); Solution[] parents = new Solution[2]; int selectedSolution = JMetalRandom.Next(0, populationSize - 1); Solution individual = new Solution(population.Get(selectedSolution)); int selected = 0; bool found = false; Solution offSpring = null; double rnd = JMetalRandom.NextDouble(); for (selected = 0; selected < N_O; selected++) { if (!found && (rnd <= contribution[selected])) { if ("DE" == getOffspring[selected].Id) { offSpring = getOffspring[selected].GetOffspring(population, selectedSolution); contrDE++; } else if ("SBXCrossover" == getOffspring[selected].Id) { offSpring = getOffspring[selected].GetOffspring(population); contrSBX++; } else if ("BLXAlphaCrossover" == getOffspring[selected].Id) { offSpring = getOffspring[selected].GetOffspring(population); contrBLXA++; } else if ("PolynomialMutation" == getOffspring[selected].Id) { offSpring = ((PolynomialMutationOffspring)getOffspring[selected]).GetOffspring(individual); contrPol++; } else { Console.Error.WriteLine("Error in NSGAIIARandom. Operator " + offSpring + " does not exist"); Logger.Log.Error("NSGAIIARandom. Operator " + offSpring + " does not exist"); } offSpring.Fitness = (int)selected; currentCrossover = selected; found = true; } } Problem.Evaluate(offSpring); offspringPopulation.Add(offSpring); evaluations += 1; // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } } // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(Result); }
/// <summary> /// Runs the NSGA-II algorithm. /// </summary> /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { int populationSize = -1; int maxEvaluations = -1; int evaluations; JMetalCSharp.QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the // indicators object (see below) SolutionSet population; SolutionSet offspringPopulation; SolutionSet union; Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; Distance distance = new Distance(); //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); parallelEvaluator.StartParallelRunner(Problem);; //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; // Create the initial solutionSet IntergenSolution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new IntergenSolution((IntergenProblem)Problem); parallelEvaluator.AddTaskForExecution(new object[] { newSolution, i });; } List <IntergenSolution> solutionList = (List <IntergenSolution>)parallelEvaluator.ParallelExecution(); foreach (IntergenSolution solution in solutionList) { population.Add(solution); evaluations++; } // Generations while (evaluations < maxEvaluations) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize); IntergenSolution[] parents = new IntergenSolution[2]; for (int i = 0; i < (populationSize / 2); i++) { if (evaluations < maxEvaluations) { //obtain parents parents[0] = (IntergenSolution)selectionOperator.Execute(population); parents[1] = (IntergenSolution)selectionOperator.Execute(population); IntergenSolution[] offSpring = (IntergenSolution[])crossoverOperator.Execute(parents); mutationOperator.Execute(offSpring[0]); mutationOperator.Execute(offSpring[1]); parallelEvaluator.AddTaskForExecution(new object[] { offSpring[0], evaluations + i }); parallelEvaluator.AddTaskForExecution(new object[] { offSpring[1], evaluations + i }); } } List <IntergenSolution> solutions = (List <IntergenSolution>)parallelEvaluator.ParallelExecution(); foreach (IntergenSolution solution in solutions) { offspringPopulation.Add(solution); evaluations++; //solution.FoundAtEval = evaluations; } // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } // This piece of code shows how to use the indicator object into the code // of NSGA-II. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if ((indicators != null) && (requiredEvaluations == 0)) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } //TODO /* * Ranking rank2 = new Ranking(population); * * Result = rank2.GetSubfront(0); */ /*Ranking forGraphicOutput = new Ranking(population); * var currentBestResultSet = forGraphicOutput.GetSubfront(0); * * var firstBestResult = currentBestResultSet.Get(0); * * var myProblem = (IntergenProblem)Problem; * //myProblem.calculated; * * //var variantValuesWithoutInteraction = Matrix.Multiply(myProblem.calculated, firstBestResult.); * //var Model = myProblem.GetModel(); * int mycounter = 0; * if (mycounter % 500 == 0) * { * //RIntegrator.PlotValues(currentBestResultSet, myProblem); * } * mycounter++; * var progress = new UserProgress(); * progress.FeatureP = firstBestResult.Objective[0]; * if (!myProblem.Model.Setting.NoVariantCalculation) progress.VariantP = firstBestResult.Objective[1]; * myProblem.Worker.ReportProgress(evaluations * 100 / maxEvaluations, progress); ; * * //Model.CurrentBestImage = "CurrentBest.png"; */ front = ranking.GetSubfront(0); var minmax = new MinMaxFitness { FeatMax = double.MinValue, FeatMin = double.MaxValue, VarMax = double.MinValue, VarMin = double.MaxValue, InterMax = double.MinValue, InterMin = double.MaxValue }; var prob = (IntergenProblem)Problem; var list = ObjectiveMapping.GetList(prob.ProblemType); for (var i = 0; i < populationSize; i++) { var sol = population.Get(i); var objindex = 0; if (list[0]) { if (sol.Objective[objindex] < minmax.FeatMin) { minmax.FeatMin = sol.Objective[objindex]; } if (sol.Objective[objindex] > minmax.FeatMax) { minmax.FeatMax = sol.Objective[objindex]; } objindex++; } if (list[1]) { if (sol.Objective[objindex] < minmax.InterMin) { minmax.InterMin = sol.Objective[objindex]; } if (sol.Objective[objindex] > minmax.InterMax) { minmax.InterMax = sol.Objective[objindex]; } objindex++; } if (list[2]) { if (sol.Objective[objindex] < minmax.VarMin) { minmax.VarMin = sol.Objective[objindex]; } if (sol.Objective[objindex] > minmax.VarMax) { minmax.VarMax = sol.Objective[objindex]; } } } var sol0 = front.Best(new CrowdingDistanceComparator()); var done = FitnessTracker.AddFitn(minmax); SolutionPlotter.Plot(sol0); ProgressReporter.ReportSolution(evaluations, sol0, _worker); if (done) { Ranking rank3 = new Ranking(population); Result = rank3.GetSubfront(0); SetOutputParameter("evaluations", evaluations); return(this.Result); } } // Return as output parameter the required evaluations SetOutputParameter("evaluations", evaluations); // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(this.Result); }
/// <summary> /// Runs the NSGA-II algorithm. /// </summary> /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { int populationSize = -1; int maxEvaluations = -1; int evaluations; JMetalCSharp.QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the // indicators object (see below) SolutionSet population; SolutionSet offspringPopulation; SolutionSet union; Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; Distance distance = new Distance(); //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); parallelEvaluator.StartParallelRunner(Problem);; //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); parallelEvaluator.AddTaskForExecution(new object[] { newSolution });; } List <Solution> solutionList = (List <Solution>)parallelEvaluator.ParallelExecution(); foreach (Solution solution in solutionList) { population.Add(solution); evaluations++; } // Generations while (evaluations < maxEvaluations) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize); Solution[] parents = new Solution[2]; for (int i = 0; i < (populationSize / 2); i++) { if (evaluations < maxEvaluations) { //obtain parents parents[0] = (Solution)selectionOperator.Execute(population); parents[1] = (Solution)selectionOperator.Execute(population); Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents); mutationOperator.Execute(offSpring[0]); mutationOperator.Execute(offSpring[1]); parallelEvaluator.AddTaskForExecution(new object[] { offSpring[0] });; parallelEvaluator.AddTaskForExecution(new object[] { offSpring[1] });; } } List <Solution> solutions = (List <Solution>)parallelEvaluator.ParallelExecution(); foreach (Solution solution in solutions) { offspringPopulation.Add(solution); evaluations++; } // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } // This piece of code shows how to use the indicator object into the code // of NSGA-II. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if ((indicators != null) && (requiredEvaluations == 0)) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } } // Return as output parameter the required evaluations SetOutputParameter("evaluations", requiredEvaluations); // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(this.Result); }
/// <summary> /// Runs the NSGA-II algorithm. /// </summary> /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { // !!!! NEEDED PARAMETES !!! start //J* Parameters int populationSize = -1; // J* store population size int maxEvaluations = -1; // J* store number of max Evaluations int evaluations; // J* number of current evaluations // J* Objects needed to illustrate the use of quality indicators inside the algorithms QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the // indicators object (see below) // J* populations needed to implement NSGA-II SolutionSet population; //J* Current population SolutionSet offspringPopulation; //J* offspring population SolutionSet union; //J* population resultant from current and offpring population //J* Genetic Operators Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; //J* Used to evaluate crowding distance Distance distance = new Distance(); //J* !!!! NEEDED PARAMETES !!! end //J* !!! INITIALIZING PARAMETERS - start !!! //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); //J* required JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); //J* required JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); //J* optional //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; //J* !!! INITIALIZING PARAMETERS - end !!! //J* !!! Creating first population !!! JMetalRandom.SetRandom(comp.MyRand); comp.LogAddMessage("Random seed = " + comp.Seed); // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; population.Add(newSolution); } // Generations while (evaluations < maxEvaluations) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize); Solution[] parents = new Solution[2]; for (int i = 0; i < (populationSize / 2); i++) { if (evaluations < maxEvaluations) { //obtain parents parents[0] = (Solution)selectionOperator.Execute(population); parents[1] = (Solution)selectionOperator.Execute(population); Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents); mutationOperator.Execute(offSpring[0]); mutationOperator.Execute(offSpring[1]); Problem.Evaluate(offSpring[0]); Problem.EvaluateConstraints(offSpring[0]); Problem.Evaluate(offSpring[1]); Problem.EvaluateConstraints(offSpring[1]); offspringPopulation.Add(offSpring[0]); offspringPopulation.Add(offSpring[1]); evaluations += 2; } } // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } // This piece of code shows how to use the indicator object into the code // of NSGA-II. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if ((indicators != null) && (requiredEvaluations == 0)) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } } // Return as output parameter the required evaluations SetOutputParameter("evaluations", requiredEvaluations); comp.LogAddMessage("Evaluations = " + evaluations); // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(Result); }
/// <summary> /// Runs of the AbYSS algorithm. /// </summary> /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions /// as a result of the algorithm execution </returns> public override SolutionSet Execute() { // STEP 1. Initialize parameters InitParam(); // STEP 2. Build the initial solutionSet Solution solution; for (int i = 0; i < solutionSetSize; i++) { solution = DiversificationGeneration(); this.Problem.Evaluate(solution); this.Problem.EvaluateConstraints(solution); evaluations++; solution = (Solution)improvementOperator.Execute(solution); evaluations += improvementOperator.GetEvaluations(); solutionSet.Add(solution); } // STEP 3. Main loop int newSolutions = 0; while (evaluations < maxEvaluations) { ReferenceSetUpdate(true); newSolutions = SubSetGeneration(); while (newSolutions > 0) { // New solutions are created ReferenceSetUpdate(false); if (evaluations >= maxEvaluations) { Result = archive; return(archive); } newSolutions = SubSetGeneration(); } // while // RE-START if (evaluations < maxEvaluations) { solutionSet.Clear(); // Add refSet1 to SolutionSet for (int i = 0; i < refSet1.Size(); i++) { solution = refSet1.Get(i); solution.UnMarked(); solution = (Solution)improvementOperator.Execute(solution); evaluations += improvementOperator.GetEvaluations(); solutionSet.Add(solution); } // Remove refSet1 and refSet2 refSet1.Clear(); refSet2.Clear(); // Sort the archive and insert the best solutions distance.CrowdingDistanceAssignment(archive, this.Problem.NumberOfObjectives); archive.Sort(crowdingDistance); int insert = solutionSetSize / 2; if (insert > archive.Size()) { insert = archive.Size(); } if (insert > (solutionSetSize - solutionSet.Size())) { insert = solutionSetSize - solutionSet.Size(); } // Insert solutions for (int i = 0; i < insert; i++) { solution = new Solution(archive.Get(i)); solution.UnMarked(); solutionSet.Add(solution); } // Create the rest of solutions randomly while (solutionSet.Size() < solutionSetSize) { solution = DiversificationGeneration(); this.Problem.EvaluateConstraints(solution); this.Problem.Evaluate(solution); evaluations++; solution = (Solution)improvementOperator.Execute(solution); evaluations += improvementOperator.GetEvaluations(); solution.UnMarked(); solutionSet.Add(solution); } } } // STEP 4. Return the archive Result = archive; return(archive); }
/// <summary> /// Implements the referenceSetUpdate method. /// </summary> /// <param name="build">build if true, indicates that the reference has to be build for the /// first time; if false, indicates that the reference set has to be /// updated with new solutions</param> public void ReferenceSetUpdate(bool build) { if (build) { // Build a new reference set // STEP 1. Select the p best individuals of P, where p is refSet1Size. // Selection Criterium: Spea2Fitness Solution individual; (new Spea2Fitness(solutionSet)).FitnessAssign(); solutionSet.Sort(fitness); // STEP 2. Build the RefSet1 with these p individuals for (int i = 0; i < refSet1Size; i++) { individual = solutionSet.Get(0); solutionSet.Remove(0); individual.UnMarked(); refSet1.Add(individual); } // STEP 3. Compute Euclidean distances in SolutionSet to obtain q // individuals, where q is refSet2Size_ for (int i = 0; i < solutionSet.Size(); i++) { individual = solutionSet.Get(i); individual.DistanceToSolutionSet = distance.DistanceToSolutionSetInSolutionSpace(individual, refSet1); } int size = refSet2Size; if (solutionSet.Size() < refSet2Size) { size = solutionSet.Size(); } // STEP 4. Build the RefSet2 with these q individuals for (int i = 0; i < size; i++) { // Find the maximumMinimunDistanceToPopulation double maxMinimum = 0.0; int index = 0; for (int j = 0; j < solutionSet.Size(); j++) { if (solutionSet.Get(j).DistanceToSolutionSet > maxMinimum) { maxMinimum = solutionSet.Get(j).DistanceToSolutionSet; index = j; } } individual = solutionSet.Get(index); solutionSet.Remove(index); // Update distances to REFSET in population for (int j = 0; j < solutionSet.Size(); j++) { double aux = distance.DistanceBetweenSolutions(solutionSet.Get(j), individual); if (aux < individual.DistanceToSolutionSet) { solutionSet.Get(j).DistanceToSolutionSet = aux; } } // Insert the individual into REFSET2 refSet2.Add(individual); // Update distances in REFSET2 for (int j = 0; j < refSet2.Size(); j++) { for (int k = 0; k < refSet2.Size(); k++) { if (i != j) { double aux = distance.DistanceBetweenSolutions(refSet2.Get(j), refSet2.Get(k)); if (aux < refSet2.Get(j).DistanceToSolutionSet) { refSet2.Get(j).DistanceToSolutionSet = aux; } } } } } } else { // Update the reference set from the subset generation result Solution individual; for (int i = 0; i < subSet.Size(); i++) { individual = (Solution)improvementOperator.Execute(subSet.Get(i)); evaluations += improvementOperator.GetEvaluations(); if (RefSet1Test(individual)) { //Update distance of RefSet2 for (int indSet2 = 0; indSet2 < refSet2.Size(); indSet2++) { double aux = distance.DistanceBetweenSolutions(individual, refSet2.Get(indSet2)); if (aux < refSet2.Get(indSet2).DistanceToSolutionSet) { refSet2.Get(indSet2).DistanceToSolutionSet = aux; } } } else { RefSet2Test(individual); } } subSet.Clear(); } }
public override SolutionSet Execute() { double contrDE = 0; double contrSBX = 0; double contrPol = 0; double contrTotalDE = 0; double contrTotalSBX = 0; double contrTotalPol = 0; double[] contrReal = new double[3]; contrReal[0] = contrReal[1] = contrReal[2] = 0; IComparer <Solution> dominance = new DominanceComparator(); IComparer <Solution> crowdingComparator = new CrowdingComparator(); Distance distance = new Distance(); Operator selectionOperator; //Read parameter values JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); //Init the variables population = new SolutionSet(populationSize); evaluations = 0; selectionOperator = Operators["selection"]; Offspring[] getOffspring; int N_O; // number of offpring objects getOffspring = ((Offspring[])GetInputParameter("offspringsCreators")); N_O = getOffspring.Length; contribution = new double[N_O]; contributionCounter = new int[N_O]; contribution[0] = (double)(populationSize / (double)N_O) / (double)populationSize; for (int i = 1; i < N_O; i++) { contribution[i] = (double)(populationSize / (double)N_O) / (double)populationSize + (double)contribution[i - 1]; } for (int i = 0; i < N_O; i++) { Console.WriteLine(getOffspring[i].Configuration()); Console.WriteLine("Contribution: " + contribution[i]); } // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; newSolution.Location = i; population.Add(newSolution); } while (evaluations < maxEvaluations) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize); Solution[] parents = new Solution[2]; for (int i = 0; i < (populationSize / 1); i++) { if (evaluations < maxEvaluations) { Solution individual = new Solution(population.Get(JMetalRandom.Next(0, populationSize - 1))); int selected = 0; bool found = false; Solution offSpring = null; double rnd = JMetalRandom.NextDouble(); for (selected = 0; selected < N_O; selected++) { if (!found && (rnd <= contribution[selected])) { if ("DE" == getOffspring[selected].Id) { offSpring = getOffspring[selected].GetOffspring(population, i); contrDE++; } else if ("SBXCrossover" == getOffspring[selected].Id) { offSpring = getOffspring[selected].GetOffspring(population); contrSBX++; } else if ("PolynomialMutation" == getOffspring[selected].Id) { offSpring = ((PolynomialMutationOffspring)getOffspring[selected]).GetOffspring(individual); contrPol++; } else { Logger.Log.Error("Error in NSGAIIAdaptive. Operator " + offSpring + " does not exist"); Console.WriteLine("Error in NSGAIIAdaptive. Operator " + offSpring + " does not exist"); } offSpring.Fitness = (int)selected; found = true; } } Problem.Evaluate(offSpring); offspringPopulation.Add(offSpring); evaluations += 1; } } // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } // CONTRIBUTION CALCULATING PHASE // First: reset contribution counter for (int i = 0; i < N_O; i++) { contributionCounter[i] = 0; } // Second: determine the contribution of each operator for (int i = 0; i < population.Size(); i++) { if ((int)population.Get(i).Fitness != -1) { contributionCounter[(int)population.Get(i).Fitness] += 1; } population.Get(i).Fitness = -1; } contrTotalDE += contributionCounter[0]; contrTotalSBX += contributionCounter[1]; contrTotalPol += contributionCounter[2]; int minimumContribution = 2; int totalContributionCounter = 0; for (int i = 0; i < N_O; i++) { if (contributionCounter[i] < minimumContribution) { contributionCounter[i] = minimumContribution; } totalContributionCounter += contributionCounter[i]; } if (totalContributionCounter == 0) { for (int i = 0; i < N_O; i++) { contributionCounter[i] = 10; } } // Third: calculating contribution contribution[0] = contributionCounter[0] * 1.0 / (double)totalContributionCounter; for (int i = 1; i < N_O; i++) { contribution[i] = contribution[i - 1] + 1.0 * contributionCounter[i] / (double)totalContributionCounter; } } // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(Result); }
/** * Runs of the GDE3 algorithm. * @return a <code>SolutionSet</code> that is a set of non dominated solutions * as a result of the algorithm execution * @throws JMException */ public override SolutionSet Execute() { int populationSize = -1; int maxIterations = -1; int evaluations; int iterations; SolutionSet population; SolutionSet offspringPopulation; Distance distance; IComparer <Solution> dominance; Operator selectionOperator; Operator crossoverOperator; distance = new Distance(); dominance = new DominanceComparator(); Solution[] parent; //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxIterations", ref maxIterations); selectionOperator = this.Operators["selection"]; crossoverOperator = this.Operators["crossover"]; //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; iterations = 0; // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(this.Problem); this.Problem.Evaluate(newSolution); this.Problem.EvaluateConstraints(newSolution); evaluations++; population.Add(newSolution); } // Generations ... while (iterations < maxIterations) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize * 2); for (int i = 0; i < populationSize; i++) { // Obtain parents. Two parameters are required: the population and the // index of the current individual parent = (Solution[])selectionOperator.Execute(new object[] { population, i }); Solution child; // Crossover. Two parameters are required: the current individual and the // array of parents child = (Solution)crossoverOperator.Execute(new object[] { population.Get(i), parent }); this.Problem.Evaluate(child); this.Problem.EvaluateConstraints(child); evaluations++; // Dominance test int result; result = dominance.Compare(population.Get(i), child); if (result == -1) { // Solution i dominates child offspringPopulation.Add(population.Get(i)); } else if (result == 1) { // child dominates offspringPopulation.Add(child); } else { // the two solutions are non-dominated offspringPopulation.Add(child); offspringPopulation.Add(population.Get(i)); } } // Ranking the offspring population Ranking ranking = new Ranking(offspringPopulation); int remain = populationSize; 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, this.Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(k)); } // for //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 while (front.Size() > remain) { distance.CrowdingDistanceAssignment(front, this.Problem.NumberOfObjectives); front.Remove(front.IndexWorst(new CrowdingComparator())); } for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(k)); } remain = 0; } iterations++; } // Return the first non-dominated front Ranking rnk = new Ranking(population); this.Result = rnk.GetSubfront(0); return(this.Result); }
/// <summary> /// Runs the FastSMSEMOA algorithm. /// </summary> /// <returns> a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { int populationSize = -1; int maxEvaluations = -1; int evaluations; double offset = -1; QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the indicators object (see below) FastHypervolume fastHypervolume; SolutionSet population; SolutionSet offspringPopulation; SolutionSet union; Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); JMetalCSharp.Utils.Utils.GetDoubleValueFromParameter(this.InputParameters, "offset", ref offset); //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; requiredEvaluations = 0; fastHypervolume = new FastHypervolume(offset); //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; population.Add(newSolution); } // Generations ... while (evaluations < maxEvaluations) { // select parents offspringPopulation = new SolutionSet(populationSize); List <Solution> selectedParents = new List <Solution>(); Solution[] parents = new Solution[0]; while (selectedParents.Count < 2) { object selected = selectionOperator.Execute(population); try { Solution parent = (Solution)selected; selectedParents.Add(parent); } catch (InvalidCastException e) { parents = (Solution[])selected; selectedParents.AddRange(parents); } } parents = selectedParents.ToArray <Solution>(); // crossover Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents); // mutation mutationOperator.Execute(offSpring[0]); // evaluation Problem.Evaluate(offSpring[0]); Problem.EvaluateConstraints(offSpring[0]); // insert child into the offspring population offspringPopulation.Add(offSpring[0]); evaluations++; // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union (non-dominated sorting) Ranking ranking = new Ranking(union); // ensure crowding distance values are up to date // (may be important for parent selection) for (int j = 0; j < population.Size(); j++) { population.Get(j).CrowdingDistance = 0.0; } SolutionSet lastFront = ranking.GetSubfront(ranking.GetNumberOfSubfronts() - 1); fastHypervolume.ComputeHVContributions(lastFront); lastFront.Sort(new CrowdingDistanceComparator()); // all but the worst are carried over to the survivor population SolutionSet front = null; population.Clear(); for (int i = 0; i < ranking.GetNumberOfSubfronts() - 1; i++) { front = ranking.GetSubfront(i); for (int j = 0; j < front.Size(); j++) { population.Add(front.Get(j)); } } for (int i = 0; i < lastFront.Size() - 1; i++) { population.Add(lastFront.Get(i)); } // This piece of code shows how to use the indicator object into the code // of SMS-EMOA. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if (indicators != null && requiredEvaluations == 0) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } } // Return as output parameter the required evaluations SetOutputParameter("evaluations", requiredEvaluations); // Return the first non-dominated front Ranking rnk = new Ranking(population); Result = rnk.GetSubfront(0); return(Result); }
/// <summary> /// Runs the NSGA-II algorithm. /// </summary> /// <returns>a <code>SolutionSet</code> that is a set of non dominated solutions as a result of the algorithm execution</returns> public override SolutionSet Execute() { int populationSize = -1; int maxEvaluations = -1; int iterationsNumber = -1; int evaluations; int iteration; QualityIndicator.QualityIndicator indicators = null; // QualityIndicator object int requiredEvaluations; // Use in the example of use of the // indicators object (see below) SolutionSet population; SolutionSet offspringPopulation; SolutionSet union; Operator mutationOperator; Operator crossoverOperator; Operator selectionOperator; Distance distance = new Distance(); //Read the parameters JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "maxEvaluations", ref maxEvaluations); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "populationSize", ref populationSize); JMetalCSharp.Utils.Utils.GetIntValueFromParameter(this.InputParameters, "iterationsNumber", ref iterationsNumber); JMetalCSharp.Utils.Utils.GetIndicatorsFromParameters(this.InputParameters, "indicators", ref indicators); //Initialize the variables population = new SolutionSet(populationSize); evaluations = 0; iteration = 0; requiredEvaluations = 0; //Read the operators mutationOperator = Operators["mutation"]; crossoverOperator = Operators["crossover"]; selectionOperator = Operators["selection"]; Random random = new Random(); JMetalRandom.SetRandom(random); // Create the initial solutionSet Solution newSolution; for (int i = 0; i < populationSize; i++) { newSolution = new Solution(Problem); Problem.Evaluate(newSolution); Problem.EvaluateConstraints(newSolution); evaluations++; population.Add(newSolution); } /* * string dir = "Result/MOEAD_ACOR/ZDT4_Real/Record/NSGAII_SBX_nr16"; * if (Directory.Exists(dir)) * { * Console.WriteLine("The directory {0} already exists.", dir); * } * else * { * Directory.CreateDirectory(dir); * Console.WriteLine("The directory {0} was created.", dir); * }*/ // Generations while (iteration < iterationsNumber) { // Create the offSpring solutionSet offspringPopulation = new SolutionSet(populationSize); Solution[] parents = new Solution[2]; for (int i = 0; i < (populationSize / 2); i++) { if (iteration < iterationsNumber) { //obtain parents parents[0] = (Solution)selectionOperator.Execute(population); parents[1] = (Solution)selectionOperator.Execute(population); Solution[] offSpring = (Solution[])crossoverOperator.Execute(parents); mutationOperator.Execute(offSpring[0]); mutationOperator.Execute(offSpring[1]); Problem.Evaluate(offSpring[0]); Problem.EvaluateConstraints(offSpring[0]); Problem.Evaluate(offSpring[1]); Problem.EvaluateConstraints(offSpring[1]); offspringPopulation.Add(offSpring[0]); offspringPopulation.Add(offSpring[1]); evaluations += 2; } } // Create the solutionSet union of solutionSet and offSpring union = ((SolutionSet)population).Union(offspringPopulation); // Ranking the union Ranking ranking = new Ranking(union); int remain = populationSize; 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, Problem.NumberOfObjectives); //Add the individuals of this front for (int k = 0; k < front.Size(); k++) { population.Add(front.Get(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, Problem.NumberOfObjectives); front.Sort(new CrowdingComparator()); for (int k = 0; k < remain; k++) { population.Add(front.Get(k)); } remain = 0; } /* * string filevar = dir + "/VAR" + iteration; * string filefun = dir + "/FUN" + iteration; * population.PrintVariablesToFile(filevar); * population.PrintObjectivesToFile(filefun);*/ iteration++; // This piece of code shows how to use the indicator object into the code // of NSGA-II. In particular, it finds the number of evaluations required // by the algorithm to obtain a Pareto front with a hypervolume higher // than the hypervolume of the true Pareto front. if ((indicators != null) && (requiredEvaluations == 0)) { double HV = indicators.GetHypervolume(population); if (HV >= (0.98 * indicators.TrueParetoFrontHypervolume)) { requiredEvaluations = evaluations; } } } Logger.Log.Info("ITERATION: " + iteration); Console.WriteLine("ITERATION: " + iteration); // Return as output parameter the required evaluations SetOutputParameter("evaluations", requiredEvaluations); // Return the first non-dominated front Ranking rank = new Ranking(population); Result = rank.GetSubfront(0); return(Result); }