Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/16 15:30:46 (8 years ago)
Author:
bwerth
Message:

#1087 several fixes according to the reviev comments in comment 31

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/GenerationalDistance.cs

    r14018 r14030  
    2626
    2727  /// <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
    2929  ///  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
    3032  /// </summary>
    3133  public static class GenerationalDistance {
    3234
    3335    public static double Calculate(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront, double p) {
    34       //TODO build a kd-tree, sort the array, do something intelligent here
    3536      if (front == null || optimalFront == null) throw new ArgumentNullException("Fronts must not be null.");
    3637      if (!front.Any()) throw new ArgumentException("Front must not be empty.");
    3738      if (p == 0.0) throw new ArgumentException("p must not be 0.0.");
    3839
    39       double sum = 0;
    40       int c = 0;
    41       foreach (double[] r in front) {
    42         sum += Utilities.MinimumDistance(r, optimalFront);
    43         c++;
    44       }
    4540
    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();
    4743    }
    4844
Note: See TracChangeset for help on using the changeset viewer.