Changeset 12804 for branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
- Timestamp:
- 07/26/15 21:32:52 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r12803 r12804 42 42 } 43 43 44 private double[] levels; 45 44 46 private bool suppressUpdates; 45 47 private readonly IndexedDataTable<double> combinedDataTable; … … 167 169 var table = (string)dataTableComboBox.SelectedItem; 168 170 if (string.IsNullOrEmpty(table)) return; 169 var maximum = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).Max(); 170 var minimum = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Min(); 171 var levels = Enumerable.Range(0, 51).Select(x => maximum - (x / 50.0) * (maximum - minimum)).ToArray(); 171 if (levels == null) { 172 var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First(); 173 var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last(); 174 levels = Enumerable.Range(0, 51).Select(x => worst + (x / 50.0) * (best - worst)).ToArray(); 175 suppressTargetsEvents = true; 176 targetsTextBox.Text = string.Join(" ; ", levels); 177 suppressTargetsEvents = false; 178 } 172 179 var selectedGroup = (string)groupComboBox.SelectedItem; 173 180 if (string.IsNullOrEmpty(selectedGroup)) return; … … 184 191 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 185 192 xAxisTitles.Add(resultsTable.VisualProperties.XAxisTitle); 186 var graph = new LinkedList<Tuple<double, double>>(resultsTable.Rows.First().Values); 187 var current = graph.First.Next; 188 // prune convergence graph to obtain first hit times only 189 while (current != null) { 190 if (current.Value.Item2.IsAlmost(current.Previous.Value.Item2)) { 191 var h = current; 192 current = current.Previous; 193 graph.Remove(h); 194 } 195 current = current.Next; 196 } 193 var values = resultsTable.Rows.First().Values; 194 var maximization = values.First().Item2 < values.Last().Item2; 197 195 var i = 0; 198 current = graph.First; 199 while (i < levels.Length && current != null) { 200 if (current.Value.Item2 < levels[i]) { 201 if (hits.ContainsKey(current.Value.Item1)) 202 hits[current.Value.Item1]++; 203 else hits[current.Value.Item1] = 1; 196 var j = 0; 197 var current = values[j]; 198 var prev = Tuple.Create(-1.0, double.NaN); 199 while (i < levels.Length) { 200 if ((double.IsNaN(prev.Item2) || prev.Item2 != current.Item2) 201 && (maximization && current.Item2 >= levels[i] 202 || !maximization && current.Item2 <= levels[i])) { 203 if (hits.ContainsKey(current.Item1)) 204 hits[current.Item1]++; 205 else hits[current.Item1] = 1; 204 206 i++; 205 207 } else { 206 current = current.Next; 208 j++; 209 if (j >= values.Count) break; 210 prev = current; 211 current = values[j]; 207 212 } 208 213 } … … 266 271 combinedDataTable.VisualProperties.XAxisLogScale = logScalingCheckBox.Checked; 267 272 } 273 274 private bool suppressTargetsEvents; 275 private void targetsTextBox_Validating(object sender, CancelEventArgs e) { 276 if (suppressTargetsEvents) return; 277 var targetStrings = targetsTextBox.Text.Split(new[] { ';', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); 278 var targetList = new List<double>(); 279 foreach (var ts in targetStrings) { 280 double t; 281 if (!double.TryParse(ts, out t)) { 282 errorProvider.SetError(targetsTextBox, "Not all targets can be parsed: " + ts); 283 e.Cancel = true; 284 return; 285 } 286 targetList.Add(t); 287 } 288 if (targetList.Count == 0) { 289 errorProvider.SetError(targetsTextBox, "Give at least one target value!"); 290 e.Cancel = true; 291 return; 292 } 293 e.Cancel = false; 294 errorProvider.SetError(targetsTextBox, null); 295 levels = targetList.ToArray(); 296 } 268 297 } 269 298 }
Note: See TracChangeset
for help on using the changeset viewer.