Changeset 9713 for branches/StatisticalTesting
- Timestamp:
- 07/17/13 13:32:08 (11 years ago)
- Location:
- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs
r9706 r9713 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Threading.Tasks; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.Common; … … 28 29 using HeuristicLab.Data; 29 30 using HeuristicLab.MainForm; 31 using HeuristicLab.MainForm.WindowsForms; 30 32 using HeuristicLab.Optimization; 31 33 using HeuristicLab.PluginInfrastructure; 32 34 33 35 namespace HeuristicLab.Analysis.Statistics { 34 [View("RunCollection Chart Analysis View")]36 [View("RunCollection Chart Analysis")] 35 37 [Content(typeof(RunCollection), false)] 36 38 public sealed partial class ChartAnalysisView : ItemView { … … 46 48 47 49 private List<IRun> runs; 50 private Progress progress; 51 private ProgressView progressView; 52 private bool valuesAdded = false; 48 53 49 54 public ChartAnalysisView() { 50 55 InitializeComponent(); 56 progress = new Progress() { 57 CanBeCanceled = false, 58 ProgressState = ProgressState.Finished 59 }; 60 progressView = new ProgressView(this, progress); 61 51 62 stringConvertibleMatrixView.DataGridView.RowHeaderMouseDoubleClick += new DataGridViewCellMouseEventHandler(DataGridView_RowHeaderMouseDoubleClick); 52 63 … … 67 78 components.Dispose(); 68 79 } 80 if (disposing) 81 progressView.Dispose(); 69 82 base.Dispose(disposing); 70 83 } … … 98 111 99 112 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 100 RebuildDataTable ();113 RebuildDataTableAsync(); 101 114 } 102 115 103 116 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 104 RebuildDataTable ();117 RebuildDataTableAsync(); 105 118 } 106 119 107 120 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) { 108 RebuildDataTable ();121 RebuildDataTableAsync(); 109 122 } 110 123 111 124 void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) { 112 if (!Content.UpdateOfRunsInProgress) { 113 RebuildDataTable(); 125 if (!Content.UpdateOfRunsInProgress && !valuesAdded) { 126 RebuildDataTableAsync(); 127 } 128 if (valuesAdded) { 129 valuesAdded = false; 114 130 } 115 131 } … … 133 149 134 150 private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) { 135 RebuildDataTable ();151 RebuildDataTableAsync(); 136 152 } 137 153 138 154 private void addLineToChart_Click(object sender, EventArgs e) { 155 progress.Status = "Adding fitted lines to charts..."; 156 progress.ProgressState = ProgressState.Started; 157 progress.ProgressValue = 0.0; 158 159 var task = System.Threading.Tasks.Task.Factory.StartNew(AddLineToChart); 160 161 task.ContinueWith((t) => { 162 progress.Finish(); 163 ErrorHandling.ShowErrorDialog("An error occured while adding lines to charts. ", t.Exception); 164 }, TaskContinuationOptions.OnlyOnFaulted); 165 166 task.ContinueWith((t) => { 167 progress.Finish(); 168 }, TaskContinuationOptions.OnlyOnRanToCompletion); 169 } 170 171 private void AddLineToChart() { 139 172 string resultName = (string)dataTableComboBox.SelectedItem; 140 173 string rowName = (string)dataRowComboBox.SelectedItem; … … 171 204 } 172 205 } 206 valuesAdded = true; 173 207 Content.UpdateOfRunsInProgress = false; 174 208 } … … 200 234 } 201 235 236 private void RebuildDataTableAsync() { 237 progress.Status = "Calculating values..."; 238 progress.ProgressState = ProgressState.Started; 239 progress.ProgressValue = 0.0; 240 241 var task = System.Threading.Tasks.Task.Factory.StartNew(RebuildDataTable); 242 243 task.ContinueWith((t) => { 244 progress.Finish(); 245 ErrorHandling.ShowErrorDialog("An error occured while calculating values. ", t.Exception); 246 }, TaskContinuationOptions.OnlyOnFaulted); 247 248 task.ContinueWith((t) => { 249 progress.Finish(); 250 }, TaskContinuationOptions.OnlyOnRanToCompletion); 251 } 252 202 253 private void RebuildDataTable() { 203 254 string resultName = (string)dataTableComboBox.SelectedItem; 204 255 string rowName = (string)dataRowComboBox.SelectedItem; 205 string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error", "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %" }; 256 LinearLeastSquaresFitting llsFitting = new LinearLeastSquaresFitting(); 257 LogFitting logFitting = new LogFitting(); 258 string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %", "Gradient", "Relative Error", "a", "b" }; 206 259 207 260 runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible).ToList(); … … 226 279 double percentile25 = values.Percentile(0.25); 227 280 double percentile75 = values.Percentile(0.75); 228 double k, d, r;229 LinearLeastSquaresFitting llsf = new LinearLeastSquaresFitting();230 llsf.Calculate(values.ToArray(), out k, out d);231 r = llsf.CalculateError(values.ToArray(), k, d);232 281 double lowerAvg = values.OrderBy(x => x).Take((int)(values.Count() * 0.25)).Average(); 233 282 double upperAvg = values.OrderByDescending(x => x).Take((int)(values.Count() * 0.25)).Average(); 234 283 double firstAvg = values.Take((int)(values.Count() * 0.25)).Average(); 235 284 double lastAvg = values.Skip((int)(values.Count() * 0.75)).Average(); 285 double k, d, r, a, b; 286 llsFitting.Calculate(values.ToArray(), out k, out d); 287 r = llsFitting.CalculateError(values.ToArray(), k, d); 288 logFitting.Calculate(values.ToArray(), out a, out b); 236 289 237 290 dt[i, 0] = cnt; … … 244 297 dt[i, 7] = percentile25; 245 298 dt[i, 8] = percentile75; 246 dt[i, 9] = k; 247 dt[i, 10] = r; 248 dt[i, 11] = upperAvg; 249 dt[i, 12] = lowerAvg; 250 dt[i, 13] = firstAvg; 251 dt[i, 14] = lastAvg; 299 dt[i, 9] = upperAvg; 300 dt[i, 10] = lowerAvg; 301 dt[i, 11] = firstAvg; 302 dt[i, 12] = lastAvg; 303 dt[i, 13] = k; 304 dt[i, 14] = r; 305 dt[i, 15] = a; 306 dt[i, 16] = b; 252 307 253 308 i++; -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.designer.cs
r9706 r9713 49 49 this.fittingComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 50 50 this.fittingComboBox.FormattingEnabled = true; 51 this.fittingComboBox.Location = new System.Drawing.Point(14 7, 359);51 this.fittingComboBox.Location = new System.Drawing.Point(142, 359); 52 52 this.fittingComboBox.Name = "fittingComboBox"; 53 this.fittingComboBox.Size = new System.Drawing.Size(2 00, 21);53 this.fittingComboBox.Size = new System.Drawing.Size(214, 21); 54 54 this.fittingComboBox.TabIndex = 12; 55 55 // 56 56 // addValuesButton 57 57 // 58 this.addValuesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles. Right)));59 this.addValuesButton.Location = new System.Drawing.Point( 8, 359);58 this.addValuesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 59 this.addValuesButton.Location = new System.Drawing.Point(3, 357); 60 60 this.addValuesButton.Name = "addValuesButton"; 61 61 this.addValuesButton.Size = new System.Drawing.Size(133, 23); … … 68 68 // 69 69 this.addLineToChart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 70 this.addLineToChart.Location = new System.Drawing.Point(3 53, 359);70 this.addLineToChart.Location = new System.Drawing.Point(362, 357); 71 71 this.addLineToChart.Name = "addLineToChart"; 72 72 this.addLineToChart.Size = new System.Drawing.Size(133, 23); -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs
r9706 r9713 30 30 31 31 namespace HeuristicLab.Analysis.Statistics { 32 [View(" Correlation View")]32 [View("RunCollection Correlations")] 33 33 [Content(typeof(RunCollection), false)] 34 34 public sealed partial class CorrelationView : ItemView { -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/LinearLeastSquaresFitting.cs
r9706 r9713 52 52 } 53 53 54 //TODO: adapt or remove 55 public double CalculateError(double[] dataPoints, double a1, double a0) { 54 public double CalculateError(double[] dataPoints, double p0, double p1) { 56 55 double r = 0.0; 57 56 double avgy = dataPoints.Average(); … … 60 59 61 60 for (int i = 0; i < dataPoints.Count(); i++) { 62 double y = a1 * i + a0;61 double y = p0 * i + p1; 63 62 sstot += Math.Pow(dataPoints[i] - avgy, 2); 64 63 sserr += Math.Pow(dataPoints[i] - y, 2); -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/SampleSizeInfluenceView.cs
r9706 r9713 34 34 35 35 namespace HeuristicLab.Analysis.Statistics { 36 [View(" Sample Size Influence View")]36 [View("RunCollection Sample Size Influences")] 37 37 [Content(typeof(RunCollection), false)] 38 38 public partial class SampleSizeInfluenceView : AsynchronousContentView { -
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.cs
r9706 r9713 32 32 33 33 namespace HeuristicLab.Analysis.Statistics { 34 [View(" Statistical Testing View")]34 [View("RunCollection Statistical Testing")] 35 35 [Content(typeof(RunCollection), false)] 36 36 public sealed partial class StatisticalTestingView : ItemView {
Note: See TracChangeset
for help on using the changeset viewer.