Changeset 16171 for branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs
- Timestamp:
- 09/21/18 09:18:49 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs
r15583 r16171 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 27 using HeuristicLab.Optimization; 26 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 29 … … 43 45 44 46 protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) { 45 List<double[]>res = new List<double[]>();46 for ( inti = 0; i <= 500; i++) {47 RealVector r = new RealVector(2);47 var res = new List<double[]>(); 48 for (var i = 0; i <= 500; i++) { 49 var r = new RealVector(2); 48 50 r[0] = 2 / 500.0 * i; 49 51 r[1] = 2 / 500.0 * i; … … 54 56 55 57 protected override double GetBestKnownHypervolume(int objectives) { 56 return Hypervolume .Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));58 return HypervolumeCalculator.CalculateHypervolume(GetOptimalParetoFront(objectives).ToArray(), GetReferencePoint(objectives), GetMaximization(objectives)); 57 59 } 58 60 … … 68 70 public override double[] Evaluate(RealVector r, int objectives) { 69 71 if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives"); 70 doublex = r[0];72 var x = r[0]; 71 73 double a = 1000; 72 doublesum = x * x;73 for ( inti = 1; i < r.Length - 1; i++) {74 var sum = x * x; 75 for (var i = 1; i < r.Length - 1; i++) { 74 76 sum += a * r[i] * r[i]; 75 77 } … … 77 79 78 80 //objective1 79 doublef0 = 1 / (a * a * r.Length) * sum;81 var f0 = 1 / (a * a * r.Length) * sum; 80 82 81 83 x = x - 2; 82 84 sum = x * x; 83 for ( inti = 1; i < r.Length - 1; i++) {85 for (var i = 1; i < r.Length - 1; i++) { 84 86 sum += a * (r[i] - 2) * (r[i] - 2); 85 87 } … … 87 89 sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2); 88 90 //objective0 89 doublef1 = 1 / (a * a * r.Length) * sum;91 var f1 = 1 / (a * a * r.Length) * sum; 90 92 91 93 return new double[] { f0, f1 };
Note: See TracChangeset
for help on using the changeset viewer.