Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16310


Ignore:
Timestamp:
11/20/18 14:53:51 (6 years ago)
Author:
bwerth
Message:

#2943 worked on MOBasicProblem and MOAnalyzers

Location:
branches/2943_MOBasicProblem_MOCMAES
Files:
2 deleted
28 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/CrowdingIndicator.cs

    r16171 r16310  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
    27 using HeuristicLab.Encodings.RealVectorEncoding;
    2826using HeuristicLab.Optimization;
    2927using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    30 using HeuristicLab.Problems.TestFunctions.MultiObjective;
    3128
    3229namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs

    r16171 r16310  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
    27 using HeuristicLab.Encodings.RealVectorEncoding;
    2826using HeuristicLab.Optimization;
    2927using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs

    r16171 r16310  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Encodings.RealVectorEncoding;
    2827using HeuristicLab.Optimization;
    2928using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis

  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/DataVisualization/IndexedDataRow.cs

    r15583 r16310  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.ComponentModel;
     25using System.Linq;
    2226using HeuristicLab.Collections;
    2327using HeuristicLab.Common;
    2428using HeuristicLab.Core;
    2529using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using System;
    27 using System.Collections.Generic;
    28 using System.ComponentModel;
    29 using System.Linq;
    3030
    3131namespace HeuristicLab.Analysis {
     
    5858      set { visualProperties = value; }
    5959    }
    60     [Storable(Name = "values")]
     60    // BackwardsCompatibility3.3
     61    #region Backwards compatible code, remove with 3.4
     62    // tuples are stored inefficiently
     63    [Storable(Name = "values", AllowOneWay = true)]
    6164    private IEnumerable<Tuple<T, double>> StorableValues {
    62       get { return values; }
    6365      set { values = new ObservableList<Tuple<T, double>>(value); }
     66    }
     67    #endregion
     68    private T[] storableX;
     69    [Storable(Name = "x")]
     70    private T[] StorableX {
     71      get { return Values.Select(x => x.Item1).ToArray(); }
     72      set { storableX = value; }
     73    }
     74    private double[] storableY;
     75    [Storable(Name = "y")]
     76    private double[] StorableY {
     77      get { return Values.Select(x => x.Item2).ToArray(); }
     78      set { storableY = value; }
    6479    }
    6580    #endregion
     
    109124      VisualProperties.DisplayName = Name;
    110125    }
     126
     127    [StorableHook(HookType.AfterDeserialization)]
     128    private void AfterDeserialization() {
     129      if (storableX != null && storableY != null) {
     130        values = new ObservableList<Tuple<T, double>>(storableX.Zip(storableY, (x, y) => Tuple.Create(x, y)));
     131        storableX = null;
     132        storableY = null;
     133      } else if (values == null) throw new InvalidOperationException("Deserialization problem with IndexedDataRow.");
     134    }
    111135  }
    112136}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj

    r16171 r16310  
    175175    <Compile Include="DataVisualization\ScatterPlot.cs" />
    176176    <Compile Include="MultidimensionalScaling\MultidimensionalScaling.cs" />
     177    <Compile Include="MultiObjective\CrowdingAnalyzer.cs" />
     178    <Compile Include="MultiObjective\GenerationalDistanceAnalyzer.cs" />
     179    <Compile Include="MultiObjective\HypervolumeAnalyzer.cs" />
     180    <Compile Include="MultiObjective\InvertedGenerationalDistanceAnalyzer.cs" />
     181    <Compile Include="MultiObjective\MultiObjectiveSuccessAnalyzer.cs" />
    177182    <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" />
    178183    <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" />
     184    <Compile Include="MultiObjective\TimelineAnalyzer.cs" />
     185    <Compile Include="MultiObjective\SpacingAnalyzer.cs" />
    179186    <Compile Include="Plugin.cs" />
    180187    <Compile Include="PopulationSimilarityAnalysis\PopulationDiversityAnalyzer.cs" />
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/CrowdingAnalyzer.cs

    r16303 r16310  
    2020#endregion
    2121
    22 using System.Linq;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
    2524using HeuristicLab.Data;
    2625using HeuristicLab.Optimization;
    27 using HeuristicLab.Parameters;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927
    30 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     28namespace HeuristicLab.Analysis {
    3129  [StorableClass]
    3230  [Item("CrowdingAnalyzer", "The mean crowding distance for each point of the Front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    33   public class CrowdingAnalyzer : MOTFAnalyzer {
    34 
    35     public IResultParameter<DoubleValue> CrowdingResultParameter {
    36       get { return (IResultParameter<DoubleValue>)Parameters["Crowding"]; }
    37     }
     31  public class CrowdingAnalyzer : MultiObjectiveSuccessAnalyzer {
     32    public override string ResultName => "Crowding";
    3833
    3934    [StorableConstructor]
     
    4742
    4843    public CrowdingAnalyzer() {
    49       Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding distance of all points (excluding infinities)"));
    50       CrowdingResultParameter.DefaultValue = new DoubleValue(double.NaN);
     44      Parameters.Add(new ResultParameter<DoubleValue>("Crowding", "The average corwding distance of all points (excluding infinities)", "Results", new DoubleValue(double.NaN)));
    5145    }
    5246
     
    5448      var qualities = QualitiesParameter.ActualValue;
    5549      var crowdingDistance = CrowdingCalculator.CalculateCrowding(qualities);
    56       CrowdingResultParameter.ActualValue.Value = crowdingDistance;
     50      ResultParameter.ActualValue.Value = crowdingDistance;
    5751      return base.Apply();
    5852    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/GenerationalDistanceAnalyzer.cs

    r16303 r16310  
    2020#endregion
    2121
    22 using System;
     22using System.Collections.Generic;
    2323using System.Linq;
    2424using HeuristicLab.Common;
     
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     31namespace HeuristicLab.Analysis {
    3232  [StorableClass]
    33   [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    34   public class GenerationalDistanceAnalyzer : MOTFAnalyzer {
     33  [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the optimal front (if known)(see Multi-Objective Performance Metrics - Shodhganga for more information). The calculation of generational distance requires a known optimal pareto front")]
     34  public class GenerationalDistanceAnalyzer : MultiObjectiveSuccessAnalyzer {
     35    public override string ResultName => "Generational Distance";
    3536
    36     private IFixedValueParameter<DoubleValue> DampeningParameter {
    37       get { return (IFixedValueParameter<DoubleValue>)Parameters["Dampening"]; }
    38       set { Parameters["Dampening"].ActualValue = value; }
     37    public IFixedValueParameter<DoubleValue> DampeningParameter => (IFixedValueParameter<DoubleValue>)Parameters["Dampening"];
     38
     39    public double Dampening {
     40      get => DampeningParameter.Value.Value;
     41      set => DampeningParameter.Value.Value = value;
    3942    }
    4043
    41     public double Dampening {
    42       get { return DampeningParameter.Value.Value; }
    43       set { DampeningParameter.Value.Value = value; }
    44     }
     44    public ILookupParameter<DoubleMatrix> OptimalParetoFrontParameter => (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"];
    4545
    46     public IResultParameter<DoubleValue> GenerationalDistanceResultParameter {
    47       get { return (IResultParameter<DoubleValue>)Parameters["Generational Distance"]; }
    48     }
    4946
    5047    [StorableConstructor]
     
    5754    public GenerationalDistanceAnalyzer() {
    5855      Parameters.Add(new FixedValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
    59       Parameters.Add(new ResultParameter<DoubleValue>("Generational Distance", "The genrational distance between the current front and the optimal front"));
    60       GenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
    61 
     56      Parameters.Add(new LookupParameter<ItemArray<DoubleArray>>("OptimalParetoFront", "The analytically best known Pareto front"));
     57      Parameters.Add(new ResultParameter<DoubleValue>(ResultName, "The generational distance between the current front and the optimal front", "Results", new DoubleValue(double.NaN)));
    6258    }
    6359
    6460    public override IOperation Apply() {
    6561      var qualities = QualitiesParameter.ActualValue;
    66       var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    67       if (optimalfront == null) return base.Apply();
    68       GenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistanceCalculator.CalculateGenerationalDistance(qualities, optimalfront, Dampening);
     62      var optimalFront = OptimalParetoFrontParameter.ActualValue;
     63      if (optimalFront == null) return base.Apply();
     64      var front = Enumerable.Range(0, optimalFront.Rows).Select(r => Enumerable.Range(0, optimalFront.Columns).Select(c => optimalFront[r, c]).ToList()).ToList();
     65      ResultParameter.ActualValue.Value = CalculateDistance(qualities,front);
    6966      return base.Apply();
     67    }
     68
     69    protected virtual double CalculateDistance(ItemArray<DoubleArray> qualities, IList<List<double>> optimalFront) {
     70      return GenerationalDistanceCalculator.CalculateGenerationalDistance(qualities, optimalFront, Dampening);
    7071    }
    7172  }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/HypervolumeAnalyzer.cs

    r16303 r16310  
    3030using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3131
    32 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     32namespace HeuristicLab.Analysis {
    3333  [StorableClass]
    3434  [Item("HypervolumeAnalyzer", "Computes the enclosed Hypervolume between the current front and a given reference Point")]
    35   public class HypervolumeAnalyzer : MOTFAnalyzer {
     35  public class HypervolumeAnalyzer : MultiObjectiveSuccessAnalyzer {
     36    public override string ResultName => "Hypervolume";
    3637
    37     public ILookupParameter<DoubleArray> ReferencePointParameter {
    38       get { return (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    39     }
    40     public IResultParameter<DoubleValue> HypervolumeResultParameter {
    41       get { return (IResultParameter<DoubleValue>)Parameters["Hypervolume"]; }
    42     }
    43     public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter {
    44       get { return (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"]; }
    45     }
    46     public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter {
    47       get { return (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"]; }
    48     }
     38    public ILookupParameter<DoubleArray> ReferencePointParameter => (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"];
     39
     40    public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter => (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"];
     41
     42    public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"];
    4943
    5044
    5145    [StorableConstructor]
    52     protected HypervolumeAnalyzer(bool deserializing)
    53       : base(deserializing) {
    54     }
     46    protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) {}
    5547
    56     protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner)
    57       : base(original, cloner) {
    58     }
     48    protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {}
     49
    5950    public override IDeepCloneable Clone(Cloner cloner) {
    6051      return new HypervolumeAnalyzer(this, cloner);
     
    6354    public HypervolumeAnalyzer() {
    6455      Parameters.Add(new LookupParameter<DoubleArray>("ReferencePoint", "The reference point for hypervolume calculation"));
    65       Parameters.Add(new ResultParameter<DoubleValue>("Hypervolume", "The hypervolume of the current generation"));
     56      Parameters.Add(new ResultParameter<DoubleValue>("Hypervolume", "The hypervolume of the current generation", "Results", new DoubleValue(double.NaN)));
    6657      Parameters.Add(new ResultParameter<DoubleValue>("Best known hypervolume", "The optimal hypervolume"));
    6758      Parameters.Add(new ResultParameter<DoubleValue>("Absolute Distance to BestKnownHypervolume", "The difference between the best known and the current hypervolume"));
    68       HypervolumeResultParameter.DefaultValue = new DoubleValue(0);
    69       BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(0);
    70       HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(0);
    71 
    72 
     59      BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(double.NaN);
     60      HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
    7361    }
    7462
    7563    public override IOperation Apply() {
    76       var qualities = QualitiesParameter.ActualValue;
    77       var testFunction = TestFunctionParameter.ActualValue;
    78       var objectives = qualities[0].Length;
    79       var referencePoint = ReferencePointParameter.ActualValue;
     64      var qualities = QualitiesParameter.ActualValue.Select(x => x.CloneAsArray()).ToArray();
     65      var referencePoint = ReferencePointParameter.ActualValue.ToArray();
     66      var best = BestKnownHypervolumeResultParameter.ActualValue.Value;
     67      var maximization = MaximizationParameter.ActualValue.ToArray();
    8068
    81       var best = BestKnownHypervolumeResultParameter.ActualValue.Value;
    82       if (referencePoint.SequenceEqual(testFunction.ReferencePoint(objectives))) {
    83         best = Math.Max(best, testFunction.OptimalHypervolume(objectives));
    84       }
    85 
    86       var hv = HypervolumeCalculator.CalculateHypervolume(qualities.Select(x=>x.CloneAsArray()).ToArray(), referencePoint.ToArray(), testFunction.Maximization(objectives));
    87 
    88       if (hv > best) {
    89         best = hv;
    90       }
    91 
    92       HypervolumeResultParameter.ActualValue.Value = hv;
     69      var hv = HypervolumeCalculator.CalculateHypervolume(qualities, referencePoint, maximization);
     70      if (hv > best || double.IsNaN(best)) best = hv;
     71      ResultParameter.ActualValue.Value = hv;
    9372      BestKnownHypervolumeResultParameter.ActualValue.Value = best;
    9473      HypervolumeDistanceResultParameter.ActualValue.Value = best - hv;
     
    9675      return base.Apply();
    9776    }
    98 
    9977  }
    10078}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/InvertedGenerationalDistanceAnalyzer.cs

    r16303 r16310  
    2020#endregion
    2121
    22 using System.Linq;
     22using System.Collections.Generic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     30namespace HeuristicLab.Analysis {
    3131  [StorableClass]
    3232  [Item("InvertedGenerationalDistanceAnalyzer", "The inverted generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    33   public class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer {
    34     public override bool EnabledByDefault { get { return false; } }
     33  public class InvertedGenerationalDistanceAnalyzer : GenerationalDistanceAnalyzer {
     34    public override bool EnabledByDefault => false;
     35    public override string ResultName => "Inverted Generational Distance";
    3536
    36     private IFixedValueParameter<DoubleValue> DampeningParameter {
    37       get { return (IFixedValueParameter<DoubleValue>)Parameters["Dampening"]; }
    38     }
    39 
    40     public double Dampening {
    41       get { return DampeningParameter.Value.Value; }
    42       set { DampeningParameter.Value.Value = value; }
    43     }
    44 
    45     public IResultParameter<DoubleValue> InvertedGenerationalDistanceResultParameter {
    46       get { return (IResultParameter<DoubleValue>)Parameters["Inverted Generational Distance"]; }
    47     }
     37    public IResultParameter<DoubleValue> InvertedGenerationalDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Inverted Generational Distance"];
    4838
    4939    [StorableConstructor]
     
    5444    }
    5545
    56     public InvertedGenerationalDistanceAnalyzer() {
    57       Parameters.Add(new FixedValueParameter<DoubleValue>("Dampening", "", new DoubleValue(1)));
    58       Parameters.Add(new ResultParameter<DoubleValue>("Inverted Generational Distance", "The genrational distance between the current front and the optimal front"));
    59       InvertedGenerationalDistanceResultParameter.DefaultValue = new DoubleValue(double.NaN);
     46    public InvertedGenerationalDistanceAnalyzer() { }
     47
     48    protected override double CalculateDistance(ItemArray<DoubleArray> qualities, IList<List<double>> optimalFront) {
     49      return GenerationalDistanceCalculator.CalculateGenerationalDistance(optimalFront, qualities, Dampening);
    6050    }
    6151
    62     public override IOperation Apply() {
    63       var qualities = QualitiesParameter.ActualValue;
    64       var optimalfront = TestFunctionParameter.ActualValue.OptimalParetoFront(qualities[0].Length);
    65       if (optimalfront == null) return base.Apply();
    66       InvertedGenerationalDistanceResultParameter.ActualValue.Value = GenerationalDistanceCalculator.CalculateInverseGenerationalDistance(qualities, optimalfront, Dampening);
    67       return base.Apply();
    68     }
    6952  }
    7053}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/MultiObjectiveSuccessAnalyzer.cs

    r16303 r16310  
    2929
    3030
    31 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     31namespace HeuristicLab.Analysis {
    3232
    3333  [StorableClass]
    34   public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    35     public virtual bool EnabledByDefault { get { return true; } }
     34  public abstract class MultiObjectiveSuccessAnalyzer : SingleSuccessorOperator, IAnalyzer, IMultiObjectiveOperator {
     35    public virtual bool EnabledByDefault => true;
     36    public abstract string ResultName { get; }
    3637
    37     public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
    38       get { return (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; }
    39     }
     38    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter => (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"];
    4039
    41     public ILookupParameter<ResultCollection> ResultsParameter {
    42       get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
    43     }
     40    public ILookupParameter<BoolArray> MaximizationParameter => (ILookupParameter<BoolArray>)Parameters["Maximization"];
    4441
    45     public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter {
    46       get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    47     }
     42    public ResultParameter<DoubleValue> ResultParameter => (ResultParameter<DoubleValue>)Parameters[ResultName];
    4843
    49     public ILookupParameter<DoubleMatrix> BestKnownFrontParameter {
    50       get { return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; }
    51     }
    52 
    53     protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { }
    54 
     44    protected MultiObjectiveSuccessAnalyzer(MultiObjectiveSuccessAnalyzer original, Cloner cloner) : base(original, cloner) { }
    5545    [StorableConstructor]
    56     protected MOTFAnalyzer(bool deserializing) : base(deserializing) { }
    57     protected MOTFAnalyzer() {
     46    protected MultiObjectiveSuccessAnalyzer(bool deserializing) : base(deserializing) { }
     47    protected MultiObjectiveSuccessAnalyzer() {
    5848      Parameters.Add(new ScopeTreeLookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector."));
    59       Parameters.Add(new LookupParameter<ResultCollection>("Results", "The results collection to write to."));
    60       Parameters.Add(new LookupParameter<IMultiObjectiveTestFunction>("TestFunction", "The Testfunction that is analyzed"));
    6149      Parameters.Add(new LookupParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front"));
     50      Parameters.Add(new LookupParameter<BoolArray>("Maximization", ""));
    6251    }
    6352  }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/SpacingAnalyzer.cs

    r16303 r16310  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     29namespace HeuristicLab.Analysis {
    3030  [StorableClass]
    3131  [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    32   public class SpacingAnalyzer : MOTFAnalyzer {
     32  public class SpacingAnalyzer : MultiObjectiveSuccessAnalyzer {
     33    public override string ResultName => "Spacing";
    3334
    34     public IResultParameter<DoubleValue> SpacingResultParameter {
    35       get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }
    36     }
    3735    [StorableConstructor]
    3836    protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }
     
    4543
    4644    public SpacingAnalyzer() {
    47       Parameters.Add(new ResultParameter<DoubleValue>("Spacing", "The spacing of the current front"));
    48       SpacingResultParameter.DefaultValue = new DoubleValue(double.NaN);
     45      Parameters.Add(new ResultParameter<DoubleValue>("Spacing", "The spacing of the current front", "Results", new DoubleValue(double.NaN)));
    4946    }
    5047
    5148    public override IOperation Apply() {
    5249      var qualities = QualitiesParameter.ActualValue;
    53       SpacingResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities);
     50      ResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities);
    5451      return base.Apply();
    5552    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/TimelineAnalyzer.cs

    r16303 r16310  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
     27using HeuristicLab.Operators;
    2628using HeuristicLab.Optimization;
     29using HeuristicLab.Parameters;
    2730using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2831
    29 namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
     32namespace HeuristicLab.Analysis {
    3033  [StorableClass]
    31   [Item("SpacingAnalyzer", "The spacing of the current front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
    32   public class SpacingAnalyzer : MOTFAnalyzer {
     34  [Item("TimelineAnalyzer", "Collects the specified double values from the results and displays them as a timeline")]
     35  public class TimelineAnalyzer : SingleSuccessorOperator, IAnalyzer, IMultiObjectiveOperator {
     36    public bool EnabledByDefault => true;
     37    public string ResultName => "Timeline";
    3338
    34     public IResultParameter<DoubleValue> SpacingResultParameter {
    35       get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }
    36     }
     39    public IFixedValueParameter<CheckedItemList<StringValue>> CollectedSuccessMeasuresParameter =>
     40      (IFixedValueParameter<CheckedItemList<StringValue>>)Parameters["CollectedSuccessMeasures"];
     41
     42    public ILookupParameter<ResultCollection> ResultsParameter => (ILookupParameter<ResultCollection>)Parameters["Results"];
     43
     44    public ResultParameter<DataTable> ResultParameter => (ResultParameter<DataTable>)Parameters[ResultName];
     45
     46    public CheckedItemList<StringValue> CollectedSuccessMeasures => CollectedSuccessMeasuresParameter.Value;
     47
    3748    [StorableConstructor]
    38     protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }
     49    protected TimelineAnalyzer(bool deserializing) : base(deserializing) { }
    3950
    4051
    41     protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }
     52    protected TimelineAnalyzer(TimelineAnalyzer original, Cloner cloner) : base(original, cloner) { }
    4253    public override IDeepCloneable Clone(Cloner cloner) {
    43       return new SpacingAnalyzer(this, cloner);
     54      return new TimelineAnalyzer(this, cloner);
    4455    }
    4556
    46     public SpacingAnalyzer() {
    47       Parameters.Add(new ResultParameter<DoubleValue>("Spacing", "The spacing of the current front"));
    48       SpacingResultParameter.DefaultValue = new DoubleValue(double.NaN);
     57    public TimelineAnalyzer() {
     58      var names = new List<string> {
     59        new CrowdingAnalyzer().ResultName,
     60        new GenerationalDistanceAnalyzer().ResultName,
     61        new InvertedGenerationalDistanceAnalyzer().ResultName,
     62        new HypervolumeAnalyzer().ResultName,
     63        new SpacingAnalyzer().ResultName
     64      };
     65      var analyzers = new CheckedItemList<StringValue> (names.Select(n=> new StringValue(n)));
     66      Parameters.Add(new FixedValueParameter<CheckedItemList<StringValue>>("CollectedSuccessMeasures",analyzers));
     67      Parameters.Add(new LookupParameter<ResultCollection>("Results"));
     68      Parameters.Add(new ResultParameter<DataTable>("Timeline", "The development of the success measures over the generations","Results", new DataTable("Timeline","")));
    4969    }
    5070
    5171    public override IOperation Apply() {
    52       var qualities = QualitiesParameter.ActualValue;
    53       SpacingResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities);
     72      if (ResultParameter.ActualValue == null) ResultParameter.ActualValue = new DataTable(ResultName,"");
     73      var plot = ResultParameter.ActualValue;
     74      var resultCollection = ResultsParameter.ActualValue;
     75      foreach (var resultName in CollectedSuccessMeasures.CheckedItems.Select(i=>i.Value.Value)) {
     76        if(!resultCollection.ContainsKey(resultName)) continue;
     77        if(!(resultCollection[resultName].Value is DoubleValue res)) continue;
     78        if(!plot.Rows.ContainsKey(resultName)) plot.Rows.Add(new DataRow(resultName));
     79        plot.Rows[resultName].Values.Add(res.Value);
     80      }
    5481      return base.Apply();
    5582    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data

  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3

  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/StringMatrix.cs

    r15583 r16310  
    209209    }
    210210
     211    public string[,] CloneAsMatrix() {
     212      return (string[,])matrix.Clone();
     213    }
     214
     215    public virtual IEnumerable<string> GetRow(int row) {
     216      for (var col = 0; col < Columns; col++) {
     217        yield return matrix[row, col];
     218      }
     219    }
     220
     221    public virtual IEnumerable<string> GetColumn(int col) {
     222      for (var row = 0; row < Rows; row++) {
     223        yield return matrix[row, col];
     224      }
     225    }
     226
    211227    public override string ToString() {
    212228      if (matrix.Length == 0) return "[]";
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization

  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization.Operators

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs

    r16171 r16310  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    2523using HeuristicLab.Common;
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs

    r15583 r16310  
    188188          TimeSpan.FromSeconds(15) });
    189189      snapshotTimesIndex = 0;
     190      snapshots = new RunCollection();
    190191      Runs = new RunCollection { OptimizerName = Name };
    191192      Initialize();
     
    199200          TimeSpan.FromSeconds(15) });
    200201      snapshotTimesIndex = 0;
     202      snapshots = new RunCollection();
    201203      Runs = new RunCollection { OptimizerName = Name };
    202204      Initialize();
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/CrowdingCalculator.cs

    r16171 r16310  
    3535  /// Beware that CrowdingCalculator is not normalized for the number of dimensions. A higher number of dimensions normally causes higher CrowdingCalculator values
    3636  /// </summary>
    37   public static class CrowdingCalculator
    38   {
     37  public static class CrowdingCalculator {
    3938
    4039    public static double CalculateCrowding<TP>(IEnumerable<TP> qualities) where TP : IReadOnlyList<double> {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/GenerationalDistanceCalculator.cs

    r16171 r16310  
    2323
    2424#region
    25 
    2625using System;
    2726using System.Collections.Generic;
    2827using System.Linq;
    2928using HeuristicLab.Common;
    30 
    3129#endregion
    3230
     
    4038  public static class GenerationalDistanceCalculator {
    4139    public static double CalculateGenerationalDistance<TP1, TP2>(IEnumerable<TP1> qualities, IEnumerable<TP2> bestKnownFront, double p) where TP1 : IReadOnlyList<double> where TP2 : IReadOnlyList<double> {
    42       if (qualities == null || bestKnownFront == null) throw new ArgumentNullException("Fronts must not be null");
     40      if (qualities == null || bestKnownFront == null) throw new ArgumentNullException(nameof(qualities));
    4341      if (p.IsAlmost(0.0)) throw new ArgumentException("p must not be zero.");
    4442      var mat = bestKnownFront.ToMatrix();
    4543      if (mat.GetLength(0) == 0) throw new ArgumentException("Fronts must not be empty.");
    4644
    47       alglib.kdtree tree;
    48       alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree);
     45      alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree);
    4946      var sum = 0.0;
    5047      var summand = new double[1];
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/HypervolumeCalculator.cs

    r16171 r16310  
    2323using System.Linq;
    2424using HeuristicLab.Common;
    25 using HeuristicLab.Optimization;
    2625
    2726namespace HeuristicLab.Optimization {
     
    6463    public static double CalculateHypervolume(double[][] qualities, double[] referencePoint, bool[] maximization){
    6564      qualities = qualities.Where(vec => DominationCalculator.Dominates(vec, referencePoint, maximization, false) == DominationResult.Dominates).ToArray();
    66       if (!qualities.Any()) return 0;//TODO replace with negative computation
     65      if (qualities.Length == 0 ) return 0;//TODO computation for negative hypervolume?
    6766      if (maximization.Length == 2)
    6867        return Calculate2D(qualities, referencePoint, maximization);
     
    7372    }
    7473
     74
     75    /// <summary>
     76    /// Caluclates the Hypervolume for a 2 dimensional problem
     77    /// </summary>
     78    /// <param name="front">All points within the front need to be Non-Dominated and need to dominate the reference point</param>
     79    /// <param name="referencePoint"></param>
     80    /// <param name="maximization"></param>
     81    /// <returns></returns>
    7582    public static double Calculate2D(double[][] front, double[] referencePoint, bool[] maximization) {
    76       if (front == null) throw new ArgumentNullException("Front must not be null.");
     83      if (front == null) throw new ArgumentNullException(nameof(front));
     84      if (referencePoint == null) throw new ArgumentNullException(nameof(referencePoint));
     85      if (maximization == null) throw new ArgumentNullException(nameof(maximization));
    7786      if (!front.Any()) throw new ArgumentException("Front must not be empty.");
    78 
    79       if (referencePoint == null) throw new ArgumentNullException("ReferencePoint must not be null.");
    8087      if (referencePoint.Length != 2) throw new ArgumentException("ReferencePoint must have exactly two dimensions.");
    8188
     
    8794      double sum = 0;
    8895      for (var i = 0; i < set.Length - 1; i++)
    89         sum += Math.Abs((set[i][0] - set[i + 1][0])) * Math.Abs((set[i][1] - referencePoint[1]));
    90      
     96        sum += Math.Abs(set[i][0] - set[i + 1][0]) * Math.Abs(set[i][1] - referencePoint[1]);
    9197      var lastPoint = set[set.Length - 1];
    9298      sum += Math.Abs(lastPoint[0] - referencePoint[0]) * Math.Abs(lastPoint[1] - referencePoint[1]);
     
    112118    }
    113119
     120
     121    //within Stream a number of equality comparisons on double values are performed
     122    //this is intentional and required
    114123    private static double Stream(double[] regionLow, double[] regionUp, List<double[]> front, int split, double cover, int sqrtNoPoints, int objectives) {
    115124      var coverOld = cover;
     
    135144      var piles = new int[coverIndex];
    136145      for (var i = 0; i < coverIndex; i++) {
    137         piles[i] = IsPile(front[i], regionLow, regionUp, objectives);
     146        piles[i] = IsPile(front[i], regionLow, objectives);
    138147        if (piles[i] == -1) {
    139148          allPiles = false;
     
    145154        var trellis = new double[regionUp.Length];
    146155        for (var j = 0; j < trellis.Length; j++) trellis[j] = regionUp[j];
    147         double current = 0;
    148         double next = 0;
     156        double next;
    149157        var i = 0;
    150158        do {
    151           current = front[i][objectives - 1];
     159          var current = front[i][objectives - 1];
    152160          do {
    153161            if (front[i][piles[i]] < trellis[piles[i]]) trellis[piles[i]] = front[i][piles[i]];
     
    176184        } while (bound == -1.0);
    177185
    178         List<double[]> pointsChildLow, pointsChildUp;
    179         pointsChildLow = new List<double[]>();
    180         pointsChildUp = new List<double[]>();
     186        var pointsChildLow = new List<double[]>();
     187        var pointsChildUp = new List<double[]>();
    181188        var regionUpC = new double[regionUp.Length];
    182189        for (var j = 0; j < regionUpC.Length; j++) regionUpC[j] = regionUp[j];
     
    205212      double result = 0;
    206213      var noSummands = BinarayToInt(bs);
    207       int oneCounter; double summand;
    208214      for (uint i = 1; i <= noSummands; i++) {
    209         summand = 1;
     215        double summand = 1;
    210216        IntToBinary(i, bs);
    211         oneCounter = 0;
     217        var oneCounter = 0;
    212218        for (var j = 0; j < objectives - 1; j++) {
    213219          if (bs[j]) {
     
    244250    }
    245251
    246     private static int IsPile(double[] cuboid, double[] regionLow, double[] regionUp, int objectives) {
     252    private static int IsPile(double[] cuboid, double[] regionLow, int objectives) {
    247253      var pile = cuboid.Length;
    248254      for (var i = 0; i < objectives - 1; i++) {
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/SpacingCalculator.cs

    r16171 r16310  
    3434
    3535    public static double CalculateSpacing<TP>(IEnumerable<TP> qualities) where TP: IReadOnlyList<double> {
    36       if (qualities == null) throw new ArgumentException("Front must not be null.");
     36      if (qualities == null) throw new ArgumentNullException(nameof(qualities));
    3737      var l = qualities.ToList();
    3838      if (l.Count == 0) throw new ArgumentException("Front must not be empty.");
     
    4040
    4141      var mat = l.ToMatrix();
    42       alglib.kdtree tree;
    43       alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out tree);
     42      alglib.kdtreebuild(mat, mat.GetLength(0), mat.GetLength(1), 0, 2, out var tree);
    4443      var summand = new double[2];
    4544      var dists = new List<double>();
     
    5150      return dists.StandardDeviationPop();
    5251    }
    53 
    54    
    5552  }
    5653}
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/CrowdingAnalyzer.cs

    r16171 r16310  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableClass]
    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 {
    3434
    35     public IResultParameter<DoubleValue> CrowdingResultParameter {
    36       get { return (IResultParameter<DoubleValue>)Parameters["Crowding"]; }
    37     }
     35    public IResultParameter<DoubleValue> CrowdingResultParameter => (IResultParameter<DoubleValue>)Parameters["Crowding"];
    3836
    3937    [StorableConstructor]
    4038    protected CrowdingAnalyzer(bool deserializing) : base(deserializing) { }
    41     public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner)
    42       : base(original, cloner) {
    43     }
     39    public CrowdingAnalyzer(CrowdingAnalyzer original, Cloner cloner): base(original, cloner) {}
    4440    public override IDeepCloneable Clone(Cloner cloner) {
    4541      return new CrowdingAnalyzer(this, cloner);
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs

    r16171 r16310  
    3131namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3232  [StorableClass]
    33   [Item("GenerationalDistanceAnalyzer", "The generational distance between the current and the best known front (see Multi-Objective Performance Metrics - Shodhganga for more information)")]
     33  [Item("GenerationalDistanceAnalyzer", "This analyzer is functionally equivalent to the GenerationalDistanceAnalyzer in HeuristicLab.Analysis, but is kept as not to break backwards compatibility")]
    3434  public class GenerationalDistanceAnalyzer : MOTFAnalyzer {
    3535
    3636    private IFixedValueParameter<DoubleValue> DampeningParameter {
    37       get { return (IFixedValueParameter<DoubleValue>)Parameters["Dampening"]; }
    38       set { Parameters["Dampening"].ActualValue = value; }
     37      get => (IFixedValueParameter<DoubleValue>)Parameters["Dampening"];
     38      set => Parameters["Dampening"].ActualValue = value;
    3939    }
    4040
    4141    public double Dampening {
    42       get { return DampeningParameter.Value.Value; }
    43       set { DampeningParameter.Value.Value = value; }
     42      get => DampeningParameter.Value.Value;
     43      set => DampeningParameter.Value.Value = value;
    4444    }
    4545
    46     public IResultParameter<DoubleValue> GenerationalDistanceResultParameter {
    47       get { return (IResultParameter<DoubleValue>)Parameters["Generational Distance"]; }
    48     }
     46    public IResultParameter<DoubleValue> GenerationalDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Generational Distance"];
    4947
    5048    [StorableConstructor]
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs

    r16171 r16310  
    3232namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3333  [StorableClass]
    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
    37     public ILookupParameter<DoubleArray> ReferencePointParameter {
    38       get { return (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"]; }
    39     }
    40     public IResultParameter<DoubleValue> HypervolumeResultParameter {
    41       get { return (IResultParameter<DoubleValue>)Parameters["Hypervolume"]; }
    42     }
    43     public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter {
    44       get { return (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"]; }
    45     }
    46     public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter {
    47       get { return (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"]; }
    48     }
     37    public ILookupParameter<DoubleArray> ReferencePointParameter => (ILookupParameter<DoubleArray>)Parameters["ReferencePoint"];
     38
     39    public IResultParameter<DoubleValue> HypervolumeResultParameter => (IResultParameter<DoubleValue>)Parameters["Hypervolume"];
     40
     41    public IResultParameter<DoubleValue> BestKnownHypervolumeResultParameter => (IResultParameter<DoubleValue>)Parameters["Best known hypervolume"];
     42
     43    public IResultParameter<DoubleValue> HypervolumeDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Absolute Distance to BestKnownHypervolume"];
    4944
    5045
    5146    [StorableConstructor]
    52     protected HypervolumeAnalyzer(bool deserializing)
    53       : base(deserializing) {
    54     }
     47    protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) {}
    5548
    56     protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner)
    57       : base(original, cloner) {
    58     }
     49    protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {}
     50
    5951    public override IDeepCloneable Clone(Cloner cloner) {
    6052      return new HypervolumeAnalyzer(this, cloner);
     
    6961      BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(0);
    7062      HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(0);
    71 
    72 
    7363    }
    7464
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs

    r16171 r16310  
    3030namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3131  [StorableClass]
    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 => false;
    3535
    36     private IFixedValueParameter<DoubleValue> DampeningParameter {
    37       get { return (IFixedValueParameter<DoubleValue>)Parameters["Dampening"]; }
     36    private IFixedValueParameter<DoubleValue> DampeningParameter => (IFixedValueParameter<DoubleValue>)Parameters["Dampening"];
     37
     38    public double Dampening {
     39      get => DampeningParameter.Value.Value;
     40      set => DampeningParameter.Value.Value = value;
    3841    }
    3942
    40     public double Dampening {
    41       get { return DampeningParameter.Value.Value; }
    42       set { DampeningParameter.Value.Value = value; }
    43     }
    44 
    45     public IResultParameter<DoubleValue> InvertedGenerationalDistanceResultParameter {
    46       get { return (IResultParameter<DoubleValue>)Parameters["Inverted Generational Distance"]; }
    47     }
     43    public IResultParameter<DoubleValue> InvertedGenerationalDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Inverted Generational Distance"];
    4844
    4945    [StorableConstructor]
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/MOTFAnalyzer.cs

    r15583 r16310  
    3333  [StorableClass]
    3434  public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer {
    35     public virtual bool EnabledByDefault { get { return true; } }
     35    public virtual bool EnabledByDefault => true;
    3636
    37     public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter {
    38       get { return (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; }
    39     }
     37    public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter => (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"];
    4038
    41     public ILookupParameter<ResultCollection> ResultsParameter {
    42       get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
    43     }
     39    public ILookupParameter<ResultCollection> ResultsParameter => (ILookupParameter<ResultCollection>)Parameters["Results"];
    4440
    45     public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter {
    46       get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; }
    47     }
     41    public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter => (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"];
    4842
    49     public ILookupParameter<DoubleMatrix> BestKnownFrontParameter {
    50       get { return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; }
    51     }
     43    public ILookupParameter<DoubleMatrix> BestKnownFrontParameter => (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"];
    5244
    5345    protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs

    r16171 r16310  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Encodings.RealVectorEncoding;
    2627using HeuristicLab.Optimization;
     
    3334  public class ScatterPlotAnalyzer : MOTFAnalyzer {
    3435
    35     public IScopeTreeLookupParameter<RealVector> IndividualsParameter {
    36       get { return (IScopeTreeLookupParameter<RealVector>)Parameters["Individuals"]; }
    37     }
     36    public IScopeTreeLookupParameter<RealVector> IndividualsParameter => (IScopeTreeLookupParameter<RealVector>)Parameters["Individuals"];
    3837
    39     public IResultParameter<ParetoFrontScatterPlot> ScatterPlotResultParameter {
    40       get { return (IResultParameter<ParetoFrontScatterPlot>)Parameters["Scatterplot"]; }
    41     }
    42 
     38    public IResultParameter<ParetoFrontScatterPlot> ScatterPlotResultParameter => (IResultParameter<ParetoFrontScatterPlot>)Parameters["Scatterplot"];
    4339
    4440    [StorableConstructor]
     
    5248      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem"));
    5349      Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)"));
    54 
    5550    }
    5651
     
    5954      var individuals = IndividualsParameter.ActualValue;
    6055      var testFunction = TestFunctionParameter.ActualValue;
    61       var objectives = qualities[0].Length;
    62       var problemSize = individuals[0].Length;
     56      var objectives = qualities.Length != 0 ? qualities[0].Length:0;   
     57      var problemSize = individuals.Length != 0 ? individuals[0].Length:0;
    6358
    64       var optimalFront = new double[0][];
    65       var front = testFunction.OptimalParetoFront(objectives);
    66       if (front != null) optimalFront = front.ToArray();
     59      var optimalFront = new double[0][];               
     60      if (testFunction != null) {
     61        var front = testFunction.OptimalParetoFront(objectives);
     62        if (front != null) optimalFront = front.ToArray();
     63      }
     64      else {
     65        var mat = BestKnownFrontParameter.ActualValue;
     66        optimalFront = mat == null ? null : Enumerable.Range(0, mat.Rows).Select(r => Enumerable.Range(0, mat.Columns).Select(c => mat[r, c]).ToArray()).ToArray();
     67      }
    6768
    6869      var qualityClones = qualities.Select(s => s.ToArray()).ToArray();
     
    7071
    7172      ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize);
    72 
    7373      return base.Apply();
    7474    }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs

    r16171 r16310  
    2929namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
    3030  [StorableClass]
    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
    34     public IResultParameter<DoubleValue> SpacingResultParameter {
    35       get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }
    36     }
     34    public IResultParameter<DoubleValue> SpacingResultParameter => (IResultParameter<DoubleValue>)Parameters["Spacing"];
     35
    3736    [StorableConstructor]
    3837    protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }
    39 
    4038
    4139    protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/HeuristicLab.Problems.TestFunctions.MultiObjective-3.3.csproj

    r16171 r16310  
    146146    <Compile Include="TestFunctions\IHR\IHR2.cs" />
    147147    <Compile Include="TestFunctions\Misc\ELLI1.cs" />
    148     <Compile Include="NonDominatedSelect.cs" />
    149148    <Compile Include="Interfaces\IMultiObjectiveTestFunction.cs" />
    150149    <Compile Include="MultiObjectiveTestFunctionProblem.cs" />
  • branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs

    r16171 r16310  
    3939    #region Parameter Properties
    4040    public new IValueParameter<BoolArray> MaximizationParameter {
    41       get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }
     41      get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; }
    4242    }
    4343    public IFixedValueParameter<IntValue> ProblemSizeParameter {
     
    8686    }
    8787
    88     protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner)
    89       : base(original, cloner) {
     88    protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner) : base(original, cloner) {
    9089      RegisterEventHandlers();
    9190    }
     
    9493    }
    9594
    96     public MultiObjectiveTestFunctionProblem()
    97       : base() {
     95    public MultiObjectiveTestFunctionProblem() : base() {
    9896      Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2)));
    9997      Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2)));
     
    130128    public double[] CheckContraints(RealVector individual) {
    131129      var constrainedTestFunction = (IConstrainedTestFunction)TestFunction;
    132       if (constrainedTestFunction != null) {
    133         return constrainedTestFunction.CheckConstraints(individual, Objectives);
    134       }
    135       return new double[0];
     130      return constrainedTestFunction != null ? constrainedTestFunction.CheckConstraints(individual, Objectives) : new double[0];
    136131    }
    137132
     
    169164      ParameterizeAnalyzers();
    170165    }
     166
    171167    protected override void OnEvaluatorChanged() {
    172168      base.OnEvaluatorChanged();
     
    199195    #region Helpers
    200196    private void InitializeOperators() {
    201       Operators.Add(new CrowdingAnalyzer());
    202       Operators.Add(new GenerationalDistanceAnalyzer());
    203       Operators.Add(new InvertedGenerationalDistanceAnalyzer());
    204       Operators.Add(new HypervolumeAnalyzer());
    205       Operators.Add(new SpacingAnalyzer());
     197      Operators.Add(new Analysis.CrowdingAnalyzer());
     198      Operators.Add(new Analysis.GenerationalDistanceAnalyzer());
     199      Operators.Add(new Analysis.InvertedGenerationalDistanceAnalyzer());
     200      Operators.Add(new Analysis.HypervolumeAnalyzer());
     201      Operators.Add(new Analysis.SpacingAnalyzer());
     202      Operators.Add(new Analysis.TimelineAnalyzer());
    206203      Operators.Add(new ScatterPlotAnalyzer());
    207 
    208       ParameterizeAnalyzers();
    209     }
    210 
    211     private IEnumerable<IMultiObjectiveTestFunctionAnalyzer> Analyzers {
    212       get { return Operators.OfType<IMultiObjectiveTestFunctionAnalyzer>(); }
    213     }
     204      ParameterizeAnalyzers();
     205    }
     206
     207    private IEnumerable<IMultiObjectiveTestFunctionAnalyzer> Analyzers => Operators.OfType<IMultiObjectiveTestFunctionAnalyzer>();
    214208
    215209    private void ParameterizeAnalyzers() {
     
    219213        analyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name;
    220214        analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name;
    221 
    222         var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer;
    223         if (scatterPlotAnalyzer != null) {
     215        if (analyzer is ScatterPlotAnalyzer scatterPlotAnalyzer)
    224216          scatterPlotAnalyzer.IndividualsParameter.ActualName = Encoding.Name;
    225         }
    226217      }
    227218    }
    228 
    229219    #endregion
    230220  }
Note: See TracChangeset for help on using the changeset viewer.