Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/09/16 12:44:23 (8 years ago)
Author:
bwerth
Message:

#1087 added Analyzers, reworked PFStore, added licence information, cleaned code

Location:
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/GenerationalDistance.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
     21using System;
    222using System.Collections.Generic;
    3 using HeuristicLab.Encodings.RealVectorEncoding;
    4 using HeuristicLab.Problems.MultiObjectiveTestFunctions.Comparators;
    523
    624namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
     
    1028  ///  where d[i] is the minimal distance the ith point of the evaluated front has to any point in the optimal pareto front.   
    1129  /// </summary>
    12   public class GenerationalDistance : IMultiObjectiveDistance {
    13     private double p; //dampening Factor
     30  public class GenerationalDistance {
    1431
    15     public GenerationalDistance(double p) {
    16       this.p = 1 / p;
    17     }
    18 
    19     public static double GetDistance(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront, double p) {
    20      return new GenerationalDistance(p).Compare(front,optimalFront);
    21     }
    22 
    23     public double Compare(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront) {
     32    public static double Calculate(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront, double p) {
    2433      //TODO build a kd-tree, sort the array, do someting intelligent here
    2534      if (front == null || optimalFront == null) throw new ArgumentException("Fronts must not be null");
    2635      double sum = 0;
    2736      int c = 0;
    28      foreach(double[] r in front) {
    29         sum += Utilities.minDistance(r, optimalFront,true);
     37      foreach (double[] r in front) {
     38        sum += Utilities.minDistance(r, optimalFront, true);
    3039        c++;
    3140      }
    3241      if (c == 0) throw new ArgumentException("Fronts must not be empty");
    33       return Math.Pow(sum, p) /c;
     42      return Math.Pow(sum, 1 / p) / c;
    3443    }
    3544
    36    
     45
    3746
    3847  }
Note: See TracChangeset for help on using the changeset viewer.