Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9302


Ignore:
Timestamp:
03/08/13 14:51:04 (12 years ago)
Author:
abeham
Message:

#1961: updated analyzer to match the output of Hansen more closely

Location:
branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/CMAES/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.3/CMAAnalyzer.cs

    r9297 r9302  
    2020#endregion
    2121
     22using System;
     23using System.Linq;
    2224using HeuristicLab.Analysis;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2528using HeuristicLab.Encodings.RealVectorEncoding;
    2629using HeuristicLab.Operators;
     
    2831using HeuristicLab.Parameters;
    2932using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    30 using System;
    3133
    3234namespace HeuristicLab.Algorithms.CMAEvolutionStrategy {
     
    4850    }
    4951
     52    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     53      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
     54    }
     55
    5056    public ILookupParameter<ResultCollection> ResultsParameter {
    5157      get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
     
    6066      Parameters.Add(new LookupParameter<CMAParameters>("StrategyParameters", "The CMA strategy parameters to be analyzed."));
    6167      Parameters.Add(new LookupParameter<RealVector>("Mean", "The mean real vector that is being optimized."));
     68      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the solutions."));
    6269      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection to store the results in."));
    6370    }
     
    7178      var vector = MeanParameter.ActualValue;
    7279      var results = ResultsParameter.ActualValue;
     80      var qualities = QualityParameter.ActualValue;
     81      double min = qualities[0].Value, max = qualities[0].Value, avg = qualities[0].Value;
     82      for (int i = 1; i < qualities.Length; i++) {
     83        if (qualities[i].Value < min) min = qualities[i].Value;
     84        if (qualities[i].Value > max) max = qualities[i].Value;
     85        avg += qualities[i].Value;
     86      }
     87      avg /= qualities.Length;
    7388
    74       DataTable axisRatio;
    75       if (results.ContainsKey("AxisRatio")) {
    76         axisRatio = (DataTable)results["AxisRatio"].Value;
     89      DataTable progress;
     90      if (results.ContainsKey("Progress")) {
     91        progress = (DataTable)results["Progress"].Value;
    7792      } else {
    78         axisRatio = new DataTable("AxisRatio");
    79         axisRatio.Rows.Add(new DataRow("AxisRatio"));
    80         axisRatio.VisualProperties.YAxisLogScale = true;
    81         results.Add(new Result("AxisRatio", axisRatio));
     93        progress = new DataTable("Progress");
     94        progress.Rows.Add(new DataRow("AxisRatio"));
     95        progress.Rows.Add(new DataRow("Sigma"));
     96        progress.Rows.Add(new DataRow("Min Quality"));
     97        progress.Rows.Add(new DataRow("Max Quality"));
     98        progress.Rows.Add(new DataRow("Avg Quality"));
     99        progress.VisualProperties.YAxisLogScale = true;
     100        results.Add(new Result("Progress", progress));
    82101      }
    83       axisRatio.Rows["AxisRatio"].Values.Add(sp.AxisRatio);
    84 
    85       DataTable sigma;
    86       if (results.ContainsKey("Sigma")) {
    87         sigma = (DataTable)results["Sigma"].Value;
    88       } else {
    89         sigma = new DataTable("Sigma");
    90         sigma.VisualProperties.YAxisLogScale = true;
    91         sigma.Rows.Add(new DataRow("Sigma"));
    92         results.Add(new Result("Sigma", sigma));
    93       }
    94       sigma.Rows["Sigma"].Values.Add(sp.Sigma);
     102      progress.Rows["AxisRatio"].Values.Add(sp.AxisRatio);
     103      progress.Rows["Sigma"].Values.Add(sp.Sigma);
     104      progress.Rows["Min Quality"].Values.Add(min);
     105      progress.Rows["Max Quality"].Values.Add(max);
     106      progress.Rows["Avg Quality"].Values.Add(avg);
    95107
    96108      DataTable scaling;
     
    108120
    109121      DataTable realVector;
    110       if (results.ContainsKey("RealVector")) {
    111         realVector = (DataTable)results["RealVector"].Value;
     122      if (results.ContainsKey("Object Variables")) {
     123        realVector = (DataTable)results["Object Variables"].Value;
    112124      } else {
    113         realVector = new DataTable("RealVector");
     125        realVector = new DataTable("Object Variables");
    114126        for (int i = 0; i < vector.Length; i++)
    115127          realVector.Rows.Add(new DataRow("Axis" + i.ToString()));
    116         results.Add(new Result("RealVector", realVector));
     128        results.Add(new Result("Object Variables", realVector));
    117129      }
    118130      for (int i = 0; i < vector.Length; i++)
     
    120132
    121133      DataTable stdDevs;
    122       if (results.ContainsKey("StandardDeviations")) {
    123         stdDevs = (DataTable)results["StandardDeviations"].Value;
     134      if (results.ContainsKey("Standard Deviations")) {
     135        stdDevs = (DataTable)results["Standard Deviations"].Value;
    124136      } else {
    125         stdDevs = new DataTable("StandardDeviations");
     137        stdDevs = new DataTable("Standard Deviations");
    126138        stdDevs.VisualProperties.YAxisLogScale = true;
     139        stdDevs.Rows.Add(new DataRow("MinStdDev"));
     140        stdDevs.Rows.Add(new DataRow("MaxStdDev"));
    127141        for (int i = 0; i < vector.Length; i++)
    128142          stdDevs.Rows.Add(new DataRow("Axis" + i.ToString()));
    129         results.Add(new Result("StandardDeviations", stdDevs));
     143        results.Add(new Result("Standard Deviations", stdDevs));
    130144      }
    131145      for (int i = 0; i < vector.Length; i++)
    132146        stdDevs.Rows["Axis" + i.ToString()].Values.Add(Math.Sqrt(sp.C[i, i]));
     147      stdDevs.Rows["MinStdDev"].Values.Add(sp.D.Min() * sp.Sigma);
     148      stdDevs.Rows["MaxStdDev"].Values.Add(sp.D.Max() * sp.Sigma);
    133149
    134150      return base.Apply();
Note: See TracChangeset for help on using the changeset viewer.