Changeset 17662
 Timestamp:
 07/09/20 16:11:31 (4 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/2825NSGA3/HeuristicLab.Algorithms.NSGA3/3.3/NSGA3.cs
r17661 r17662 43 43 } 44 44 45 public int NumberOfObjectives => Problem.Maximization.Length; 46 45 47 #endregion ProblemProperties 46 48 … … 236 238 } 237 239 238 private void InitReferencePoints()239 {240 // Generate reference points and add them to results241 ReferencePoints = ReferencePoint.GenerateReferencePoints(random, Problem.Maximization.Length);242 ResultsGeneratedReferencePoints = Utility.ConvertToDoubleMatrix(ReferencePoints);243 }244 245 240 private void InitResults() 246 241 { 247 242 Results.Add(new Result(GeneratedReferencePointsResultName, "The initially generated reference points", new DoubleMatrix())); 248 243 Results.Add(new Result(CurrentFrontResultName, "The Pareto Front", new DoubleMatrix())); 244 } 245 246 private void InitReferencePoints() 247 { 248 // Generate reference points and add them to results 249 ReferencePoints = ReferencePoint.GenerateReferencePoints(random, NumberOfObjectives); 250 ResultsGeneratedReferencePoints = Utility.ConvertToDoubleMatrix(ReferencePoints); 249 251 } 250 252 … … 343 345 { 344 346 // Find the ideal point 345 double[] idealPoint = new double[ Problem.Encoding.Length];346 for (int j = 0; j < Problem.Encoding.Length; j++)347 double[] idealPoint = new double[NumberOfObjectives]; 348 for (int j = 0; j < NumberOfObjectives; j++) 347 349 { 348 350 // Compute ideal point … … 355 357 356 358 // Find the extreme points 357 Solution[] extremePoints = new Solution[ Problem.Encoding.Length];358 for (int j = 0; j < Problem.Encoding.Length; j++)359 Solution[] extremePoints = new Solution[NumberOfObjectives]; 360 for (int j = 0; j < NumberOfObjectives; j++) 359 361 { 360 362 // Compute extreme points 361 double[] weights = new double[ Problem.Encoding.Length];362 for (int i = 0; i < Problem.Encoding.Length; i++) weights[i] = EPSILON;363 double[] weights = new double[NumberOfObjectives]; 364 for (int i = 0; i < NumberOfObjectives; i++) weights[i] = EPSILON; 363 365 weights[j] = 1; 364 366 double func(Solution s) => ASF(s.Fitness, weights); … … 379 381 foreach (var solution in Fronts[f]) 380 382 { 381 for (int i = 0; i < Problem.Encoding.Length; i++)383 for (int i = 0; i < NumberOfObjectives; i++) 382 384 { 383 385 if (Math.Abs(intercepts[i]  idealPoint[i]) > EPSILON) … … 498 500 { 499 501 List<int> dimensions = new List<int>(); 500 for (int i = 0; i < Problem.Encoding.Length; i++) dimensions.Add(i);502 for (int i = 0; i < NumberOfObjectives; i++) dimensions.Add(i); 501 503 double f(int dim) => x[dim] / weight[dim]; 502 504 return Utility.Max(f, dimensions); … … 521 523 if (duplicate) 522 524 { // cannot construct the unique hyperplane (this is a casual method to deal with the condition) 523 for (int f = 0; f < Problem.Encoding.Length; f++)525 for (int f = 0; f < NumberOfObjectives; f++) 524 526 { 525 527 // extreme_points[f] stands for the individual with the largest value of … … 532 534 // Find the equation of the hyperplane 533 535 List<double> b = new List<double>(); //(pop[0].objs().size(), 1.0); 534 for (int i = 0; i < Problem.Encoding.Length; i++)536 for (int i = 0; i < NumberOfObjectives; i++) 535 537 { 536 538 b.Add(1.0); … … 541 543 { 542 544 List<double> aux = new List<double>(); 543 for (int i = 0; i < Problem.Encoding.Length; i++)545 for (int i = 0; i < NumberOfObjectives; i++) 544 546 aux.Add(s.Fitness[i]); 545 547 a.Add(aux); … … 548 550 549 551 // Find intercepts 550 for (int f = 0; f < Problem.Encoding.Length; f++)552 for (int f = 0; f < NumberOfObjectives; f++) 551 553 { 552 554 intercepts.Add(1.0 / x[f]);
Note: See TracChangeset
for help on using the changeset viewer.