Changeset 17229


Ignore:
Timestamp:
09/03/19 14:49:46 (3 weeks ago)
Author:
abeham
Message:

#2521: Refactored ParetoFrontScatterPlot (moved from TestFunctions.MultiObjective to Analysis)

  • Introduced generic type that may work with all solution encodings
Location:
branches/2521_ProblemRefactoring
Files:
3 added
8 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis.Views/3.3/HeuristicLab.Analysis.Views-3.3.csproj

    r16723 r17229  
    144144      <DependentUpon>IndexedDataTableView.cs</DependentUpon>
    145145    </Compile>
     146    <Compile Include="ParetoFrontScatterPlotViewOfT.cs">
     147      <SubType>UserControl</SubType>
     148    </Compile>
     149    <Compile Include="ParetoFrontScatterPlotViewOfT.Designer.cs">
     150      <DependentUpon>ParetoFrontScatterPlotViewOfT.cs</DependentUpon>
     151    </Compile>
     152    <Compile Include="ParetoFrontScatterPlotView.cs">
     153      <SubType>UserControl</SubType>
     154    </Compile>
     155    <Compile Include="ParetoFrontScatterPlotView.Designer.cs">
     156      <DependentUpon>ParetoFrontScatterPlotView.cs</DependentUpon>
     157    </Compile>
    146158    <Compile Include="ScatterPlotView.cs">
    147159      <SubType>UserControl</SubType>
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis.Views/3.3/ParetoFrontScatterPlotView.Designer.cs

    r17228 r17229  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.TestFunctions.Views {
     22namespace HeuristicLab.Analysis.Views {
    2323  partial class ParetoFrontScatterPlotView {
    2424    /// <summary>
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis.Views/3.3/ParetoFrontScatterPlotView.cs

    r17228 r17229  
    2222using System;
    2323using System.Linq;
    24 using HeuristicLab.Analysis;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core.Views;
    2726using HeuristicLab.MainForm;
    28 using HeuristicLab.Problems.TestFunctions.MultiObjective;
    2927
    30 namespace HeuristicLab.Problems.TestFunctions.Views {
     28namespace HeuristicLab.Analysis.Views {
    3129  [View("Scatter Plot")]
     30#pragma warning disable CS0618 // Type or member is obsolete
    3231  [Content(typeof(ParetoFrontScatterPlot))]
     32#pragma warning restore CS0618 // Type or member is obsolete
    3333  public partial class ParetoFrontScatterPlotView : ItemView {
    3434
     
    4242    private bool suppressEvents;
    4343
     44#pragma warning disable CS0618 // Type or member is obsolete
    4445    public new ParetoFrontScatterPlot Content {
    4546      get { return (ParetoFrontScatterPlot)base.Content; }
    4647      set { base.Content = value; }
    4748    }
     49#pragma warning restore CS0618 // Type or member is obsolete
    4850
    4951    public ParetoFrontScatterPlotView() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r17225 r17229  
    155155    <Compile Include="MultiObjective\InvertedGenerationalDistanceAnalyzer.cs" />
    156156    <Compile Include="MultiObjective\MultiObjectiveSuccessAnalyzer.cs" />
     157    <Compile Include="MultiObjective\ParetoFrontScatterPlot.cs" />
    157158    <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" />
    158159    <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Analysis/3.3/MultiObjective/ParetoFrontScatterPlot.cs

    r17228 r17229  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.Drawing;
    2325using System.Linq;
     26using HEAL.Attic;
    2427using HeuristicLab.Common;
    2528using HeuristicLab.Core;
    26 using HEAL.Attic;
    2729
    28 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     30namespace HeuristicLab.Analysis {
     31  [StorableType("1bc5f640-ed3a-49dd-9dca-aa034cc81e12")]
     32  [Item("Pareto Front Scatter Plot", "The optimal front, current front(s) and associated items.")]
     33  public class ParetoFrontScatterPlot<T> : Item where T: class, IItem {
     34
     35    public static new Image StaticItemImage {
     36      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
     37    }
     38
     39    [Storable]
     40    private int objectives;
     41    public int Objectives {
     42      get { return objectives; }
     43    }
     44
     45    [Storable]
     46    private IList<double[][]> fronts;
     47    public IList<double[][]> Fronts {
     48      get { return fronts; }
     49    }
     50
     51    [Storable]
     52    private IList<T[]> items;
     53    public IList<T[]> Items {
     54      get { return items; }
     55    }
     56
     57    [Storable]
     58    private IList<double[]> bestKnownFront;
     59    public IList<double[]> BestKnownFront {
     60      get { return bestKnownFront; }
     61    }
     62
     63    [StorableConstructor]
     64    protected ParetoFrontScatterPlot(StorableConstructorFlag _) : base(_) { }
     65    public ParetoFrontScatterPlot() { }
     66    public ParetoFrontScatterPlot(IList<double[][]> qualities, IList<T[]> items, IList<double[]> paretoFront, int objectives) {
     67      this.fronts = qualities;
     68      this.items = items;
     69      this.bestKnownFront = paretoFront;
     70      this.objectives = objectives;
     71    }
     72    protected ParetoFrontScatterPlot(ParetoFrontScatterPlot<T> original, Cloner cloner)
     73      : base(original, cloner) {
     74      if (original.fronts != null) fronts = original.fronts.Select(s => s.Select(x => x.ToArray()).ToArray()).ToArray();
     75      if (original.items != null) items = original.items.Select(s => s.Select(cloner.Clone).ToArray()).ToArray();
     76      if (original.bestKnownFront != null) bestKnownFront = original.bestKnownFront.Select(s => s.ToArray()).ToArray();
     77      objectives = original.objectives;
     78    }
     79    public override IDeepCloneable Clone(Cloner cloner) {
     80      return new ParetoFrontScatterPlot<T>(this, cloner);
     81    }
     82  }
     83
    2984  [StorableType("3BF7AD0E-8D55-4033-974A-01DB16F9E41A")]
    3085  [Item("Pareto Front Scatter Plot", "The optimal front, current front and its associated Points in the searchspace")]
     86  [Obsolete("Use the generic ParetoFrontScatterPlot<T> instead.")]
    3187  public class ParetoFrontScatterPlot : Item {
    3288    public static new Image StaticItemImage {
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r17226 r17229  
    1 #region License Information
     1
     2#region License Information
    23/* HeuristicLab
    34 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj

    r16723 r17229  
    130130    <Compile Include="ArchitectureManipulators\SymbolicExpressionTreeArchitectureManipulator.cs" />
    131131    <Compile Include="Grammars\GrammarUtils.cs" />
     132    <Compile Include="SymbolicExpressionTreeMultiObjectiveProblem.cs" />
    132133    <Compile Include="SymbolicExpressionTreeProblem.cs" />
    133134    <Compile Include="Compiler\Instruction.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeProblem.cs

    r17226 r17229  
    7171      }
    7272    }
     73
     74    protected override void OnEncodingChanged() {
     75      base.OnEncodingChanged();
     76      Parameterize();
     77    }
     78
     79    private void Parameterize() {
     80      foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) {
     81        similarityCalculator.SolutionVariableName = Encoding.Name;
     82        similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName;
     83      }
     84    }
    7385  }
    7486}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r17226 r17229  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
     24using HeuristicLab.Analysis;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
    25 using HeuristicLab.Data;
    2627using HeuristicLab.Encodings.RealVectorEncoding;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     
    3838    }
    3939
    40     public IResultParameter<ParetoFrontScatterPlot> ScatterPlotResultParameter {
    41       get { return (IResultParameter<ParetoFrontScatterPlot>)Parameters["Scatterplot"]; }
     40    public IResultParameter<ParetoFrontScatterPlot<RealVector>> ScatterPlotResultParameter {
     41      get { return (IResultParameter<ParetoFrontScatterPlot<RealVector>>)Parameters["Scatterplot"]; }
    4242    }
    4343
     
    5151    public ScatterPlotAnalyzer() {
    5252      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem"));
    53       Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)"));
     53      Parameters.Add(new ResultParameter<ParetoFrontScatterPlot<RealVector>>("Scatterplot", "The scatterplot for the current and optimal (if known front)"));
    5454    }
    5555
     
    5858      var individuals = IndividualsParameter.ActualValue;
    5959      var testFunction = TestFunctionParameter.ActualValue;
    60       var objectives = qualities.Length != 0 ? qualities[0].Length:0;   
    61       var problemSize = individuals.Length != 0 ? individuals[0].Length:0;
     60      var objectives = qualities.Length != 0 ? qualities[0].Length:0;
    6261
    6362      var optimalFront = new double[0][];               
     
    7170      }
    7271
    73       var qualityClones = qualities.Select(s => s.ToArray()).ToArray();
    74       var solutionClones = individuals.Select(s => s.ToArray()).ToArray();
    75 
    76       ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize);
     72      var fronts = DominationCalculator.CalculateAllParetoFronts(individuals.ToArray(), qualities.Select(x => x.ToArray()).ToArray(), testFunction.Maximization(objectives), out var rank);
     73     
     74      ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot<RealVector>(
     75        fronts.Select(x => x.Select(y => y.Item2).ToArray()).ToArray(),
     76        fronts.Select(x => x.Select(y => y.Item1).ToArray()).ToArray(),
     77        optimalFront, objectives);
    7778      return base.Apply();
    7879    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj

    r17225 r17229  
    111111    <Compile Include="Calculators\InvertedGenerationalDistance.cs" />
    112112    <Compile Include="Calculators\GenerationalDistance.cs" />
    113     <Compile Include="ParetoFrontScatterPlot.cs" />
    114113    <Compile Include="Utilities.cs" />
    115114    <Compile Include="Instances\MISCInstanceProvider.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.Views/3.3/HeuristicLab.Problems.TestFunctions.Views-3.3.csproj

    r16723 r17229  
    107107  </ItemGroup>
    108108  <ItemGroup>
    109     <Compile Include="ParetoFrontScatterPlotView.cs">
    110       <SubType>UserControl</SubType>
    111     </Compile>
    112     <Compile Include="ParetoFrontScatterPlotView.Designer.cs">
    113       <DependentUpon>ParetoFrontScatterPlotView.cs</DependentUpon>
    114     </Compile>
    115109    <Compile Include="Plugin.cs" />
    116110    <Compile Include="Properties\AssemblyInfo.cs" />
Note: See TracChangeset for help on using the changeset viewer.