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/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
     21using System;
    222using System.Collections.Generic;
    323using HeuristicLab.Common;
    4 using HeuristicLab.Encodings.RealVectorEncoding;
    5 using HeuristicLab.Problems.MultiObjectiveTestFunctions.Comparators;
    624
    725namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    8 
    926
    1027  /// <summary>
     
    1330  /// to all OTHER points in the same front
    1431  /// </summary>
    15   public class Spacing : IMultiObjectiveDistance {
     32  public class Spacing {
    1633
    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) {
    3335      if (front == null) throw new ArgumentException("Fronts must not be null");
    3436      List<double> d = new List<double>();
    3537      foreach (double[] r in front) {
    3638        double dist = Utilities.minDistance(r, front, false);
    37         d.Add(dist>=0?dist:0);
     39        d.Add(dist >= 0 ? dist : 0);
    3840      }
    3941      int n = d.Count;
    4042      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);
    4244
    4345    }
Note: See TracChangeset for help on using the changeset viewer.