Changeset 13776
- Timestamp:
- 04/20/16 10:29:06 (8 years ago)
- Location:
- branches/HeuristicLab.Problems.MultiObjectiveTestFunctions
- Files:
-
- 2 added
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/HyperVolume.cs
r13725 r13776 57 57 double[][] set = front.ToArray(); //Still no Good 58 58 if (set.Length == 0) throw new ArgumentException("Fronts must not be empty"); 59 if (refp.Length != set.Length) throw new ArgumentException("Front and referencepoint need to be of the same dimensionality"); 59 60 Array.Sort<double[]>(set, Utilities.getDimensionComparer(0, maximization[0])); 60 61 double[] last = set[set.Length - 1]; -
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/HeuristicLab.Problems.MultiObjectiveTestFunctions-3.3.csproj
r13771 r13776 154 154 <Compile Include="Data\DTLZInstanceProvider.cs" /> 155 155 <Compile Include="Interfaces\IMOFrontModel.cs" /> 156 <Compile Include="Testfunctions\CF1.cs" /> 156 157 <Compile Include="Views\MOSolution.cs" /> 157 158 <Compile Include="Views\MOFrontScatterPlotView.cs"> … … 204 205 <EmbeddedResource Include="EmbeddedRessources\ZDT4.pf" /> 205 206 <EmbeddedResource Include="EmbeddedRessources\ZDT6.pf" /> 207 <EmbeddedResource Include="EmbeddedRessources\CF1.pf" /> 206 208 <None Include="HeuristicLab.snk" /> 207 209 <None Include="Plugin.cs.frame" /> -
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Interfaces/IConstrainedTestFunction.cs
r13773 r13776 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using HeuristicLab.Core; 24 23 using HeuristicLab.Encodings.RealVectorEncoding; … … 28 27 /// An interface which represents an evaluation operator for multi objective test functions. 29 28 /// </summary> 30 public interface IMultiObjectiveTestFunction : INamedItem { 31 bool[] Maximization(int objectives); 32 double[,] Bounds(int objectives); 33 IEnumerable<double[]> OptimalParetoFront(int objectives); 34 double[] ReferencePoint(int objectives); 35 double BestKnownHypervolume(int objectives); 29 public interface IConstrainedTestFunction : INamedItem { 36 30 37 int MinimumSolutionLength { get; } 38 int MaximumSolutionLength { get; } 39 int MinimumObjectives { get; } 40 int MaximumObjectives { get; } 41 42 double[] Evaluate(RealVector point, int objectives); 31 /// <summary> 32 /// checks whether a given solution violates the contraints of this function 33 /// </summary> 34 /// <param name="point"></param> 35 /// <param name="objectives"></param> 36 /// <returns>a double array that holds the distances that describe how much every contraint is violated (0 is not violated) </returns> 37 double[] CheckConstraints(RealVector point, int objectives); 43 38 } 44 39 } -
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/MultiObjectiveTestFunctionProblem.cs
r13771 r13776 167 167 } 168 168 169 170 /// <summary> 171 /// Checks whether a given solution violates the contraints of this function. 172 /// </summary> 173 /// <param name="individual"></param> 174 /// <returns>a double array that holds the distances that describe how much every contraint is violated (0 is not violated). If the current TestFunction does not have constraints an array of length 0 is returned</returns> 175 public double[] checkContraints(RealVector individual) { 176 if (TestFunction is IConstrainedTestFunction) { 177 return ((IConstrainedTestFunction)TestFunction).CheckConstraints(individual, Objectives); 178 } 179 return new double[0]; 180 } 181 169 182 public double[] Evaluate(RealVector individual, IRandom random) { 170 183 return TestFunction.Evaluate(individual, Objectives); -
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ8.cs
r13725 r13776 26 26 27 27 namespace HeuristicLab.Problems.MultiObjectiveTestFunctions { 28 [Item("DTLZ8", "Testfunction as defined as DTLZ7 in http://repository.ias.ac.in/81671/ [30.11.15] ")]28 [Item("DTLZ8", "Testfunction as defined as DTLZ7 in http://repository.ias.ac.in/81671/ [30.11.15]. There has been a renumbering therefore the numbers do not match")] 29 29 [StorableClass] 30 public class DTLZ8 : DTLZ {30 public class DTLZ8 : DTLZ, IConstrainedTestFunction { 31 31 32 32 … … 38 38 } 39 39 public DTLZ8() : base() { } 40 41 public double[] Evaluate2(RealVector r, int objectives) {42 if (r.Length < objectives) {43 throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the number of objectives ");44 }45 double[] res = new double[objectives];46 47 //calculate f0...fM-1;48 double n = 10 * objectives;49 for (int i = 1; i <= objectives; i++) {50 double d = 0;51 int c = 0;52 for (int j = (int)Math.Floor((i - 1) * n / objectives); j < Math.Min((int)Math.Floor(i * n / objectives), r.Length); j++) {53 d += r[j];54 c++;55 }56 if (c != 0) {57 d *= 1.0 / c;58 }59 res[i - 1] = d;60 }61 62 //evaluate constraints g0...gM-263 for (int i = 0; i < objectives - 1; i++) {64 if (res[objectives - 1] + 4 * res[i] - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));65 }66 //evaluate gM-167 double min = Double.PositiveInfinity;68 for (int i = 0; i < objectives - 1; i++) {69 for (int j = 0; j < i; j++) min = Math.Min(min, res[i] + res[j]);70 };71 if (2 * res[objectives - 1] + min - 1 < 0) return MultiObjectiveTestFunction.IllegalValue(objectives, Maximization(objectives));72 73 return res;74 }75 76 40 77 41 public override double[] Evaluate(RealVector r, int objectives) { … … 104 68 } 105 69 106 70 double[] IConstrainedTestFunction.CheckConstraints(RealVector r, int objectives) { 71 if (r.Length < 10 * objectives) throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than ten times the number of objectives "); 72 double n = r.Length; 73 double M = objectives; 74 double ratio = n / M; 75 double[] res = new double[objectives]; 76 double[] constraints = new double[objectives]; 77 for (int j = 0; j < objectives; j++) { 78 double sum = 0; 79 for (int i = (int)(j * ratio); i < (j + 1) + ratio; i++) { 80 sum += r[i]; 81 } 82 sum /= (int)ratio; 83 res[j] = sum; 84 } 85 for (int j = 0; j < M - 1; j++) { 86 double d1 = res[objectives - 1] + 4 * res[j] - 1; 87 constraints[j] = d1 < 0 ? -d1 : 0; 88 } 89 double min = Double.PositiveInfinity; 90 for (int i = 0; i < res.Length - 1; i++) { 91 for (int j = 0; j < i; j++) { 92 double d2 = res[i] + res[j]; 93 if (min < d2) min = d2; 94 } 95 } 96 double d = 2 * res[objectives - 1] + min - 1; 97 constraints[constraints.Length - 1] = d < 0 ? -d : 0; 98 return constraints; 99 } 107 100 } 108 101 }
Note: See TracChangeset
for help on using the changeset viewer.