Changeset 13672 for branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/Spacing.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/Spacing.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 23 using HeuristicLab.Common; 4 using HeuristicLab.Encodings.RealVectorEncoding;5 using HeuristicLab.Problems.MultiObjectiveTestFunctions.Comparators;6 24 7 25 namespace HeuristicLab.Problems.MultiObjectiveTestFunctions { 8 9 26 10 27 /// <summary> … … 13 30 /// to all OTHER points in the same front 14 31 /// </summary> 15 public class Spacing : IMultiObjectiveDistance{32 public class Spacing { 16 33 17 public Spacing() { } 18 19 20 public static double GetSpacing(IEnumerable<double[]> front) { 21 return new Spacing().Get(front); 22 } 23 public static double GetDistance(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront) { 24 return new Spacing().Get(front); 25 } 26 27 public double Compare(IEnumerable<double[]> front, IEnumerable<double[]> optimalFront) { 28 return GetSpacing(front) - GetSpacing(optimalFront); 29 } 30 31 public double Get(IEnumerable<double[]> front) { 32 //TODO build a kd-tree, sort the array, do someting intelligent here 34 public static double Calculate(IEnumerable<double[]> front) { 33 35 if (front == null) throw new ArgumentException("Fronts must not be null"); 34 36 List<double> d = new List<double>(); 35 37 foreach (double[] r in front) { 36 38 double dist = Utilities.minDistance(r, front, false); 37 d.Add(dist >=0?dist:0);39 d.Add(dist >= 0 ? dist : 0); 38 40 } 39 41 int n = d.Count; 40 42 if (n == 0) throw new ArgumentException("Fronts must not be empty"); 41 return Math.Sqrt(d.Variance() *(n-1)/n);43 return Math.Sqrt(d.Variance() * (n - 1) / n); 42 44 43 45 }
Note: See TracChangeset
for help on using the changeset viewer.