Changeset 7150
- Timestamp:
- 12/07/11 17:25:12 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
r7147 r7150 46 46 private const string UpdateIntervalParameterName = "UpdateInterval"; 47 47 private const string UpdateCounterParameterName = "UpdateCounter"; 48 private const string GenerationCounterParameterName = "GenerationCounter";49 48 50 49 #region Parameter properties … … 71 70 get { return (ValueParameter<IntValue>)Parameters[UpdateCounterParameterName]; } 72 71 } 73 public ValueParameter<IntValue> GenerationCounterParameter {74 get { return (ValueParameter<IntValue>)Parameters[GenerationCounterParameterName]; }75 }76 72 #endregion 77 73 … … 86 82 get { return StoreHistoryParameter.Value; } 87 83 } 88 public IntValue GenerationCounter {89 get { return GenerationCounterParameter.Value; }90 }91 92 84 #endregion 93 85 … … 111 103 Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1))); 112 104 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 113 Parameters.Add(new ValueParameter<IntValue>(GenerationCounterParameterName, "The value of the total number of generations this operator has been applied.", new IntValue(0)));114 115 UpdateCounterParameter.Hidden = true;116 105 117 106 AfterDeserialization(); … … 130 119 Parameters.Remove(UpdateCounterParameterName); 131 120 Parameters.Add(new ValueParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update", new IntValue(0))); 132 if (!Parameters.ContainsKey(GenerationCounterParameterName)) { 133 Parameters.Add(new ValueParameter<IntValue>(GenerationCounterParameterName, "The value of the total number of generations this operator has been applied.", new IntValue(1))); 134 } 121 122 SymbolicExpressionTreeLengthsParameter.Hidden = true; 123 SymbolicExpressionTreeLengthsHistoryParameter.Hidden = true; 124 ResultsParameter.Hidden = true; 125 UpdateCounterParameter.Hidden = true; 135 126 } 136 127 137 128 public override IOperation Apply() { 138 //IntValue updateCounter = UpdateCounterParameter.Value;139 // if the counter doesn't exist yet, we initialize it here with the current update interval140 GenerationCounter.Value++;141 129 UpdateCounter.Value++; 142 143 130 // the analyzer runs periodically, every 'updateInterval' times 144 131 if (UpdateCounter.Value == UpdateInterval.Value) { … … 213 200 treeLengthsTable.VisualProperties.YAxisMinimumFixedValue = 0.0; 214 201 int maxFreq = solutions.GroupBy(s => s.Length).Max(g => g.Count()); 215 double yAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0) > maxFreq ? Math.Ceiling(solutions.Length / 2.0) : maxFreq;216 // round up yAxisMaximumFixedValue to the nearest multiple of 5, so it would look nice in the chart217 yAxisMaximumFixedValue = yAxisMaximumFixedValue + 5 - ((int)yAxisMaximumFixedValue % 5);202 if (maxFreq % 5 != 0) 203 maxFreq += (5 - maxFreq % 5); 204 double yAxisMaximumFixedValue = maxFreq; 218 205 219 206 treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue; … … 230 217 bool storeHistory = StoreHistoryParameter.Value.Value; 231 218 const string treeLengthHistoryTableName = "Tree lengths history"; 232 const string treeLengthHistoryRowPrefix = "Tree lengths ";233 219 234 220 if (storeHistory) { 235 221 // store tree lengths for each generation 236 var historyDataRow = new DataRow( treeLengthHistoryRowPrefix + GenerationCounter.Value, "Symbolic expression tree lengths at generation " + GenerationCounter.Value, treeLengthsTableRow.Values);222 var historyDataRow = new DataRow("Tree lengths", "", treeLengthsTableRow.Values); 237 223 historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 238 224 historyDataRow.VisualProperties.ExactBins = false; 239 225 historyDataRow.VisualProperties.Bins = range; 240 226 historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor; 241 var historyTable = new DataTable(); 227 historyDataRow.VisualProperties.IsVisibleInLegend = false; 228 var historyTable = new DataTable("Tree lengths"); 242 229 historyTable.Rows.Add(historyDataRow); 243 230 // visual properties for the X-axis
Note: See TracChangeset
for help on using the changeset viewer.