Changeset 13672 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ8.cs
- Timestamp:
- 03/09/16 12:44:23 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ8.cs
r13620 r13672 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 using System; 2 22 using HeuristicLab.Common; 3 23 using HeuristicLab.Core; … … 19 39 public DTLZ8() : base() { } 20 40 21 public 41 public double[] Evaluate2(RealVector r, int objectives) { 22 42 if (r.Length < objectives) { 23 43 throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the dimensionality of the solution(SolutionSize) "); … … 36 56 if (c != 0) { 37 57 d *= 1.0 / c; 38 } 58 } 39 59 res[i - 1] = d; 40 60 } … … 56 76 57 77 public override double[] Evaluate(RealVector r, int objectives) { 58 if (r.Length < 10 *objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the dimensionality of the solution(SolutionSize)");78 if (r.Length < 10 * objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than ten times the number of objectives "); 59 79 double n = r.Length; 60 80 double M = objectives; 61 81 double ratio = n / M; 62 82 double[] res = new double[objectives]; 63 for (int j =0; j < objectives; j++) {83 for (int j = 0; j < objectives; j++) { 64 84 double sum = 0; 65 for (int i = (int) (j*ratio); i < (j+1)+ratio; i++) {66 sum +=r[i];85 for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 86 sum += r[i]; 67 87 } 68 sum /= (int) 88 sum /= (int)ratio; 69 89 res[j] = sum; 70 90 } 71 for (int j = 0; j < M - 1; j++) {72 if (res[objectives - 1]+4*res[j]-1<0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));91 for (int j = 0; j < M - 1; j++) { 92 if (res[objectives - 1] + 4 * res[j] - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives)); 73 93 } 74 94 double min = Double.PositiveInfinity; 75 for (int i =0; i < res.Length - 1; i++) {76 for (int j = 0;j< i; j++) {95 for (int i = 0; i < res.Length - 1; i++) { 96 for (int j = 0; j < i; j++) { 77 97 double d = res[i] + res[j]; 78 98 if (min < d) min = d; … … 80 100 } 81 101 82 if (2 *res[objectives-1]+min-1<0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));102 if (2 * res[objectives - 1] + min - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives)); 83 103 return res; 84 104 }
Note: See TracChangeset
for help on using the changeset viewer.