Changeset 9302
- Timestamp:
- 03/08/13 14:51:04 (12 years ago)
- 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 20 20 #endregion 21 21 22 using System; 23 using System.Linq; 22 24 using HeuristicLab.Analysis; 23 25 using HeuristicLab.Common; 24 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 25 28 using HeuristicLab.Encodings.RealVectorEncoding; 26 29 using HeuristicLab.Operators; … … 28 31 using HeuristicLab.Parameters; 29 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using System;31 33 32 34 namespace HeuristicLab.Algorithms.CMAEvolutionStrategy { … … 48 50 } 49 51 52 public IScopeTreeLookupParameter<DoubleValue> QualityParameter { 53 get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 54 } 55 50 56 public ILookupParameter<ResultCollection> ResultsParameter { 51 57 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } … … 60 66 Parameters.Add(new LookupParameter<CMAParameters>("StrategyParameters", "The CMA strategy parameters to be analyzed.")); 61 67 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.")); 62 69 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The collection to store the results in.")); 63 70 } … … 71 78 var vector = MeanParameter.ActualValue; 72 79 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; 73 88 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; 77 92 } 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)); 82 101 } 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); 95 107 96 108 DataTable scaling; … … 108 120 109 121 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; 112 124 } else { 113 realVector = new DataTable(" RealVector");125 realVector = new DataTable("Object Variables"); 114 126 for (int i = 0; i < vector.Length; i++) 115 127 realVector.Rows.Add(new DataRow("Axis" + i.ToString())); 116 results.Add(new Result(" RealVector", realVector));128 results.Add(new Result("Object Variables", realVector)); 117 129 } 118 130 for (int i = 0; i < vector.Length; i++) … … 120 132 121 133 DataTable stdDevs; 122 if (results.ContainsKey("Standard Deviations")) {123 stdDevs = (DataTable)results["Standard Deviations"].Value;134 if (results.ContainsKey("Standard Deviations")) { 135 stdDevs = (DataTable)results["Standard Deviations"].Value; 124 136 } else { 125 stdDevs = new DataTable("Standard Deviations");137 stdDevs = new DataTable("Standard Deviations"); 126 138 stdDevs.VisualProperties.YAxisLogScale = true; 139 stdDevs.Rows.Add(new DataRow("MinStdDev")); 140 stdDevs.Rows.Add(new DataRow("MaxStdDev")); 127 141 for (int i = 0; i < vector.Length; i++) 128 142 stdDevs.Rows.Add(new DataRow("Axis" + i.ToString())); 129 results.Add(new Result("Standard Deviations", stdDevs));143 results.Add(new Result("Standard Deviations", stdDevs)); 130 144 } 131 145 for (int i = 0; i < vector.Length; i++) 132 146 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); 133 149 134 150 return base.Apply();
Note: See TracChangeset
for help on using the changeset viewer.