Changeset 7147
- Timestamp:
- 12/07/11 13:24:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionTreeLengthAnalyzer.cs
r7143 r7147 127 127 Parameters.Add(new ValueParameter<IntValue>(UpdateIntervalParameterName, "The interval in which the tree length analysis should be applied.", new IntValue(1))); 128 128 } 129 if ( !Parameters.ContainsKey(UpdateCounterParameterName)) {130 Parameters. Add(new LookupParameter<IntValue>(UpdateCounterParameterName, "The value which counts how many times the operator was called since the last update"));131 }129 if (Parameters.ContainsKey(UpdateCounterParameterName)) 130 Parameters.Remove(UpdateCounterParameterName); 131 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 132 if (!Parameters.ContainsKey(GenerationCounterParameterName)) { 133 133 Parameters.Add(new ValueParameter<IntValue>(GenerationCounterParameterName, "The value of the total number of generations this operator has been applied.", new IntValue(1))); … … 163 163 const string yAxisTitle = "Frequency / Number of tree individuals"; 164 164 165 var treeLengths = solutions.Select(s => (double)s.Length); 166 int maxLength = solutions.Max(s => s.Length); 167 int minLength = solutions.Min(s => s.Length); 165 var treeLengths = solutions.Select(s => (int)s.Length).ToList(); 166 167 int maxLength = treeLengths.Max(t => t); 168 int minLength = treeLengths.Min(t => t); 168 169 169 170 if (!treeLengthsTable.Rows.ContainsKey(treeLengthsTableRowName)) { 170 treeLengthsTableRow = new DataRow(treeLengthsTableRowName, treeLengthsTableRowDesc, treeLengths );171 treeLengthsTableRow = new DataRow(treeLengthsTableRowName, treeLengthsTableRowDesc, treeLengths.Select(x => (double)x)); 171 172 treeLengthsTable.Rows.Add(treeLengthsTableRow); 172 173 } else { 173 174 treeLengthsTableRow = treeLengthsTable.Rows[treeLengthsTableRowName]; 174 treeLengthsTableRow.Values.Replace(treeLengths );175 treeLengthsTableRow.Values.Replace(treeLengths.Select(x => (double)x)); 175 176 } 176 177 … … 180 181 treeLengthsTableRow.VisualProperties.ExactBins = false; 181 182 183 int range = maxLength - minLength; 184 if (range == 0) range = 1; 182 185 // the following trick should result in an integer intervalWidth of 1,2,4,... 183 treeLengthsTableRow.VisualProperties.Bins = maxLength - minLength;186 treeLengthsTableRow.VisualProperties.Bins = range; 184 187 185 188 if (maxLength <= 25) // [0,25] 186 189 treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0; 187 else if (maxLength <= 100) // [26,100] )190 else if (maxLength <= 100) // [26,100] 188 191 treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 2.0; 189 else if (maxLength <= 250) // [10 0,250]192 else if (maxLength <= 250) // [101,250] 190 193 treeLengthsTableRow.VisualProperties.ScaleFactor = 1.0 / 5.0; 191 194 else if (maxLength <= 500) // [251,500] … … 205 208 treeLengthsTable.VisualProperties.XAxisMaximumFixedValue = maximumAllowedTreeLength + 1; 206 209 treeLengthsTable.VisualProperties.XAxisTitle = xAxisTitle; 207 // 210 //visual properties for the Y-axis 208 211 treeLengthsTable.VisualProperties.YAxisMinimumAuto = false; 209 212 treeLengthsTable.VisualProperties.YAxisMaximumAuto = false; 210 213 treeLengthsTable.VisualProperties.YAxisMinimumFixedValue = 0.0; 211 treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0); 214 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 chart 217 yAxisMaximumFixedValue = yAxisMaximumFixedValue + 5 - ((int)yAxisMaximumFixedValue % 5); 218 219 treeLengthsTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue; 212 220 treeLengthsTable.VisualProperties.YAxisTitle = yAxisTitle; 213 221 … … 229 237 historyDataRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram; 230 238 historyDataRow.VisualProperties.ExactBins = false; 231 historyDataRow.VisualProperties.Bins = maxLength - minLength;239 historyDataRow.VisualProperties.Bins = range; 232 240 historyDataRow.VisualProperties.ScaleFactor = treeLengthsTableRow.VisualProperties.ScaleFactor; 233 241 var historyTable = new DataTable(); … … 246 254 historyTable.VisualProperties.YAxisMaximumAuto = false; 247 255 historyTable.VisualProperties.YAxisMinimumFixedValue = 0.0; 248 historyTable.VisualProperties.YAxisMaximumFixedValue = Math.Ceiling(solutions.Length / 2.0);256 historyTable.VisualProperties.YAxisMaximumFixedValue = yAxisMaximumFixedValue; 249 257 historyTable.VisualProperties.YAxisTitle = yAxisTitle; 250 258
Note: See TracChangeset
for help on using the changeset viewer.