Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13725


Ignore:
Timestamp:
03/24/16 12:30:32 (9 years ago)
Author:
bwerth
Message:

#1087 minor bugfixes, added Parameters to Analyzers, convenience Tooltips for ScatterPlot

Location:
branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3
Files:
7 deleted
21 edited
4 copied
2 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/CrowdingAnalyzer.cs

    r13672 r13725  
    2020#endregion
    2121using HeuristicLab.Common;
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Optimization;
     25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2426
    2527namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    26   class CrowdingAnalyzer : MOTFAnalyzer {
    27 
    28     protected CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner) : base(original, cloner) {
     28  [StorableClass]
     29  [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     30  public class CrowdingAnalyzer : MOTFAnalyzer {
     31    [StorableHook(HookType.AfterDeserialization)]
     32    private void AfterDeserialization() {
     33    }
     34    [StorableConstructor]
     35    protected CrowdingAnalyzer(bool deserializing) : base(deserializing) { }
     36    public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner) : base(original, cloner) {
    2937    }
    3038    public override IDeepCloneable Clone(Cloner cloner) {
    3139      return new CrowdingAnalyzer(this, cloner);
    3240    }
     41
     42
     43
    3344    public CrowdingAnalyzer() { }
    3445
    35     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     46    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3647      int objectives = qualities[0].Length;
    3748      if (!results.ContainsKey("Crowding")) results.Add(new Result("Crowding", typeof(DoubleValue)));
    38       results["Crowding"].Value = new DoubleValue(Crowding.Calculate(qualities, TestFunction.Bounds(objectives)));
     49      results["Crowding"].Value = new DoubleValue(Crowding.Calculate(qualities, TestFunctionParameter.ActualValue.Bounds(objectives)));
    3950    }
    4051  }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/GenerationalDistanceAnalyzer.cs

    r13672 r13725  
    2020#endregion
    2121using HeuristicLab.Common;
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Optimization;
     25using HeuristicLab.Parameters;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2427
    2528namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    26   class GenerationalDistanceAnalyzer : MOTFAnalyzer {
    27     public GenerationalDistanceAnalyzer() {
     29  [StorableClass]
     30  [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     31  public class GenerationalDistanceAnalyzer : MOTFAnalyzer {
     32    [StorableHook(HookType.AfterDeserialization)]
     33    private void AfterDeserialization() {
    2834    }
    29 
    30     protected GenerationalDistanceAnalyzer(GenerationalDistanceAnalyzer original, Cloner cloner) : base(original, cloner) {
     35    [StorableConstructor]
     36    protected GenerationalDistanceAnalyzer(bool deserializing) : base(deserializing) { }
     37    public GenerationalDistanceAnalyzer(GenerationalDistanceAnalyzer original, Cloner cloner) : base(original, cloner) {
    3138    }
    32 
    3339    public override IDeepCloneable Clone(Cloner cloner) {
    3440      return new GenerationalDistanceAnalyzer(this, cloner);
    3541    }
    3642
    37     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     43    /// <summary>
     44    /// </summary>
     45    private IValueParameter<DoubleValue> DampeningParameter {
     46      get {
     47        return (IValueParameter<DoubleValue>)Parameters["Dampening"];
     48      }
     49      set {
     50        Parameters["Dampening"].ActualValue = value;
     51      }
     52    }
     53
     54    public GenerationalDistanceAnalyzer() {
     55      Parameters.Add(new ValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
     56    }
     57
     58    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3859      int objectives = qualities[0].Length;
    39       var optimalfront = TestFunction.OptimalParetoFront(objectives);
     60      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
    4061      if (optimalfront == null) {
    4162        return;
    4263      }
    4364      if (!results.ContainsKey("GenerationalDistance")) results.Add(new Result("GenerationalDistance", typeof(DoubleValue)));
    44       results["GenerationalDistance"].Value = new DoubleValue(GenerationalDistance.Calculate(qualities, optimalfront, 1));
     65      results["GenerationalDistance"].Value = new DoubleValue(GenerationalDistance.Calculate(qualities, optimalfront, DampeningParameter.Value.Value));
    4566    }
    4667  }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/HypervolumeAnalyzer.cs

    r13672 r13725  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Common;
     25using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Optimization;
     28using HeuristicLab.Parameters;
     29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2730
    2831namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    29   class HypervolumeAnalyzer : MOTFAnalyzer {
    30     public HypervolumeAnalyzer() {
     32  [StorableClass]
     33  [Item("GenerationalDistanceAnalyzer", "Computes the enclosed Hypervolume between the current front and a given reference Point")]
     34  public class HypervolumeAnalyzer : MOTFAnalyzer {
     35    [StorableHook(HookType.AfterDeserialization)]
     36    private void AfterDeserialization() {
    3137    }
    32 
    33     protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) { }
     38    [StorableConstructor]
     39    protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) { }
     40    public HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) { }
    3441    public override IDeepCloneable Clone(Cloner cloner) {
    3542      return new HypervolumeAnalyzer(this, cloner);
    3643    }
    3744
    38     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     45    public IValueParameter<DoubleArray> ReferencePointParameter {
     46      get {
     47        return (IValueParameter<DoubleArray>)Parameters["ReferencePoint"];
     48      }
     49    }
     50
     51    public IValueParameter<DoubleValue> BestKnownHyperVolumeParameter {
     52      get {
     53        return (IValueParameter<DoubleValue>)Parameters["BestKnownHyperVolume"];
     54      }
     55      set {
     56        Parameters["BestKnownHyperVolume"].ActualValue = value;
     57      }
     58    }
     59
     60    public HypervolumeAnalyzer() {
     61      Parameters.Add(new ValueParameter<DoubleArray>("ReferencePoint", "The reference point for hypervolume calculation"));
     62      Parameters.Add(new ValueParameter<DoubleValue>("BestKnownHyperVolume", "The currently best known hypervolume"));
     63    }
     64
     65    private void RegisterEventHandlers() {
     66      ReferencePointParameter.ValueChanged += ReferencePointParameterOnValueChanged;
     67    }
     68
     69    private void ReferencePointParameterOnValueChanged(object sender, EventArgs e) {
     70      BestKnownHyperVolumeParameter.Value = new DoubleValue(0);
     71    }
     72
     73    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3974      if (qualities == null || qualities.Length < 2) return;
    4075      int objectives = qualities[0].Length;
    41       double best = TestFunction.BestKnownHypervolume(objectives);
     76      double best = BestKnownHyperVolumeParameter.Value.Value;
    4277
    4378      double diff;
    4479
    4580      if (!results.ContainsKey("Hypervolume")) results.Add(new Result("Hypervolume", typeof(DoubleValue)));
    46       IEnumerable<double[]> front = NonDominatedSelect.selectNonDominatedVectors(qualities, TestFunction.Maximization(objectives), true);
     81      IEnumerable<double[]> front = NonDominatedSelect.selectNonDominatedVectors(qualities, TestFunctionParameter.ActualValue.Maximization(objectives), true);
    4782      if (!results.ContainsKey("BestKnownHypervolume")) results.Add(new Result("BestKnownHypervolume", typeof(DoubleValue)));
    4883      else {
     
    5590      try {
    5691        if (objectives == 2) { //Hypervolume analysis only with 2 objectives for now
    57           hv = Hypervolume.Calculate(front, TestFunction.ReferencePoint(objectives), TestFunction.Maximization(objectives));
    58         } else if (Array.TrueForAll(TestFunction.Maximization(objectives), x => !x)) {
    59           hv = FastHV2.Calculate(front, TestFunction.ReferencePoint(objectives));
     92          hv = Hypervolume.Calculate(front, ReferencePointParameter.Value, TestFunctionParameter.ActualValue.Maximization(objectives));
     93        } else if (Array.TrueForAll(TestFunctionParameter.ActualValue.Maximization(objectives), x => !x)) {
     94          hv = MultiDimensionalHypervolume.Calculate(front, ReferencePointParameter.Value);
    6095        }
    6196      }
    6297      catch (ArgumentException) {
    63         //TODO
     98
    6499      }
    65100
     
    71106        best = hv;
    72107        diff = 0;
     108        BestKnownFrontParameter.ActualValue = new DoubleMatrix(MultiObjectiveTestFunctionProblem.To2D(qualities));
    73109      }
    74110
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs

    r13672 r13725  
    2121
    2222using HeuristicLab.Common;
     23using HeuristicLab.Core;
    2324using HeuristicLab.Data;
    2425using HeuristicLab.Optimization;
     26using HeuristicLab.Parameters;
     27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2528
    2629namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    27   class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer {
    28     public InvertedGenerationalDistanceAnalyzer() {
     30  [StorableClass]
     31  [Item("InvertedGenerationalDistanceAnalyzer", "The inverted generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  public class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer {
     33    [StorableHook(HookType.AfterDeserialization)]
     34    private void AfterDeserialization() {
    2935    }
    30 
    31     protected InvertedGenerationalDistanceAnalyzer(InvertedGenerationalDistanceAnalyzer original, Cloner cloner) : base(original, cloner) {
     36    [StorableConstructor]
     37    protected InvertedGenerationalDistanceAnalyzer(bool deserializing) : base(deserializing) { }
     38    public InvertedGenerationalDistanceAnalyzer(InvertedGenerationalDistanceAnalyzer original, Cloner cloner) : base(original, cloner) {
    3239    }
    3340
     
    3643    }
    3744
    38     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     45    /// <summary>
     46    /// </summary>
     47    private IValueParameter<DoubleValue> DampeningParameter {
     48      get {
     49        return (IValueParameter<DoubleValue>)Parameters["Dampening"];
     50      }
     51      set {
     52        Parameters["Dampening"].ActualValue = value;
     53      }
     54    }
     55
     56    public InvertedGenerationalDistanceAnalyzer() {
     57      Parameters.Add(new ValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
     58    }
     59
     60    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3961      int objectives = qualities[0].Length;
    40       var optimalfront = TestFunction.OptimalParetoFront(objectives);
     62      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
    4163      if (optimalfront == null) {
    4264        return;
    4365      }
    4466      if (!results.ContainsKey("InvertedGenerationalDistance")) results.Add(new Result("InvertedGenerationalDistance", typeof(DoubleValue)));
    45       results["InvertedGenerationalDistance"].Value = new DoubleValue(InvertedGenerationalDistance.Calculate(qualities, optimalfront, 1));
     67      results["InvertedGenerationalDistance"].Value = new DoubleValue(InvertedGenerationalDistance.Calculate(qualities, optimalfront, DampeningParameter.Value.Value));
    4668    }
    4769  }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/MOTFAnalyzer.cs

    r13672 r13725  
    3434
    3535  [StorableClass]
    36   abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
     36  public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    3737
    3838    public ILookupParameter<IEncoding> EncodingParameter {
     
    4848    }
    4949
     50    public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter {
     51      get {
     52        return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"];
     53      }
     54    }
    5055
    51     private IMultiObjectiveTestFunction testFunction;
    52     public IMultiObjectiveTestFunction TestFunction {
    53       get { return testFunction; }
    54       set { testFunction = value; }
     56    public ILookupParameter<DoubleMatrix> BestKnownFrontParameter {
     57      get {
     58        return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"];
     59      }
    5560    }
    5661
     
    6368      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    6469      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
     70      Parameters.Add(new LookupParameter<IMultiObjectiveTestFunction>("TestFunction", "The Testfunction that is analyzed"));
     71      Parameters.Add(new LookupParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
    6572    }
    6673    [StorableHook(HookType.AfterDeserialization)]
     
    8592    }
    8693
    87     protected abstract void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results);
     94    public abstract void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results);
    8895  }
    8996}
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r13672 r13725  
    2121using System.Linq;
    2222using HeuristicLab.Common;
     23using HeuristicLab.Core;
    2324using HeuristicLab.Encodings.RealVectorEncoding;
    2425using HeuristicLab.Optimization;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2527
    2628namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    27   class ScatterPlotAnalyzer : MOTFAnalyzer {
     29  [StorableClass]
     30  [Item("ScatterPlotAnalyzer", "Creates a Scatterplot for the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     31  public class ScatterPlotAnalyzer : MOTFAnalyzer {
    2832
    29     protected ScatterPlotAnalyzer(ScatterPlotAnalyzer original, Cloner cloner) : base(original, cloner) {
     33    [StorableHook(HookType.AfterDeserialization)]
     34    private void AfterDeserialization() {
     35    }
     36    [StorableConstructor]
     37    protected ScatterPlotAnalyzer(bool deserializing) : base(deserializing) { }
     38    public ScatterPlotAnalyzer(ScatterPlotAnalyzer original, Cloner cloner) : base(original, cloner) {
    3039    }
    3140    public override IDeepCloneable Clone(Cloner cloner) {
    3241      return new ScatterPlotAnalyzer(this, cloner);
    3342    }
     43
     44
    3445    public ScatterPlotAnalyzer() { }
    3546
    36     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     47
     48
     49
     50
     51
     52    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3753      if (qualities == null || qualities.Length < 1) return;
    3854      int objectives = qualities[0].Length;
    3955      double[][] opf = new double[0][];
    40       var optmialFront = TestFunction.OptimalParetoFront(objectives);
     56      var optmialFront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
    4157      if (optmialFront != null) {
    4258        opf = optmialFront.Select(s => s.ToArray()).ToArray();
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Analyzers/SpacingAnalyzer.cs

    r13672 r13725  
    2121
    2222using HeuristicLab.Common;
     23using HeuristicLab.Core;
    2324using HeuristicLab.Data;
    2425using HeuristicLab.Optimization;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2527
    2628namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    27   class SpacingAnalyzer : MOTFAnalyzer {
     29  [StorableClass]
     30  [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     31  public class SpacingAnalyzer : MOTFAnalyzer {
     32
     33    [StorableHook(HookType.AfterDeserialization)]
     34    private void AfterDeserialization() {
     35    }
     36
     37    [StorableConstructor]
     38    protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }
     39
    2840    public SpacingAnalyzer() {
    2941    }
    3042
    31     protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) {
     43    public SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) {
    3244    }
    3345
     
    3648    }
    3749
    38     protected override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
     50    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results) {
    3951      if (!results.ContainsKey("Spacing")) results.Add(new Result("Spacing", typeof(DoubleValue)));
    4052      results["Spacing"].Value = new DoubleValue(Spacing.Calculate(qualities));
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/HyperVolume.cs

    r13672 r13725  
    5050    ///
    5151    /// </summary>
    52     public static double Calculate(IEnumerable<double[]> front, double[] reference, bool[] maximization) {
     52    public static double Calculate(IEnumerable<double[]> front, IEnumerable<double> reference, bool[] maximization) {
     53      List<double> list = new List<double>();
     54      foreach (double d in reference) list.Add(d);
     55      double[] refp = list.ToArray<double>();
    5356      if (front == null) throw new ArgumentException("Fronts must not be null");
    54       //TODO what to do if set contains dominated points
    5557      double[][] set = front.ToArray();   //Still no Good
    5658      if (set.Length == 0) throw new ArgumentException("Fronts must not be empty");
    5759      Array.Sort<double[]>(set, Utilities.getDimensionComparer(0, maximization[0]));
    5860      double[] last = set[set.Length - 1];
    59       CheckConsistency(last, 0, reference, maximization);
    60       CheckConsistency(last, 1, reference, maximization);
     61      CheckConsistency(last, 0, refp, maximization);
     62      CheckConsistency(last, 1, refp, maximization);
    6163
    6264      double sum = 0;
    6365      for (int i = 0; i < set.Length - 1; i++) {
    64         CheckConsistency(set[i], 1, reference, maximization);
    65         sum += Math.Abs((set[i][0] - set[i + 1][0])) * Math.Abs((set[i][1] - reference[1]));
     66        CheckConsistency(set[i], 1, refp, maximization);
     67        sum += Math.Abs((set[i][0] - set[i + 1][0])) * Math.Abs((set[i][1] - refp[1]));
    6668      }
    6769
    68       sum += Math.Abs(reference[0] - last[0]) * Math.Abs(reference[1] - last[1]);
     70      sum += Math.Abs(refp[0] - last[0]) * Math.Abs(refp[1] - last[1]);
    6971      return sum;
    7072    }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Calculators/MultiDimensionalHypervolume.cs

    r13724 r13725  
    2626
    2727namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
    28   public class FastHV2 {
    29 
    30     public static double Calculate(IEnumerable<double[]> points, double[] referencePoint) {
     28
     29  public class MultiDimensionalHypervolume {
     30    /// <summary>
     31    /// The Hyprevolume-metric is defined as the Hypervolume enclosed between a given reference point,
     32    /// that is fixed for every evaluation function and the evaluated front.
     33    ///
     34    /// Example:
     35    /// r is the reference Point at (1|1)  and every Point p is part of the evaluated front
     36    /// The filled Area labled HV is the 2 diensional Hypervolume enclosed by this front.
     37    ///
     38    /// (0|1)                (1|1)
     39    ///   +      +-------------r
     40    ///   |      |###### HV ###|
     41    ///   |      p------+######|
     42    ///   |             p+#####|
     43    ///   |              |#####|
     44    ///   |              p-+###|
     45    ///   |                p---+
     46    ///   |                 
     47    ///   +--------------------1
     48    /// (0|0)                (1|0)
     49    ///
     50    ///  Please note that in this example both dimensions are minimized. The reference Point need to be dominated by EVERY point in the evaluated front
     51    ///
     52    /// This is an efficient calculation for a multidimensional Hypervolume as described in
     53    /// "Faster S-Metric Calculation by Considering Dominated
     54    /// Hypervolume as Klee’s Measure Problem" by
     55    /// Nicola Beume and Günter Rudolph.
     56    ///
     57    ///
     58    /// A reference Impelementation in C++ can be found at http://image.diku.dk/shark/doxygen_pages/html/_hypervolume_calculator_8h_source.html
     59    /// </summary>
     60    public static double Calculate(IEnumerable<double[]> points, IEnumerable<double> reference) {
     61      double[] referencePoint = reference.ToArray<double>();
    3162      if (referencePoint == null || referencePoint.Length < 3) throw new ArgumentException("ReferencePoint unfit for complex Hypervolume calculation");
     63      if (!IsDominated(referencePoint, points)) {
     64        throw new ArgumentException("ReferencePoint unfit for complex Hypervolume calculation");
     65      }
    3266      int objectives = referencePoint.Length;
    3367      List<double[]> lpoints = new List<double[]>();
     
    4882
    4983      return Stream(regLow, referencePoint, lpoints, 0, referencePoint[objectives - 1], (int)Math.Sqrt(points.Count()), objectives);
     84    }
     85
     86    private static bool IsDominated(double[] referencePoint, IEnumerable<double[]> points) {
     87      foreach (double[] point in points) {
     88        for (int i = 0; i < referencePoint.Length; i++) {
     89          if (referencePoint[i] < point[i]) {
     90            return false;
     91          }
     92        }
     93      }
     94      return true;
    5095    }
    5196
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Data/MISCInstanceProvider.cs

    r13672 r13725  
    4747      var otherProviders = ApplicationManager.Manager.GetInstances<IProblemInstanceProvider<MOTFData>>().Where(x => x.Equals(this));
    4848      var evaluators = ApplicationManager.Manager.GetInstances<IMultiObjectiveTestFunction>()
    49                                                  .Where(x => !handles(otherProviders, x))
     49                                                 .Where(x => !Handled(x))
    5050                                                 .OrderBy(x => x.Name);
    5151      return evaluators.Select(x => new MOTFDataDescriptor(x));
    5252    }
    5353
    54     private bool handles(IEnumerable<IProblemInstanceProvider<MOTFData>> others, IMultiObjectiveTestFunction x) {
    55       foreach (var o in others) {
    56         foreach (var instance in o.GetDataDescriptors()) {
    57           if (instance.Equals(x)) return true;
    58         }
    59       }
    60       return false;
     54    private bool Handled(IMultiObjectiveTestFunction f) {
     55
     56
     57      return f is DTLZ || f is ZDT;
    6158    }
    6259
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/HeuristicLab.Problems.MultiObjectiveTestFunctions-3.3.csproj

    r13672 r13725  
    141141    <Compile Include="Interfaces\IMultiObjectiveTestFunctionAnalyzer.cs" />
    142142    <Compile Include="Calculators\Crowding.cs" />
    143     <Compile Include="Calculators\FastHV2.cs" />
     143    <Compile Include="Calculators\MultiDimensionalHypervolume.cs" />
    144144    <Compile Include="Calculators\Spacing.cs" />
    145145    <Compile Include="Calculators\HyperVolume.cs" />
     
    153153    <Compile Include="Data\DTLZInstanceProvider.cs" />
    154154    <Compile Include="Interfaces\IMOFrontModel.cs" />
    155     <Compile Include="Drawings\MOSolution.cs" />
    156     <Compile Include="Drawings\MOFrontScatterPlotView.cs">
     155    <Compile Include="Views\MOSolution.cs" />
     156    <Compile Include="Views\MOFrontScatterPlotView.cs">
    157157      <SubType>UserControl</SubType>
    158158    </Compile>
    159     <Compile Include="Drawings\MOFrontScatterPlotView.Designer.cs">
     159    <Compile Include="Views\MOFrontScatterPlotView.Designer.cs">
    160160      <DependentUpon>MOFrontScatterPlotView.cs</DependentUpon>
    161161    </Compile>
     
    208208  </ItemGroup>
    209209  <ItemGroup>
    210     <EmbeddedResource Include="Drawings\MOFrontScatterPlotView.resx">
     210    <EmbeddedResource Include="Views\MOFrontScatterPlotView.resx">
    211211      <DependentUpon>MOFrontScatterPlotView.cs</DependentUpon>
    212212    </EmbeddedResource>
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Interfaces/IMultiObjectiveTestFunctionAnalyzer.cs

    r13672 r13725  
    3232    ILookupParameter<ResultCollection> ResultsParameter { get; }
    3333
    34     IMultiObjectiveTestFunction TestFunction { get; set; }
     34    ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter { get; }
     35
     36    ILookupParameter<DoubleMatrix> BestKnownFrontParameter { get; }
     37
    3538  }
    3639}
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/MultiObjectiveTestFunctionProblem.cs

    r13672 r13725  
    7676      get { return (IValueParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    7777    }
     78
     79    /// <summary>
     80    /// The testfunction
     81    /// </summary>
     82    public IValueParameter<DoubleArray> ReferencePointParameter {
     83      get { return (IValueParameter<DoubleArray>)Parameters["ReferencePoint"]; }
     84    }
     85
     86    public IValueParameter<DoubleMatrix> BestKnownFrontParameter {
     87      get {
     88        return (IValueParameter<DoubleMatrix>)Parameters["BestKnownFront"];
     89      }
     90    }
     91
    7892    #endregion
    7993
     
    115129      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -4, 4 } })));
    116130      Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca()));
     131      Parameters.Add(new ValueParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
    117132
    118133      Encoding.LengthParameter = ProblemSizeParameter;
    119134      Encoding.BoundsParameter = BoundsParameter;
     135      BestKnownFrontParameter.Hidden = true;
    120136
    121137      InitializeOperators();
     
    132148    public override void Analyze(Individual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {
    133149      base.Analyze(individuals, qualities, results, random);
     150      if (results.ContainsKey("Pareto Front")) {
     151        ((DoubleMatrix)results["Pareto Front"].Value).SortableView = true;
     152      }
     153      //DoubleMatrix res = (DoubleMatrix)results["Pareto Front"];
     154      //res.SortableView = true;
    134155    }
    135156
     
    235256        analyzer.ResultsParameter.ActualName = "Results";
    236257        analyzer.QualitiesParameter.ActualName = Evaluator.QualitiesParameter.ActualName;
    237         analyzer.TestFunction = TestFunction;
     258        analyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name;
     259        analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
     260
     261        BestKnownFrontParameter.ActualValue = new DoubleMatrix(To2D(TestFunction.OptimalParetoFront(Objectives).ToArray<double[]>()));
     262        if (analyzer is HypervolumeAnalyzer) {
     263          ((HypervolumeAnalyzer)analyzer).ReferencePointParameter.Value = new DoubleArray(TestFunction.ReferencePoint(Objectives));
     264          ((HypervolumeAnalyzer)analyzer).BestKnownHyperVolumeParameter.Value = new DoubleValue(TestFunction.BestKnownHypervolume(Objectives));
     265        }
     266
     267      }
     268    }
     269
     270    public static T[,] To2D<T>(T[][] source) {
     271      try {
     272        int FirstDim = source.Length;
     273        int SecondDim = source.GroupBy(row => row.Length).Single().Key; // throws InvalidOperationException if source is not rectangular
     274
     275        var result = new T[FirstDim, SecondDim];
     276        for (int i = 0; i < FirstDim; ++i)
     277          for (int j = 0; j < SecondDim; ++j)
     278            result[i, j] = source[i][j];
     279
     280        return result;
     281      }
     282      catch (InvalidOperationException) {
     283        throw new InvalidOperationException("The given jagged array is not rectangular.");
    238284      }
    239285    }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ1.cs

    r13673 r13725  
    4747    public override double[] Evaluate(RealVector r, int objectives) {
    4848      if (r.Length < objectives) {
    49         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger or equal than the dimensionality of the solution(SolutionSize) ");
     49        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    5050      }
    5151      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ2.cs

    r13672 r13725  
    4747    public override double[] Evaluate(RealVector r, int objectives) {
    4848      if (r.Length < objectives) {
    49         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger or equal than the dimensionality of the solution(SolutionSize) ");
     49        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    5050      }
    5151
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ3.cs

    r13673 r13725  
    4646    public override double[] Evaluate(RealVector r, int objectives) {
    4747      if (r.Length < objectives) {
    48         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger or equal than the dimensionality of the solution(SolutionSize) ");
     48        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4949      }
    5050      double[] res = new double[objectives];
     
    5353      double sum = 0;
    5454      int length = r.Length - objectives + 1;
    55       for (int i = r.Length-length; i < r.Length; i++) {
     55      for (int i = r.Length - length; i < r.Length; i++) {
    5656        double d = r[i] - 0.5;
    5757        sum += d * d - Math.Cos(20 * Math.PI * d);
    58        
    5958      }
    6059      double g = 100 * (length + sum);
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ4.cs

    r13672 r13725  
    4646    public override double[] Evaluate(RealVector r, int objectives) {
    4747      if (r.Length < objectives) {
    48         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger or equal than the dimensionality of the solution(SolutionSize) ");
     48        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4949      }
    5050      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ5.cs

    r13672 r13725  
    4141    public override double[] Evaluate(RealVector r, int objectives) {
    4242      if (r.Length < objectives) {
    43         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than the dimensionality of the solution(SolutionSize) ");
     43        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4444      }
    4545      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ6.cs

    r13672 r13725  
    4040    public override double[] Evaluate(RealVector r, int objectives) {
    4141      if (r.Length < objectives) {
    42         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than the dimensionality of the solution(SolutionSize) ");
     42        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    4343      }
    4444      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ7.cs

    r13673 r13725  
    4747    public override double[] Evaluate(RealVector r, int objectives) {
    4848      if (r.Length < objectives) {
    49         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to the dimensionality of the solution(SolutionSize) ");
     49        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
    5050      }
    5151      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ8.cs

    r13672 r13725  
    4141    public double[] Evaluate2(RealVector r, int objectives) {
    4242      if (r.Length < objectives) {
    43         throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the dimensionality of the solution(SolutionSize) ");
     43        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to ten times the number of objectives ");
    4444      }
    4545      double[] res = new double[objectives];
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/MultiObjectiveTestFunction.cs

    r13672 r13725  
    105105    protected MultiObjectiveTestFunction(MultiObjectiveTestFunction original, Cloner cloner) : base(original, cloner) {
    106106      this.objectives = original.objectives;
     107    }
     108    protected MultiObjectiveTestFunction() : base() {
    107109      Parameters.Add(new FixedValueParameter<IntValue>("MinimumObjectives", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(MinimumObjectives)));
    108110      Parameters.Add(new FixedValueParameter<IntValue>("MaximumObjectives", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(MaximumObjectives)));
     
    110112      Parameters.Add(new FixedValueParameter<IntValue>("MaximumSolutionLength", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(MaximumSolutionLength)));
    111113    }
    112     protected MultiObjectiveTestFunction() : base() { }
    113114
    114115
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Views/MOFrontScatterPlotView.Designer.cs

    r13672 r13725  
    8585      this.menuStrip1.TabIndex = 2;
    8686      this.menuStrip1.Text = "menuStrip1";
     87      this.menuStrip1.ShowItemToolTips = true;
    8788      //
    8889      // chooseDimensionToolStripMenuItem
     
    9091      this.chooseDimensionToolStripMenuItem.Name = "chooseDimensionToolStripMenuItem";
    9192      this.chooseDimensionToolStripMenuItem.Size = new System.Drawing.Size(253, 38);
    92       this.chooseDimensionToolStripMenuItem.Text = "Choose X-Dimension";
     93      this.chooseDimensionToolStripMenuItem.Text = "Objective 0";
     94      this.chooseDimensionToolStripMenuItem.ToolTipText = "Choose X-Dimension";
    9395      //
    9496      // chooseYDimensionToolStripMenuItem
     
    98100      this.chooseYDimensionToolStripMenuItem.Name = "chooseYDimensionToolStripMenuItem";
    99101      this.chooseYDimensionToolStripMenuItem.Size = new System.Drawing.Size(252, 38);
    100       this.chooseYDimensionToolStripMenuItem.Text = "Choose Y-Dimension";
     102      this.chooseYDimensionToolStripMenuItem.Text = "Objective 1";
     103      this.chooseYDimensionToolStripMenuItem.ToolTipText = "Choose Y-Dimension";
    101104      //
    102105      // testToolStripMenuItem
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Views/MOFrontScatterPlotView.cs

    r13672 r13725  
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    2322using System.Data;
    2423using System.Drawing;
     
    8483
    8584    private void Chart_GetToolTipText(object sender, ToolTipEventArgs e) {
     85      if (e.HitTestResult.ChartElementType == ChartElementType.LegendItem) {
     86        if (e.HitTestResult.Series == paretoSeries && (Content.ParetoFront == null || Content.ParetoFront.Length == 0)) {
     87          e.Text = "No optimal pareto front is available for this problem with this number of objectives";
     88        }
     89        if (e.HitTestResult.Series == paretoSeries && (xDim >= Content.Objectives || yDim >= Content.Objectives)) {
     90          e.Text = "The optimal pareto front can only be displayed in  Objective Space";
     91        }
     92      }
    8693
    8794      // Check selected chart element and set tooltip text
     
    121128        paretoSeries = null;
    122129        this.chart.Series.Remove(s);
     130
    123131      } else if (Content.ParetoFront != null && !chart.Series.Contains(paretoSeries)) {
    124132        this.chart.Series.Add(PARETO_FRONT);
     
    174182
    175183        if (this.chart.Series.Contains(qualitySeries) && qualitySeries.Points.Count() != 0) {
    176           fillSeries(Content.Qualities, qualitySeries);
     184          fillSeries(Content.Qualities, Content.Solutions, qualitySeries);
    177185        }
    178186        if (this.chart.Series.Contains(paretoSeries) && paretoSeries.Points.Count() != 0) {
    179           fillSeries(Content.ParetoFront, paretoSeries);
     187          fillSeries(Content.ParetoFront, null, paretoSeries);
    180188        }
    181189
     
    239247        switch (series.Name) {
    240248          case PARETO_FRONT:
    241             fillSeries(Content.ParetoFront, this.chart.Series[PARETO_FRONT]);
     249            fillSeries(Content.ParetoFront, null, this.chart.Series[PARETO_FRONT]);
    242250            break;
    243251          case QUALITIES:
    244             fillSeries(Content.Qualities, this.chart.Series[QUALITIES]);
     252            fillSeries(Content.Qualities, Content.Solutions, this.chart.Series[QUALITIES]);
    245253            break;
    246254        }
     
    278286      chooseYDimensionToolStripMenuItem.DropDownItems.Clear();
    279287      if (Content == null) { return; }
    280       for (int i = 0; i < Content.Objectives; i++) {
     288      int i = 0;
     289      for (; i < Content.Objectives; i++) {
    281290        //add Menu Points
    282         ToolStripMenuItem xItem = makeMenuItem("X", i);
    283         ToolStripMenuItem yItem = makeMenuItem("Y", i); ;
     291        ToolStripMenuItem xItem = makeMenuItem("X", "Objective " + i, i);
     292        ToolStripMenuItem yItem = makeMenuItem("Y", "Objective " + i, i);
    284293        xItem.Click += new System.EventHandler(this.XMenu_Click);
    285294        yItem.Click += new System.EventHandler(this.YMenu_Click);
     
    287296        chooseYDimensionToolStripMenuItem.DropDownItems.Add(yItem);
    288297      }
    289     }
    290 
    291     private ToolStripMenuItem makeMenuItem(String axis, int i) {
     298
     299      for (; i < Content.Solutions[0].Length + Content.Objectives; i++) {
     300        ToolStripMenuItem xItem = makeMenuItem("X", "ProblemDimension " + (i - Content.Objectives), i);
     301        ToolStripMenuItem yItem = makeMenuItem("Y", "ProblemDimension " + (i - Content.Objectives), i); ;
     302        xItem.Click += new System.EventHandler(this.XMenu_Click);
     303        yItem.Click += new System.EventHandler(this.YMenu_Click);
     304        chooseDimensionToolStripMenuItem.DropDownItems.Add(xItem);
     305        chooseYDimensionToolStripMenuItem.DropDownItems.Add(yItem);
     306      }
     307    }
     308
     309    private ToolStripMenuItem makeMenuItem(String axis, String label, int i) {
    292310      ToolStripMenuItem xItem = new ToolStripMenuItem();
    293311      xItem.Name = "obj" + i;
    294312      xItem.Size = new System.Drawing.Size(269, 38);
    295       xItem.Text = "Objective" + i;
     313      xItem.Text = label;
    296314      return xItem;
    297315    }
     
    300318      ToolStripMenuItem item = (ToolStripMenuItem)sender;
    301319      yDim = Int32.Parse(item.Name.Remove(0, 3));
    302       this.chooseYDimensionToolStripMenuItem.Text = "Objective" + yDim;
    303       this.chart.ChartAreas[0].AxisY.Title = "Objective " + yDim;
     320      String label = item.Text;
     321      this.chooseYDimensionToolStripMenuItem.Text = label;
     322      this.chart.ChartAreas[0].AxisY.Title = label;
    304323      UpdateChart();
    305324    }
     
    308327      ToolStripMenuItem item = (ToolStripMenuItem)sender;
    309328      xDim = Int32.Parse(item.Name.Remove(0, 3));
    310       this.chooseDimensionToolStripMenuItem.Text = "Objective" + xDim;
    311       this.chart.ChartAreas[0].AxisX.Title = "Objective " + xDim;
     329      String label = item.Text;
     330      this.chooseDimensionToolStripMenuItem.Text = label;
     331      this.chart.ChartAreas[0].AxisX.Title = label;
    312332      UpdateChart();
    313333    }
    314334
    315     private void fillSeries(IEnumerable<double[]> data, Series series) {
     335    private void fillSeries(double[][] qualities, double[][] solutions, Series series) {
    316336      series.Points.Clear();
    317       foreach (double[] d in data) {   //Assumtion: Columnwise
    318         series.Points.AddXY(d[xDim], d[yDim]);
     337      int jx = xDim - qualities[0].Length;
     338      int jy = yDim - qualities[0].Length;
     339      if ((jx >= 0 || jy >= 0) && solutions == null) {
     340        return;
     341      }
     342      for (int i = 0; i < qualities.Length; i++) {   //Assumtion: Columnwise
     343        double[] d = qualities[i];
     344        double[] q = null;
     345        if (jx >= 0 || jy >= 0) { q = solutions[i]; }
     346        series.Points.AddXY(jx < 0 ? d[xDim] : q[jx], jy < 0 ? d[yDim] : q[jy]);
    319347      }
    320348    }
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Views/MOSolution.cs

    r13672 r13725  
    2020#endregion
    2121using System;
    22 using System.Collections.Generic;
    2322using System.Drawing;
    2423using HeuristicLab.Common;
     
    6665    public string ItemName {
    6766      get {
    68         return "MyName";
     67        return "MOSolution";
    6968      }
    7069    }
Note: See TracChangeset for help on using the changeset viewer.