Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

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

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