- Timestamp:
- 12/18/15 12:42:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionIteratedSamplingView.cs
r13475 r13485 26 26 using System.Linq; 27 27 using System.Windows.Forms.DataVisualization.Charting; 28 using HeuristicLab.MainForm.WindowsForms;29 using HeuristicLab.MainForm;30 28 using HeuristicLab.Analysis; 31 29 using HeuristicLab.Common; 32 30 using HeuristicLab.Data; 31 using HeuristicLab.MainForm; 32 using HeuristicLab.MainForm.WindowsForms; 33 33 34 34 namespace HeuristicLab.Optimization.Views.RunCollectionViews { … … 268 268 bestProbability = 1.0; 269 269 var bestProbabilityEffort = 0.0; 270 var succ = 0; 270 271 foreach (var d in data) { 271 272 if (double.IsNaN(d.Item2)) continue; 272 double succ = 0.0, unsucc = 0.0; 273 foreach (var e in data) { 274 if (e.Item1 <= d.Item1 && HasAchievedTarget(maximization, e, target)) succ++; 275 else if (e.Item1 >= d.Item1) unsucc++; 276 } 273 if (HasAchievedTarget(maximization, d, target)) succ++; 277 274 // probability of having no successful run with effort d.Item1 278 var prob = (1.0 - succ / ( succ + unsucc));275 var prob = (1.0 - succ / (double)data.Count); 279 276 // normalizing probability to effort 1 (assuming exponential convergence) 280 277 prob = Math.Pow(prob, 1.0 / d.Item1); … … 293 290 private void UpdateGraph(double cutoff, double bestProbability, double target, bool maximization) { 294 291 var table = (string)dataTableComboBox.SelectedItem; 295 var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization);296 var lambda = 1.0 / result.ExpectedRuntime;297 292 var runs = GetRunsFiltered().Select(x => (IndexedDataTable<double>)x.Results[table]).ToList(); 298 293 var evaluations = runs.SelectMany(x => x.Rows.First().Values.Select(y => y.Item1)).Distinct().OrderBy(x => x).ToList(); … … 332 327 } 333 328 334 var minimum = hits.First(x => x.Value > 0).Key;335 336 329 enhancedChart.SuspendRepaint(); 337 330 … … 346 339 var series2 = enhancedChart.Series["rldApproximationSeries"]; 347 340 series2.Points.Clear(); 348 foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max()))) { 349 series2.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum)))); 341 var evalMax = evaluations.Max(); 342 var steps = evalMax / 100.0; 343 344 var result = ExpectedRuntimeHelper.CalculateErt(GetRunsFiltered().ToList(), table, target, maximization); 345 var lambda = 1.0 / result.ExpectedRuntime; 346 foreach (var e in Enumerable.Range(0, 100)) { 347 var x = e * steps; 348 series2.Points.AddXY(x, Math.Max(0, 1.0 - Math.Exp(-lambda * x))); 350 349 } 351 350 var series3 = enhancedChart.Series["optimalSeries"]; 352 351 series3.Points.Clear(); 353 lambda = -Math.Log(bestProbability); 354 foreach (var e in Enumerable.Range(0, (int)Math.Ceiling(evaluations.Max()))) 355 series3.Points.AddXY(e, Math.Max(0, 1.0 - Math.Exp(-lambda * (e - minimum)))); 352 if (bestProbability <= 0) bestProbability = 1 - lambda; 353 foreach (var e in Enumerable.Range(0, 100)) { 354 var x = e * steps; 355 series3.Points.AddXY(x, Math.Max(0, 1.0 - Math.Pow(bestProbability, x))); 356 } 356 357 357 358 enhancedChart.Annotations.Clear(); … … 359 360 var annotation = new VerticalLineAnnotation(); 360 361 annotation.AnchorDataPoint = series.Points[cutOffIdx]; 361 annotation.Height = -20;362 annotation.Height = series.Points[cutOffIdx].YValues[0] > enhancedChart.ChartAreas[series.ChartArea].AxisY.Maximum / 2.0 ? 10 : -10; 362 363 annotation.LineWidth = 2; 363 364 annotation.StartCap = LineAnchorCapStyle.Arrow;
Note: See TracChangeset
for help on using the changeset viewer.