Changeset 16310
- Timestamp:
- 11/20/18 14:53:51 (6 years ago)
- 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 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding;28 26 using HeuristicLab.Optimization; 29 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Problems.TestFunctions.MultiObjective;31 28 32 29 namespace HeuristicLab.Algorithms.MOCMAEvolutionStrategy { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/HypervolumeIndicator.cs
r16171 r16310 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding;28 26 using HeuristicLab.Optimization; 29 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/Indicators/MinimalDistanceIndicator.cs
r16171 r16310 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Encodings.RealVectorEncoding;28 27 using HeuristicLab.Optimization; 29 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis
- Property svn:mergeinfo changed
/branches/2916_IndexedDataTableSerialization/HeuristicLab.Analysis (added) merged: 15918 /trunk/HeuristicLab.Analysis (added) merged: 16177
- Property svn:mergeinfo changed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/DataVisualization/IndexedDataRow.cs
r15583 r16310 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.ComponentModel; 25 using System.Linq; 22 26 using HeuristicLab.Collections; 23 27 using HeuristicLab.Common; 24 28 using HeuristicLab.Core; 25 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using System;27 using System.Collections.Generic;28 using System.ComponentModel;29 using System.Linq;30 30 31 31 namespace HeuristicLab.Analysis { … … 58 58 set { visualProperties = value; } 59 59 } 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)] 61 64 private IEnumerable<Tuple<T, double>> StorableValues { 62 get { return values; }63 65 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; } 64 79 } 65 80 #endregion … … 109 124 VisualProperties.DisplayName = Name; 110 125 } 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 } 111 135 } 112 136 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/HeuristicLab.Analysis-3.3.csproj
r16171 r16310 175 175 <Compile Include="DataVisualization\ScatterPlot.cs" /> 176 176 <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" /> 177 182 <Compile Include="MultiObjective\RankBasedParetoFrontAnalyzer.cs" /> 178 183 <Compile Include="MultiObjective\ParetoFrontAnalyzer.cs" /> 184 <Compile Include="MultiObjective\TimelineAnalyzer.cs" /> 185 <Compile Include="MultiObjective\SpacingAnalyzer.cs" /> 179 186 <Compile Include="Plugin.cs" /> 180 187 <Compile Include="PopulationSimilarityAnalysis\PopulationDiversityAnalyzer.cs" /> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/CrowdingAnalyzer.cs
r16303 r16310 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Data; 26 25 using HeuristicLab.Optimization; 27 using HeuristicLab.Parameters;28 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 27 30 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{28 namespace HeuristicLab.Analysis { 31 29 [StorableClass] 32 30 [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"; 38 33 39 34 [StorableConstructor] … … 47 42 48 43 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))); 51 45 } 52 46 … … 54 48 var qualities = QualitiesParameter.ActualValue; 55 49 var crowdingDistance = CrowdingCalculator.CalculateCrowding(qualities); 56 CrowdingResultParameter.ActualValue.Value = crowdingDistance;50 ResultParameter.ActualValue.Value = crowdingDistance; 57 51 return base.Apply(); 58 52 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/GenerationalDistanceAnalyzer.cs
r16303 r16310 20 20 #endregion 21 21 22 using System ;22 using System.Collections.Generic; 23 23 using System.Linq; 24 24 using HeuristicLab.Common; … … 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 30 31 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{31 namespace HeuristicLab.Analysis { 32 32 [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"; 35 36 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; 39 42 } 40 43 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"]; 45 45 46 public IResultParameter<DoubleValue> GenerationalDistanceResultParameter {47 get { return (IResultParameter<DoubleValue>)Parameters["Generational Distance"]; }48 }49 46 50 47 [StorableConstructor] … … 57 54 public GenerationalDistanceAnalyzer() { 58 55 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))); 62 58 } 63 59 64 60 public override IOperation Apply() { 65 61 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); 69 66 return base.Apply(); 67 } 68 69 protected virtual double CalculateDistance(ItemArray<DoubleArray> qualities, IList<List<double>> optimalFront) { 70 return GenerationalDistanceCalculator.CalculateGenerationalDistance(qualities, optimalFront, Dampening); 70 71 } 71 72 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/HypervolumeAnalyzer.cs
r16303 r16310 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 31 32 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{32 namespace HeuristicLab.Analysis { 33 33 [StorableClass] 34 34 [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"; 36 37 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"]; 49 43 50 44 51 45 [StorableConstructor] 52 protected HypervolumeAnalyzer(bool deserializing) 53 : base(deserializing) { 54 } 46 protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) {} 55 47 56 protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) 57 : base(original, cloner) { 58 } 48 protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {} 49 59 50 public override IDeepCloneable Clone(Cloner cloner) { 60 51 return new HypervolumeAnalyzer(this, cloner); … … 63 54 public HypervolumeAnalyzer() { 64 55 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))); 66 57 Parameters.Add(new ResultParameter<DoubleValue>("Best known hypervolume", "The optimal hypervolume")); 67 58 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); 73 61 } 74 62 75 63 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(); 80 68 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; 93 72 BestKnownHypervolumeResultParameter.ActualValue.Value = best; 94 73 HypervolumeDistanceResultParameter.ActualValue.Value = best - hv; … … 96 75 return base.Apply(); 97 76 } 98 99 77 } 100 78 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/InvertedGenerationalDistanceAnalyzer.cs
r16303 r16310 20 20 #endregion 21 21 22 using System. Linq;22 using System.Collections.Generic; 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; … … 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{30 namespace HeuristicLab.Analysis { 31 31 [StorableClass] 32 32 [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"; 35 36 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"]; 48 38 49 39 [StorableConstructor] … … 54 44 } 55 45 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); 60 50 } 61 51 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 }69 52 } 70 53 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/MultiObjectiveSuccessAnalyzer.cs
r16303 r16310 29 29 30 30 31 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{31 namespace HeuristicLab.Analysis { 32 32 33 33 [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; } 36 37 37 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { 38 get { return (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; } 39 } 38 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter => (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; 40 39 41 public ILookupParameter<ResultCollection> ResultsParameter { 42 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 43 } 40 public ILookupParameter<BoolArray> MaximizationParameter => (ILookupParameter<BoolArray>)Parameters["Maximization"]; 44 41 45 public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter { 46 get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; } 47 } 42 public ResultParameter<DoubleValue> ResultParameter => (ResultParameter<DoubleValue>)Parameters[ResultName]; 48 43 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) { } 55 45 [StorableConstructor] 56 protected M OTFAnalyzer(bool deserializing) : base(deserializing) { }57 protected M OTFAnalyzer() {46 protected MultiObjectiveSuccessAnalyzer(bool deserializing) : base(deserializing) { } 47 protected MultiObjectiveSuccessAnalyzer() { 58 48 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"));61 49 Parameters.Add(new LookupParameter<DoubleMatrix>("BestKnownFront", "The currently best known Pareto front")); 50 Parameters.Add(new LookupParameter<BoolArray>("Maximization", "")); 62 51 } 63 52 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/SpacingAnalyzer.cs
r16303 r16310 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{29 namespace HeuristicLab.Analysis { 30 30 [StorableClass] 31 31 [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"; 33 34 34 public IResultParameter<DoubleValue> SpacingResultParameter {35 get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; }36 }37 35 [StorableConstructor] 38 36 protected SpacingAnalyzer(bool deserializing) : base(deserializing) { } … … 45 43 46 44 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))); 49 46 } 50 47 51 48 public override IOperation Apply() { 52 49 var qualities = QualitiesParameter.ActualValue; 53 SpacingResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities);50 ResultParameter.ActualValue.Value = SpacingCalculator.CalculateSpacing(qualities); 54 51 return base.Apply(); 55 52 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Analysis/3.3/MultiObjective/TimelineAnalyzer.cs
r16303 r16310 20 20 #endregion 21 21 22 using System.Collections.Generic; 22 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 27 using HeuristicLab.Operators; 26 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Parameters; 27 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 31 29 namespace HeuristicLab. Problems.TestFunctions.MultiObjective{32 namespace HeuristicLab.Analysis { 30 33 [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"; 33 38 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 37 48 [StorableConstructor] 38 protected SpacingAnalyzer(bool deserializing) : base(deserializing) { }49 protected TimelineAnalyzer(bool deserializing) : base(deserializing) { } 39 50 40 51 41 protected SpacingAnalyzer(SpacingAnalyzer original, Cloner cloner) : base(original, cloner) { }52 protected TimelineAnalyzer(TimelineAnalyzer original, Cloner cloner) : base(original, cloner) { } 42 53 public override IDeepCloneable Clone(Cloner cloner) { 43 return new SpacingAnalyzer(this, cloner);54 return new TimelineAnalyzer(this, cloner); 44 55 } 45 56 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",""))); 49 69 } 50 70 51 71 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 } 54 81 return base.Apply(); 55 82 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data (added) merged: 16280
- Property svn:mergeinfo changed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Data/3.3 (added) merged: 16280
- Property svn:mergeinfo changed
-
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Data/3.3/StringMatrix.cs
r15583 r16310 209 209 } 210 210 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 211 227 public override string ToString() { 212 228 if (matrix.Length == 0) return "[]"; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Optimization (added) merged: 16179
- Property svn:mergeinfo changed
-
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 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.Linq; 25 23 using HeuristicLab.Common; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs
r15583 r16310 188 188 TimeSpan.FromSeconds(15) }); 189 189 snapshotTimesIndex = 0; 190 snapshots = new RunCollection(); 190 191 Runs = new RunCollection { OptimizerName = Name }; 191 192 Initialize(); … … 199 200 TimeSpan.FromSeconds(15) }); 200 201 snapshotTimesIndex = 0; 202 snapshots = new RunCollection(); 201 203 Runs = new RunCollection { OptimizerName = Name }; 202 204 Initialize(); -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/CrowdingCalculator.cs
r16171 r16310 35 35 /// Beware that CrowdingCalculator is not normalized for the number of dimensions. A higher number of dimensions normally causes higher CrowdingCalculator values 36 36 /// </summary> 37 public static class CrowdingCalculator 38 { 37 public static class CrowdingCalculator { 39 38 40 39 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 23 23 24 24 #region 25 26 25 using System; 27 26 using System.Collections.Generic; 28 27 using System.Linq; 29 28 using HeuristicLab.Common; 30 31 29 #endregion 32 30 … … 40 38 public static class GenerationalDistanceCalculator { 41 39 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)); 43 41 if (p.IsAlmost(0.0)) throw new ArgumentException("p must not be zero."); 44 42 var mat = bestKnownFront.ToMatrix(); 45 43 if (mat.GetLength(0) == 0) throw new ArgumentException("Fronts must not be empty."); 46 44 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); 49 46 var sum = 0.0; 50 47 var summand = new double[1]; -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/HypervolumeCalculator.cs
r16171 r16310 23 23 using System.Linq; 24 24 using HeuristicLab.Common; 25 using HeuristicLab.Optimization;26 25 27 26 namespace HeuristicLab.Optimization { … … 64 63 public static double CalculateHypervolume(double[][] qualities, double[] referencePoint, bool[] maximization){ 65 64 qualities = qualities.Where(vec => DominationCalculator.Dominates(vec, referencePoint, maximization, false) == DominationResult.Dominates).ToArray(); 66 if ( !qualities.Any()) return 0;//TODO replace with negative computation65 if (qualities.Length == 0 ) return 0;//TODO computation for negative hypervolume? 67 66 if (maximization.Length == 2) 68 67 return Calculate2D(qualities, referencePoint, maximization); … … 73 72 } 74 73 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> 75 82 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)); 77 86 if (!front.Any()) throw new ArgumentException("Front must not be empty."); 78 79 if (referencePoint == null) throw new ArgumentNullException("ReferencePoint must not be null.");80 87 if (referencePoint.Length != 2) throw new ArgumentException("ReferencePoint must have exactly two dimensions."); 81 88 … … 87 94 double sum = 0; 88 95 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]); 91 97 var lastPoint = set[set.Length - 1]; 92 98 sum += Math.Abs(lastPoint[0] - referencePoint[0]) * Math.Abs(lastPoint[1] - referencePoint[1]); … … 112 118 } 113 119 120 121 //within Stream a number of equality comparisons on double values are performed 122 //this is intentional and required 114 123 private static double Stream(double[] regionLow, double[] regionUp, List<double[]> front, int split, double cover, int sqrtNoPoints, int objectives) { 115 124 var coverOld = cover; … … 135 144 var piles = new int[coverIndex]; 136 145 for (var i = 0; i < coverIndex; i++) { 137 piles[i] = IsPile(front[i], regionLow, regionUp,objectives);146 piles[i] = IsPile(front[i], regionLow, objectives); 138 147 if (piles[i] == -1) { 139 148 allPiles = false; … … 145 154 var trellis = new double[regionUp.Length]; 146 155 for (var j = 0; j < trellis.Length; j++) trellis[j] = regionUp[j]; 147 double current = 0; 148 double next = 0; 156 double next; 149 157 var i = 0; 150 158 do { 151 current = front[i][objectives - 1];159 var current = front[i][objectives - 1]; 152 160 do { 153 161 if (front[i][piles[i]] < trellis[piles[i]]) trellis[piles[i]] = front[i][piles[i]]; … … 176 184 } while (bound == -1.0); 177 185 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[]>(); 181 188 var regionUpC = new double[regionUp.Length]; 182 189 for (var j = 0; j < regionUpC.Length; j++) regionUpC[j] = regionUp[j]; … … 205 212 double result = 0; 206 213 var noSummands = BinarayToInt(bs); 207 int oneCounter; double summand;208 214 for (uint i = 1; i <= noSummands; i++) { 209 summand = 1;215 double summand = 1; 210 216 IntToBinary(i, bs); 211 oneCounter = 0;217 var oneCounter = 0; 212 218 for (var j = 0; j < objectives - 1; j++) { 213 219 if (bs[j]) { … … 244 250 } 245 251 246 private static int IsPile(double[] cuboid, double[] regionLow, double[] regionUp,int objectives) {252 private static int IsPile(double[] cuboid, double[] regionLow, int objectives) { 247 253 var pile = cuboid.Length; 248 254 for (var i = 0; i < objectives - 1; i++) { -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Optimization/3.3/MultiObjective/SpacingCalculator.cs
r16171 r16310 34 34 35 35 public static double CalculateSpacing<TP>(IEnumerable<TP> qualities) where TP: IReadOnlyList<double> { 36 if (qualities == null) throw new Argument Exception("Front must not be null.");36 if (qualities == null) throw new ArgumentNullException(nameof(qualities)); 37 37 var l = qualities.ToList(); 38 38 if (l.Count == 0) throw new ArgumentException("Front must not be empty."); … … 40 40 41 41 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); 44 43 var summand = new double[2]; 45 44 var dists = new List<double>(); … … 51 50 return dists.StandardDeviationPop(); 52 51 } 53 54 55 52 } 56 53 } -
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 30 30 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 31 31 [StorableClass] 32 [Item("CrowdingAnalyzer", "Th e 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")] 33 33 public class CrowdingAnalyzer : MOTFAnalyzer { 34 34 35 public IResultParameter<DoubleValue> CrowdingResultParameter { 36 get { return (IResultParameter<DoubleValue>)Parameters["Crowding"]; } 37 } 35 public IResultParameter<DoubleValue> CrowdingResultParameter => (IResultParameter<DoubleValue>)Parameters["Crowding"]; 38 36 39 37 [StorableConstructor] 40 38 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) {} 44 40 public override IDeepCloneable Clone(Cloner cloner) { 45 41 return new CrowdingAnalyzer(this, cloner); -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/GenerationalDistanceAnalyzer.cs
r16171 r16310 31 31 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 32 32 [StorableClass] 33 [Item("GenerationalDistanceAnalyzer", "Th e 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")] 34 34 public class GenerationalDistanceAnalyzer : MOTFAnalyzer { 35 35 36 36 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; 39 39 } 40 40 41 41 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; 44 44 } 45 45 46 public IResultParameter<DoubleValue> GenerationalDistanceResultParameter { 47 get { return (IResultParameter<DoubleValue>)Parameters["Generational Distance"]; } 48 } 46 public IResultParameter<DoubleValue> GenerationalDistanceResultParameter => (IResultParameter<DoubleValue>)Parameters["Generational Distance"]; 49 47 50 48 [StorableConstructor] -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/HypervolumeAnalyzer.cs
r16171 r16310 32 32 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 33 33 [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")] 35 35 public class HypervolumeAnalyzer : MOTFAnalyzer { 36 36 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"]; 49 44 50 45 51 46 [StorableConstructor] 52 protected HypervolumeAnalyzer(bool deserializing) 53 : base(deserializing) { 54 } 47 protected HypervolumeAnalyzer(bool deserializing) : base(deserializing) {} 55 48 56 protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) 57 : base(original, cloner) { 58 } 49 protected HypervolumeAnalyzer(HypervolumeAnalyzer original, Cloner cloner) : base(original, cloner) {} 50 59 51 public override IDeepCloneable Clone(Cloner cloner) { 60 52 return new HypervolumeAnalyzer(this, cloner); … … 69 61 BestKnownHypervolumeResultParameter.DefaultValue = new DoubleValue(0); 70 62 HypervolumeDistanceResultParameter.DefaultValue = new DoubleValue(0); 71 72 73 63 } 74 64 -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/InvertedGenerationalDistanceAnalyzer.cs
r16171 r16310 30 30 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 31 31 [StorableClass] 32 [Item("InvertedGenerationalDistanceAnalyzer", "Th e 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")] 33 33 public class InvertedGenerationalDistanceAnalyzer : MOTFAnalyzer { 34 public override bool EnabledByDefault { get { return false; } }34 public override bool EnabledByDefault => false; 35 35 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; 38 41 } 39 42 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"]; 48 44 49 45 [StorableConstructor] -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/MOTFAnalyzer.cs
r15583 r16310 33 33 [StorableClass] 34 34 public abstract class MOTFAnalyzer : SingleSuccessorOperator, IMultiObjectiveTestFunctionAnalyzer { 35 public virtual bool EnabledByDefault { get { return true; } }35 public virtual bool EnabledByDefault => true; 36 36 37 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter { 38 get { return (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; } 39 } 37 public IScopeTreeLookupParameter<DoubleArray> QualitiesParameter => (IScopeTreeLookupParameter<DoubleArray>)Parameters["Qualities"]; 40 38 41 public ILookupParameter<ResultCollection> ResultsParameter { 42 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 43 } 39 public ILookupParameter<ResultCollection> ResultsParameter => (ILookupParameter<ResultCollection>)Parameters["Results"]; 44 40 45 public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter { 46 get { return (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; } 47 } 41 public ILookupParameter<IMultiObjectiveTestFunction> TestFunctionParameter => (ILookupParameter<IMultiObjectiveTestFunction>)Parameters["TestFunction"]; 48 42 49 public ILookupParameter<DoubleMatrix> BestKnownFrontParameter { 50 get { return (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; } 51 } 43 public ILookupParameter<DoubleMatrix> BestKnownFrontParameter => (ILookupParameter<DoubleMatrix>)Parameters["BestKnownFront"]; 52 44 53 45 protected MOTFAnalyzer(MOTFAnalyzer original, Cloner cloner) : base(original, cloner) { } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs
r16171 r16310 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 25 26 using HeuristicLab.Encodings.RealVectorEncoding; 26 27 using HeuristicLab.Optimization; … … 33 34 public class ScatterPlotAnalyzer : MOTFAnalyzer { 34 35 35 public IScopeTreeLookupParameter<RealVector> IndividualsParameter { 36 get { return (IScopeTreeLookupParameter<RealVector>)Parameters["Individuals"]; } 37 } 36 public IScopeTreeLookupParameter<RealVector> IndividualsParameter => (IScopeTreeLookupParameter<RealVector>)Parameters["Individuals"]; 38 37 39 public IResultParameter<ParetoFrontScatterPlot> ScatterPlotResultParameter { 40 get { return (IResultParameter<ParetoFrontScatterPlot>)Parameters["Scatterplot"]; } 41 } 42 38 public IResultParameter<ParetoFrontScatterPlot> ScatterPlotResultParameter => (IResultParameter<ParetoFrontScatterPlot>)Parameters["Scatterplot"]; 43 39 44 40 [StorableConstructor] … … 52 48 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem")); 53 49 Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)")); 54 55 50 } 56 51 … … 59 54 var individuals = IndividualsParameter.ActualValue; 60 55 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; 63 58 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 } 67 68 68 69 var qualityClones = qualities.Select(s => s.ToArray()).ToArray(); … … 70 71 71 72 ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize); 72 73 73 return base.Apply(); 74 74 } -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/SpacingAnalyzer.cs
r16171 r16310 29 29 namespace HeuristicLab.Problems.TestFunctions.MultiObjective { 30 30 [StorableClass] 31 [Item("SpacingAnalyzer", "Th e 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")] 32 32 public class SpacingAnalyzer : MOTFAnalyzer { 33 33 34 public IResultParameter<DoubleValue> SpacingResultParameter { 35 get { return (IResultParameter<DoubleValue>)Parameters["Spacing"]; } 36 } 34 public IResultParameter<DoubleValue> SpacingResultParameter => (IResultParameter<DoubleValue>)Parameters["Spacing"]; 35 37 36 [StorableConstructor] 38 37 protected SpacingAnalyzer(bool deserializing) : base(deserializing) { } 39 40 38 41 39 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 146 146 <Compile Include="TestFunctions\IHR\IHR2.cs" /> 147 147 <Compile Include="TestFunctions\Misc\ELLI1.cs" /> 148 <Compile Include="NonDominatedSelect.cs" />149 148 <Compile Include="Interfaces\IMultiObjectiveTestFunction.cs" /> 150 149 <Compile Include="MultiObjectiveTestFunctionProblem.cs" /> -
branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r16171 r16310 39 39 #region Parameter Properties 40 40 public new IValueParameter<BoolArray> MaximizationParameter { 41 get { return (IValueParameter<BoolArray>)Parameters[ "Maximization"]; }41 get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; } 42 42 } 43 43 public IFixedValueParameter<IntValue> ProblemSizeParameter { … … 86 86 } 87 87 88 protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner) 89 : base(original, cloner) { 88 protected MultiObjectiveTestFunctionProblem(MultiObjectiveTestFunctionProblem original, Cloner cloner) : base(original, cloner) { 90 89 RegisterEventHandlers(); 91 90 } … … 94 93 } 95 94 96 public MultiObjectiveTestFunctionProblem() 97 : base() { 95 public MultiObjectiveTestFunctionProblem() : base() { 98 96 Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2))); 99 97 Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2))); … … 130 128 public double[] CheckContraints(RealVector individual) { 131 129 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]; 136 131 } 137 132 … … 169 164 ParameterizeAnalyzers(); 170 165 } 166 171 167 protected override void OnEvaluatorChanged() { 172 168 base.OnEvaluatorChanged(); … … 199 195 #region Helpers 200 196 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()); 206 203 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>(); 214 208 215 209 private void ParameterizeAnalyzers() { … … 219 213 analyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name; 220 214 analyzer.BestKnownFrontParameter.ActualName = BestKnownFrontParameter.Name; 221 222 var scatterPlotAnalyzer = analyzer as ScatterPlotAnalyzer; 223 if (scatterPlotAnalyzer != null) { 215 if (analyzer is ScatterPlotAnalyzer scatterPlotAnalyzer) 224 216 scatterPlotAnalyzer.IndividualsParameter.ActualName = Encoding.Name; 225 }226 217 } 227 218 } 228 229 219 #endregion 230 220 }
Note: See TracChangeset
for help on using the changeset viewer.