- Timestamp:
- 12/22/11 00:12:46 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
r7223 r7227 20 20 #endregion 21 21 22 using System; 22 23 using System.Linq; 23 24 using HeuristicLab.Analysis; … … 29 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using System;32 32 33 33 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 37 37 [Item("SymbolicExpressionTreeLengthAnalyzer", "An operator that tracks tree lengths of Symbolic Expression Trees")] 38 38 [StorableClass] 39 public sealed class SymbolicExpressionTreeLengthAnalyzer : SingleSuccessorOperator, ISymbolicExpressionTreeAnalyzer {39 public sealed class SymbolicExpressionTreeLengthAnalyzer : SingleSuccessorOperator, ISymbolicExpressionTreeAnalyzer, IStatefulItem { 40 40 private const string SymbolicExpressionTreeParameterName = "SymbolicExpressionTree"; 41 41 private const string MaximumSymbolicExpressionTreeLengthParameterName = "MaximumSymbolicExpressionTreeLength"; … … 91 91 private SymbolicExpressionTreeLengthAnalyzer(SymbolicExpressionTreeLengthAnalyzer original, Cloner cloner) 92 92 : base(original, cloner) { 93 AfterDeserialization();94 93 } 95 94 public override IDeepCloneable Clone(Cloner cloner) { … … 107 106 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 108 107 109 AfterDeserialization(); 108 SymbolicExpressionTreeLengthsParameter.Hidden = true; 109 SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true; 110 ResultsParameter.Hidden = true; 111 UpdateCounterParameter.Hidden = true; 110 112 } 111 113 … … 119 121 Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1))); 120 122 } 121 if (Parameters.ContainsKey(UpdateCounterParameterName)) 122 Parameters.Remove(UpdateCounterParameterName); 123 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 124 125 SymbolicExpressionTreeLengthsParameter.Hidden = true; 126 SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true; 127 ResultsParameter.Hidden = true; 128 UpdateCounterParameter.Hidden = true; 129 } 123 if (!Parameters.ContainsKey(UpdateCounterParameterName)) { 124 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 125 UpdateCounterParameter.Hidden = true; 126 } 127 } 128 129 #region IStatefulItem members 130 public void InitializeState() { 131 UpdateCounter.Value = 0; 132 } 133 public void ClearState() { 134 UpdateCounter.Value = 0; 135 } 136 #endregion 130 137 131 138 public override IOperation Apply() { … … 222 229 223 230 if (storeHistory) { 224 // store tree lengths for each generation225 var historyDataRow = new DataRow("Tree lengths", "", treeLengthsTableRow.Values);226 historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;227 historyDataRow.VisualProperties.ExactBins = false;228 historyDataRow.VisualProperties.Bins = range;229 historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor;230 historyDataRow.VisualProperties.IsVisibleInLegend = false;231 var historyTable = new DataTable("Tree lengths");232 historyTable.Rows.Add(historyDataRow);233 // visual properties for the X-axis234 historyTable.VisualProperties.XAxisMinimumAuto = false;235 historyTable.VisualProperties.XAxisMaximumAuto = false;236 historyTable.VisualProperties.XAxisMinimumFixedValue = 0.0;237 if (maxLength > maximumAllowedTreeLength + 1)238 historyTable.VisualProperties.XAxisMaximumFixedValue = maxLength + 1; // +1 so the histogram column for the maximum length won't get trimmed239 else240 historyTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1;241 historyTable.VisualProperties.XAxisTitle = xAxisTitle;242 // visual properties for the Y-axis243 historyTable.VisualProperties.YAxisMinimumAuto = false;244 historyTable.VisualProperties.YAxisMaximumAuto = false;245 historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0;246 historyTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue;247 historyTable.VisualProperties.YAxisTitle = yAxisTitle;248 249 231 var treeLengthsHistory = SymbolicExpressionTreeLengthsHistoryParameter.ActualValue; 250 232 if (treeLengthsHistory == null) { … … 252 234 SymbolicExpressionTreeLengthsHistoryParameter.ActualValue = treeLengthsHistory; 253 235 } 254 255 treeLengthsHistory.Add(historyTable); 236 treeLengthsHistory.Add((DataTable)treeLengthsTable.Clone()); 256 237 257 238 if (!results.ContainsKey(treeLengthHistoryTableName)) {
Note: See TracChangeset
for help on using the changeset viewer.