Changeset 14030 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/GenerationalDistance.cs
- Timestamp:
- 07/08/16 15:30:46 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/GenerationalDistance.cs
r14018 r14030 26 26 27 27 /// <summary> 28 /// The generational Distance is defined as the mean of a all d[i]^(1/p),28 /// The generational Distance is defined as the pth-root of the sum of all d[i]^(p) divided by the size of the front 29 29 /// where d[i] is the minimal distance the ith point of the evaluated front has to any point in the optimal pareto front. 30 /// p is a dampening factor and is normally set to 1. 31 /// http://shodhganga.inflibnet.ac.in/bitstream/10603/15070/28/28_appendix_h.pdf 30 32 /// </summary> 31 33 public static class GenerationalDistance { 32 34 33 35 public static double Calculate(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront, double p) { 34 //TODO build a kd-tree, sort the array, do something intelligent here35 36 if (front == null || optimalFront == null) throw new ArgumentNullException("Fronts must not be null."); 36 37 if (!front.Any()) throw new ArgumentException("Front must not be empty."); 37 38 if (p == 0.0) throw new ArgumentException("p must not be 0.0."); 38 39 39 double sum = 0;40 int c = 0;41 foreach (double[] r in front) {42 sum += Utilities.MinimumDistance(r, optimalFront);43 c++;44 }45 40 46 return Math.Pow(sum, 1 / p) / c; 41 double sum = front.Select(r => Math.Pow(Utilities.MinimumDistance(r, optimalFront), p)).Sum(); 42 return Math.Pow(sum, 1 / p) / front.Count(); 47 43 } 48 44
Note: See TracChangeset
for help on using the changeset viewer.