Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/19 13:53:26 (5 years ago)
Author:
mkommend
Message:

#2521: Integrated changes of #2943 into problem refactoring branch.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/CrowdingAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("F06FB45C-051E-4AD8-BD82-16DA9DCBCACB")]
    32   [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("CrowdingAnalyzer", "This analyzer is functionally equivalent to the CrowdingAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class CrowdingAnalyzer : MOTFAnalyzer {
    34 
    35     public ILookupParameter<DoubleMatrix> BoundsParameter {
    36       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    37     }
    3834
    3935    public IResultParameter<DoubleValue> CrowdingResultParameter {
     
    4339    [StorableConstructor]
    4440    protected CrowdingAnalyzer(StorableConstructorFlag _) : base(_) { }
    45     public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner)
    46       : base(original, cloner) {
    47     }
     41    public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner): base(original, cloner) {}
    4842    public override IDeepCloneable Clone(Cloner cloner) {
    4943      return new CrowdingAnalyzer(this, cloner);
     
    5145
    5246    public CrowdingAnalyzer() {
    53       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds",
    54         "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."));
    55       Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding value of all points (excluding infinities)"));
     47      Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding distance of all points (excluding infinities)"));
    5648      CrowdingResultParameter.DefaultValue = new DoubleValue(double.NaN);
    57 
    5849    }
    5950
    6051    public override IOperation Apply() {
    6152      var qualities = QualitiesParameter.ActualValue;
    62       var bounds = BoundsParameter.ActualValue;
    63 
    64       var crowdingDistance = Crowding.Calculate(qualities.Select(x => x.ToArray()), bounds.CloneAsMatrix());
     53      var crowdingDistance = CrowdingCalculator.CalculateCrowding(qualities);
    6554      CrowdingResultParameter.ActualValue.Value = crowdingDistance;
    66 
    6755      return base.Apply();
    6856    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("EBC72F16-E329-4D18-800C-8642EFD0F05C")]
    32   [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("GenerationalDistanceAnalyzer", "This analyzer is functionally equivalent to the GenerationalDistanceAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class GenerationalDistanceAnalyzer : MOTFAnalyzer {
    3434
     
    6363    public override IOperation Apply() {
    6464      var qualities = QualitiesParameter.ActualValue;
    65       int objectives = qualities[0].Length;
    66 
    67       var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(objectives);
     65      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    6866      if (optimalfront == null) return base.Apply();
    6967
    70       var distance = GenerationalDistance.Calculate(qualities.Select(x => x.CloneAsArray()), optimalfront, Dampening);
    71       GenerationalDistanceResultParameter.ActualValue.Value = distance;
    72 
     68      var q = qualities.Select(x => x.ToArray());
     69      GenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistance.Calculate(q, optimalfront, Dampening);
    7370      return base.Apply();
    7471    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs

    r16723 r17225  
    3232namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3333  [StorableType("13D363E4-76FF-4A5A-9B2C-767D9E880E4B")]
    34   [Item("HypervolumeAnalyzer", "Computes the enclosed Hypervolume between the current front and a given reference Point")]
     34  [Item("HypervolumeAnalyzer", "This analyzer is functionally equivalent to the HypervolumeAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3535  public class HypervolumeAnalyzer : MOTFAnalyzer {
    3636
     
    3838      get { return (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    3939    }
     40
    4041    public IResultParameter<DoubleValue> HypervolumeResultParameter {
    4142      get { return (IResultParameter<DoubleValue>)Parameters["Hypervolume"]; }
    4243    }
     44
    4345    public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter {
    4446      get { return (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"]; }
    4547    }
     48
    4649    public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter {
    4750      get { return (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"]; }
     
    5356    }
    5457
    55     protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner)
    56       : base(original, cloner) {
    57     }
     58    protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {}
     59
    5860    public override IDeepCloneable Clone(Cloner cloner) {
    5961      return new HypervolumeAnalyzer(this, cloner);
     
    6870      BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(0);
    6971      HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(0);
    70 
    71 
    7272    }
    7373
     
    7575      var qualities = QualitiesParameter.ActualValue;
    7676      var testFunction = TestFunctionParameter.ActualValue;
    77       int objectives = qualities[0].Length;
     77      var objectives = qualities[0].Length;
    7878      var referencePoint = ReferencePointParameter.ActualValue;
    7979
    80       double best = BestKnownHypervolumeResultParameter.ActualValue.Value;
     80      var best = BestKnownHypervolumeResultParameter.ActualValue.Value;
    8181      if (referencePoint.SequenceEqual(testFunction.ReferencePoint(objectives))) {
    8282        best = Math.Max(best, testFunction.OptimalHypervolume(objectives));
    8383      }
    8484
    85       IEnumerable<double[]> front = NonDominatedSelect.SelectNonDominatedVectors(qualities.Select(q => q.ToArray()), testFunction.Maximization(objectives), true);
    86 
    87       double hv = Hypervolume.Calculate(front, referencePoint.ToArray(), testFunction.Maximization(objectives));
     85      var hv = HypervolumeCalculator.CalculateHypervolume(qualities.Select(x=>x.CloneAsArray()).ToArray(), referencePoint.ToArray(), testFunction.Maximization(objectives));
    8886
    8987      if (hv > best) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs

    r16723 r17225  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableType("EC99F3C1-D8D2-4738-9523-0D07438647A5")]
    32   [Item("InvertedGenerationalDistanceAnalyzer", "The inverted generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     32  [Item("InvertedGenerationalDistanceAnalyzer", "This analyzer is functionally equivalent to the InvertedGenerationalDistanceAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3333  public class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer {
    34     public override bool EnabledByDefault { get { return false; } }
     34    public override bool EnabledByDefault {
     35      get { return false; }
     36    }
    3537
    3638    private IFixedValueParameter<DoubleValue> DampeningParameter {
     
    5153      Parameters.Add(new ResultParameter<DoubleValue>("Inverted Generational Distance", "The genrational distance between the current front and the optimal front"));
    5254      InvertedGenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
    53 
    5455    }
    5556
     
    6465    public override IOperation Apply() {
    6566      var qualities = QualitiesParameter.ActualValue;
    66       var testFunction = TestFunctionParameter.ActualValue;
    67       int objectives = qualities[0].Length;
    68 
    69       var optimalfront = testFunction.OptimalParetoFront(objectives);
     67      var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    7068      if (optimalfront == null) return base.Apply();
    7169
    72       var invertedGenerationalDistance = InvertedGenerationalDistance.Calculate(qualities.Select(q => q.ToArray()), optimalfront, DampeningParameter.Value.Value);
    73       InvertedGenerationalDistanceResultParameter.ActualValue.Value = invertedGenerationalDistance;
    74 
     70      var q = qualities.Select(x => x.ToArray());
     71      InvertedGenerationalDistanceResultParameter.ActualValue.Value = InvertedGenerationalDistance.Calculate(q, optimalfront, Dampening);
    7572      return base.Apply();
    7673    }
    77 
    78 
    7974  }
    8075}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/MOTFAnalyzer.cs

    r16723 r17225  
    3333  [StorableType("CFBB2CAB-C1B7-4F14-9A01-6D5624B7B681")]
    3434  public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    35     public virtual bool EnabledByDefault { get { return true; } }
     35    public virtual bool EnabledByDefault {
     36      get { return true; }
     37    }
    3638
    3739    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r16723 r17225  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
    2627using HeuristicLab.Optimization;
     
    4142    }
    4243
    43 
    4444    [StorableConstructor]
    4545    protected ScatterPlotAnalyzer(StorableConstructorFlag _) : base(_) { }
     
    5252      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem"));
    5353      Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)"));
    54 
    5554    }
    5655
     
    5958      var individuals = IndividualsParameter.ActualValue;
    6059      var testFunction = TestFunctionParameter.ActualValue;
    61       int objectives = qualities[0].Length;
    62       int problemSize = individuals[0].Length;
     60      var objectives = qualities.Length != 0 ? qualities[0].Length:0;   
     61      var problemSize = individuals.Length != 0 ? individuals[0].Length:0;
    6362
    64       double[][] optimalFront = new double[0][];
    65       var front = testFunction.OptimalParetoFront(objectives);
    66       if (front != null) optimalFront = front.ToArray();
     63      var optimalFront = new double[0][];               
     64      if (testFunction != null) {
     65        var front = testFunction.OptimalParetoFront(objectives);
     66        if (front != null) optimalFront = front.ToArray();
     67      }
     68      else {
     69        var mat = BestKnownFrontParameter.ActualValue;
     70        optimalFront = mat == null ? null : Enumerable.Range(0, mat.Rows).Select(r => Enumerable.Range(0, mat.Columns).Select(c => mat[r, c]).ToArray()).ToArray();
     71      }
    6772
    6873      var qualityClones = qualities.Select(s => s.ToArray()).ToArray();
     
    7075
    7176      ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize);
    72 
    7377      return base.Apply();
    7478    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs

    r16723 r17225  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Optimization;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3030  [StorableType("F32027A7-3116-4864-A404-820F866BFD65")]
    31   [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     31  [Item("SpacingAnalyzer", "This analyzer is functionally equivalent to the SpacingAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3232  public class SpacingAnalyzer : MOTFAnalyzer {
    3333
     
    3535      get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }
    3636    }
     37
    3738    [StorableConstructor]
    3839    protected SpacingAnalyzer(StorableConstructorFlag _) : base(_) { }
    39 
    4040
    4141    protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }
     
    5151    public override IOperation Apply() {
    5252      var qualities = QualitiesParameter.ActualValue;
    53       var spacing = Spacing.Calculate(qualities.Select(q => q.ToArray()));
    54       SpacingResultParameter.ActualValue.Value = spacing;
    55 
     53      var q = qualities.Select(x => x.ToArray());
     54      SpacingResultParameter.ActualValue.Value = Spacing.Calculate(q);
    5655      return base.Apply();
    5756    }
Note: See TracChangeset for help on using the changeset viewer.