Changeset 17225 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs
- Timestamp:
- 08/29/19 13:53:26 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/Analyzers/ScatterPlotAnalyzer.cs
r16723 r17225 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; … … 41 42 } 42 43 43 44 44 [StorableConstructor] 45 45 protected ScatterPlotAnalyzer(StorableConstructorFlag _) : base(_) { } … … 52 52 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("Individuals", "The individual solutions to the problem")); 53 53 Parameters.Add(new ResultParameter<ParetoFrontScatterPlot>("Scatterplot", "The scatterplot for the current and optimal (if known front)")); 54 55 54 } 56 55 … … 59 58 var individuals = IndividualsParameter.ActualValue; 60 59 var testFunction = TestFunctionParameter.ActualValue; 61 int objectives = qualities[0].Length;62 int problemSize = individuals[0].Length;60 var objectives = qualities.Length != 0 ? qualities[0].Length:0; 61 var problemSize = individuals.Length != 0 ? individuals[0].Length:0; 63 62 64 double[][] optimalFront = new double[0][]; 65 var front = testFunction.OptimalParetoFront(objectives); 66 if (front != null) optimalFront = front.ToArray(); 63 var optimalFront = new double[0][]; 64 if (testFunction != null) { 65 var front = testFunction.OptimalParetoFront(objectives); 66 if (front != null) optimalFront = front.ToArray(); 67 } 68 else { 69 var mat = BestKnownFrontParameter.ActualValue; 70 optimalFront = mat == null ? null : Enumerable.Range(0, mat.Rows).Select(r => Enumerable.Range(0, mat.Columns).Select(c => mat[r, c]).ToArray()).ToArray(); 71 } 67 72 68 73 var qualityClones = qualities.Select(s => s.ToArray()).ToArray(); … … 70 75 71 76 ScatterPlotResultParameter.ActualValue = new ParetoFrontScatterPlot(qualityClones, solutionClones, optimalFront, objectives, problemSize); 72 73 77 return base.Apply(); 74 78 }
Note: See TracChangeset
for help on using the changeset viewer.