Changeset 17440 for branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA
- Timestamp:
- 02/17/20 16:30:40 (5 years ago)
- Location:
- branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4/SMSEMOAAlgorithm.cs
r17425 r17440 103 103 var analyzer = Analyzer; 104 104 var rand = RandomParameter.Value; 105 int lambda = 1; // the size of offspring 105 //int lambda = 1; // the size of offspring 106 var lambda = Lambda.Value; 106 107 //int indexOffspring = 0; // the index of offspring to be generated 107 108 -
branches/3055_SMSEMOA/HeuristicLab.Algorithms.SMSEMOA/3.4/SMSEMOAlgorithmBase.cs
r17425 r17440 101 101 private DoubleArray ReferencePoint { 102 102 get { 103 var problem = (MultiObjectiveTestFunctionProblem)Problem; 104 return problem.ReferencePoint; 103 if (Problem is MultiObjectiveTestFunctionProblem) { 104 var problem = (MultiObjectiveTestFunctionProblem)Problem; 105 return problem.ReferencePoint; 106 } 107 else { 108 return null; 109 } 105 110 } 106 111 } … … 250 255 251 256 #region constructors 252 public SMSEMOAAlgorithmBase() { 257 public SMSEMOAAlgorithmBase() { 253 258 // Add or define or specify the parameters that may be use in SMS-EMOA. 254 259 // ***("Name", "Description", "Value") … … 480 485 var lastLayer = pf2.Last(); 481 486 482 try { // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020 483 // smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization); 484 smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), ReferencePoint.ToArray(), maximization); 485 } 486 catch { 487 smetric = int.MinValue; 488 } 489 490 var indices = Enumerable.Range(0, lastLayer.Count()).ToList(); 491 492 for (int ii = 0; ii < lastLayer.Count(); ++ii) { 487 // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020 488 // smetric = Hypervolume.Calculate(lastLayer.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization); 489 490 491 var reference = Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray(); 492 if (ReferencePoint is null) { // KF, 20200217 -- fix no reference point on real-world applications. If No reference points in Algorithms, use 1.1 \times max objective values as the reference point 493 for (int i = 0; i < reference.Length; i++) { 494 reference[i] = 1.1 * reference[i]; 495 if (reference[i] > 10000) { 496 reference[i] = 9999; // set a upper bound for the reference point 497 } 498 } 499 } 500 else { 501 reference = ReferencePoint.ToArray(); 502 } 503 //var reference = ReferencePoint.ToArray(); 504 var nondominated = NonDominatedSelect.GetDominatingVectors(lastLayer.Select(x => x.Item2), reference, maximization, false); 505 smetric = nondominated.Any() ? Hypervolume.Calculate(nondominated, reference, maximization) : int.MinValue; 506 507 for (int ii = 0; ii < lastLayer.Count; ++ii) { 493 508 try { // TODO: This can be use for dynamic reference point strategy later. Kaifeng , 02/2020 494 509 // tempHV = Hypervolume.Calculate(indices.Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization); 495 tempHV = Hypervolume.Calculate( indices.Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), ReferencePoint.ToArray(), maximization);510 tempHV = Hypervolume.Calculate(Enumerable.Range(0, lastLayer.Count).Where(idx => idx != ii).Select(idx => lastLayer[idx].Item2), reference, maximization); 496 511 } 497 512 catch { … … 537 552 // True: maximization problem 538 553 // False: minimization problem 539 hypervolumes[0, 0] = Hypervolume.Calculate(pf.Select(x => x.Item2), Enumerable.Repeat(11d, NadirPoint.Length).ToArray(), maximization); 554 var reference = Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray(); 555 if (ReferencePoint is null) { // KF, 20200217 -- fix no reference point on real-world applications. If No reference points in Algorithms, use 1.1 \times max objective values as the reference point 556 for (int i = 0; i < reference.Length; i++) { 557 reference[i] = 1.1 * reference[i]; 558 if (reference[i] > 10000) { 559 reference[i] = 9999; // set a upper bound for the reference point 560 } 561 } 562 } 563 else { 564 reference = ReferencePoint.ToArray(); 565 } 566 //var reference = ReferencePoint.ToArray() ?? Enumerable.Repeat(double.MaxValue, maximization.Length).ToArray(); 567 //var reference = ReferencePoint.ToArray(); 568 var nondominated = NonDominatedSelect.GetDominatingVectors(pf.Select(x => x.Item2), reference, maximization, false); 569 hypervolumes[0, 0] = nondominated.Any() ? Hypervolume.Calculate(nondominated, reference, maximization) : int.MinValue; 570 571 //hypervolumes[0, 0] = Hypervolume.Calculate(pf.Select(x => x.Item2), reference, maximization); 540 572 hypervolumes[0, 1] = pf.Count; 541 573 Console.WriteLine("Current HV is", hypervolumes[0, 0]);
Note: See TracChangeset
for help on using the changeset viewer.