Changeset 16171 for branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ
- Timestamp:
- 09/21/18 09:18:49 (6 years ago)
- Location:
- branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ.cs
r15583 r16171 42 42 43 43 protected override double[] GetReferencePoint(int objectives) { 44 double[]rp = new double[objectives];45 for ( inti = 0; i < objectives; i++) {44 var rp = new double[objectives]; 45 for (var i = 0; i < objectives; i++) { 46 46 rp[i] = 11; 47 47 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ1.cs
r15583 r16171 48 48 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 49 49 } 50 double[]res = new double[objectives];51 intk = r.Length - objectives + 1;50 var res = new double[objectives]; 51 var k = r.Length - objectives + 1; 52 52 double g = 0; 53 53 54 for ( inti = r.Length - k; i < r.Length; i++) {54 for (var i = r.Length - k; i < r.Length; i++) { 55 55 g += (r[i] - 0.5) * (r[i] - 0.5) - Math.Cos(20.0 * Math.PI * (r[i] - 0.5)); 56 56 }; … … 58 58 g *= 100; 59 59 60 for ( inti = 0; i < objectives; i++) {60 for (var i = 0; i < objectives; i++) { 61 61 res[i] = 0.5 * (1.0 + g); 62 for ( intj = 0; j < objectives - i - 1; ++j)62 for (var j = 0; j < objectives - i - 1; ++j) 63 63 res[i] *= (r[j]); 64 64 if (i > 0) -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ2.cs
r15583 r16171 48 48 } 49 49 50 double[]res = new double[objectives];50 var res = new double[objectives]; 51 51 52 52 //calculate g(Xm) 53 53 double g = 0; 54 for ( inti = objectives; i < r.Length; i++) {55 doubled = r[i] - 0.5;54 for (var i = objectives; i < r.Length; i++) { 55 var d = r[i] - 0.5; 56 56 g += d * d; 57 57 } 58 58 59 59 //calculating f0...fM-1 60 for ( inti = 0; i < objectives; i++) {61 doublef = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);62 for ( intj = 0; j < objectives - i - 1; j++) {60 for (var i = 0; i < objectives; i++) { 61 var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g); 62 for (var j = 0; j < objectives - i - 1; j++) { 63 63 f *= Math.Cos(r[j] * Math.PI / 2); 64 64 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ3.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double sum = 0; 53 intlength = r.Length - objectives + 1;54 for ( inti = r.Length - length; i < r.Length; i++) {55 doubled = r[i] - 0.5;53 var length = r.Length - objectives + 1; 54 for (var i = r.Length - length; i < r.Length; i++) { 55 var d = r[i] - 0.5; 56 56 sum += d * d - Math.Cos(20 * Math.PI * d); 57 57 } 58 doubleg = 100 * (length + sum);58 var g = 100 * (length + sum); 59 59 60 60 //calculating f0...fM-1 61 for ( inti = 0; i < objectives; i++) {62 doublef = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);63 for ( intj = 0; j < objectives - i - 1; j++) {61 for (var i = 0; i < objectives; i++) { 62 var f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g); 63 for (var j = 0; j < objectives - i - 1; j++) { 64 64 f *= Math.Cos(r[j] * Math.PI / 2); 65 65 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ4.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double g = 0; 53 for ( inti = objectives; i < r.Length; i++) {54 doubled = r[i] - 0.5;53 for (var i = objectives; i < r.Length; i++) { 54 var d = r[i] - 0.5; 55 55 g += d * d; 56 56 } 57 57 58 58 //calculating f0...fM-1 59 for ( inti = 0; i < objectives; i++) {60 doublef = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g);61 for ( intj = 0; j < objectives - i - 1; j++) {59 for (var i = 0; i < objectives; i++) { 60 var f = i == 0 ? 1 : (Math.Sin(Math.Pow(r[objectives - i - 1], 100) * Math.PI / 2)) * (1 + g); 61 for (var j = 0; j < objectives - i - 1; j++) { 62 62 f *= Math.Cos(Math.Pow(r[j], 100) * Math.PI / 2); 63 63 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ5.cs
r15583 r16171 42 42 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 43 43 } 44 double[]res = new double[objectives];44 var res = new double[objectives]; 45 45 46 46 //calculate g(Xm) 47 47 double g = 0; 48 for ( inti = objectives; i < r.Length; i++) {49 doubled = r[i] - 0.5;48 for (var i = objectives; i < r.Length; i++) { 49 var d = r[i] - 0.5; 50 50 g += d * d; 51 51 } … … 56 56 57 57 //calculating f0...fM-1 58 for ( inti = 0; i < objectives; i++) {59 doublef = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);60 for ( intj = 0; j < objectives - i - 1; j++) {58 for (var i = 0; i < objectives; i++) { 59 var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g); 60 for (var j = 0; j < objectives - i - 1; j++) { 61 61 f *= Math.Cos(phi(r[j]) * Math.PI / 2); 62 62 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ6.cs
r15583 r16171 42 42 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 43 43 } 44 double[]res = new double[objectives];44 var res = new double[objectives]; 45 45 46 46 //calculate g(Xm) 47 47 double g = 0; 48 for ( inti = objectives; i < r.Length; i++) {48 for (var i = objectives; i < r.Length; i++) { 49 49 g += Math.Pow(r[i], 0.1); 50 50 } … … 55 55 56 56 //calculating f0...fM-1 57 for ( inti = 0; i < objectives; i++) {58 doublef = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);59 for ( intj = 0; j < objectives - i - 1; j++) {57 for (var i = 0; i < objectives; i++) { 58 var f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g); 59 for (var j = 0; j < objectives - i - 1; j++) { 60 60 f *= Math.Cos(phi(r[j]) * Math.PI / 2); 61 61 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ7.cs
r15583 r16171 47 47 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives"); 48 48 } 49 double[]res = new double[objectives];49 var res = new double[objectives]; 50 50 51 51 //calculate g(Xm) 52 52 double g = 0, length = length = r.Length - objectives + 1; 53 for ( inti = objectives; i < r.Length; i++) {53 for (var i = objectives; i < r.Length; i++) { 54 54 g += r[i]; 55 55 } … … 58 58 59 59 //calculating f0...fM-2 60 for ( inti = 0; i < objectives - 1; i++) {60 for (var i = 0; i < objectives - 1; i++) { 61 61 res[i] = r[i]; 62 62 } 63 63 //calculate fM-1 64 64 double h = objectives; 65 for ( inti = 0; i < objectives - 1; i++) {65 for (var i = 0; i < objectives - 1; i++) { 66 66 h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i])); 67 67 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ8.cs
r15583 r16171 30 30 public class DTLZ8 : DTLZ, IConstrainedTestFunction { 31 31 public static double[] IllegalValue(int size, bool[] maximization) { 32 double[]res = new double[size];33 for ( inti = 0; i < size; i++) {32 var res = new double[size]; 33 for (var i = 0; i < size; i++) { 34 34 res[i] = maximization[i] ? Double.MinValue : Double.MaxValue; 35 35 } … … 49 49 double n = r.Length; 50 50 double M = objectives; 51 doubleratio = n / M;52 double[]res = new double[objectives];53 for ( intj = 0; j < objectives; j++) {51 var ratio = n / M; 52 var res = new double[objectives]; 53 for (var j = 0; j < objectives; j++) { 54 54 double sum = 0; 55 for ( inti = (int)(j * ratio); i < (j + 1) + ratio; i++) {55 for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 56 56 sum += r[i]; 57 57 } … … 59 59 res[j] = sum; 60 60 } 61 for ( intj = 0; j < M - 1; j++) {61 for (var j = 0; j < M - 1; j++) { 62 62 if (res[objectives - 1] + 4 * res[j] - 1 < 0) return IllegalValue(objectives, GetMaximization(objectives)); 63 63 } 64 doublemin = Double.PositiveInfinity;65 for ( inti = 0; i < res.Length - 1; i++) {66 for ( intj = 0; j < i; j++) {67 doubled = res[i] + res[j];64 var min = Double.PositiveInfinity; 65 for (var i = 0; i < res.Length - 1; i++) { 66 for (var j = 0; j < i; j++) { 67 var d = res[i] + res[j]; 68 68 if (min < d) min = d; 69 69 } … … 78 78 double n = r.Length; 79 79 double M = objectives; 80 doubleratio = n / M;81 double[]res = new double[objectives];82 double[]constraints = new double[objectives];83 for ( intj = 0; j < objectives; j++) {80 var ratio = n / M; 81 var res = new double[objectives]; 82 var constraints = new double[objectives]; 83 for (var j = 0; j < objectives; j++) { 84 84 double sum = 0; 85 for ( inti = (int)(j * ratio); i < (j + 1) + ratio; i++) {85 for (var i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 86 86 sum += r[i]; 87 87 } … … 89 89 res[j] = sum; 90 90 } 91 for ( intj = 0; j < M - 1; j++) {92 doubled1 = res[objectives - 1] + 4 * res[j] - 1;91 for (var j = 0; j < M - 1; j++) { 92 var d1 = res[objectives - 1] + 4 * res[j] - 1; 93 93 constraints[j] = d1 < 0 ? -d1 : 0; 94 94 } 95 doublemin = Double.PositiveInfinity;96 for ( inti = 0; i < res.Length - 1; i++) {97 for ( intj = 0; j < i; j++) {98 doubled2 = res[i] + res[j];95 var min = Double.PositiveInfinity; 96 for (var i = 0; i < res.Length - 1; i++) { 97 for (var j = 0; j < i; j++) { 98 var d2 = res[i] + res[j]; 99 99 if (min < d2) min = d2; 100 100 } 101 101 } 102 doubled = 2 * res[objectives - 1] + min - 1;102 var d = 2 * res[objectives - 1] + min - 1; 103 103 constraints[constraints.Length - 1] = d < 0 ? -d : 0; 104 104 return constraints;
Note: See TracChangeset
for help on using the changeset viewer.