Changeset 13672 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/GenerationalDistance.cs
- Timestamp:
- 03/09/16 12:44:23 (8 years ago)
- 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 21 using System; 2 22 using System.Collections.Generic; 3 using HeuristicLab.Encodings.RealVectorEncoding;4 using HeuristicLab.Problems.MultiObjectiveTestFunctions.Comparators;5 23 6 24 namespace HeuristicLab.Problems.MultiObjectiveTestFunctions { … … 10 28 /// where d[i] is the minimal distance the ith point of the evaluated front has to any point in the optimal pareto front. 11 29 /// </summary> 12 public class GenerationalDistance : IMultiObjectiveDistance { 13 private double p; //dampening Factor 30 public class GenerationalDistance { 14 31 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) { 24 33 //TODO build a kd-tree, sort the array, do someting intelligent here 25 34 if (front == null || optimalFront == null) throw new ArgumentException("Fronts must not be null"); 26 35 double sum = 0; 27 36 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); 30 39 c++; 31 40 } 32 41 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; 34 43 } 35 44 36 45 37 46 38 47 }
Note: See TracChangeset
for help on using the changeset viewer.