Changeset 4652
- Timestamp:
- 10/28/10 17:38:37 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs
r4477 r4652 87 87 return ((m_n > 1) ? m_newS / (m_n - 1) : 0.0); 88 88 } 89 90 /// <summary> 91 /// Calculates the pth percentile of the values. 92 /// </summary 93 public static double Percentile(this IEnumerable<double> values, double p) { 94 if (values.Count() == 0) throw new InvalidOperationException("Enumeration contains no elements."); 95 if (values.Count() == 1) return values.ElementAt(0); 96 97 double[] sortedValues = values.ToArray(); 98 Array.Sort(sortedValues); 99 100 int n = sortedValues.Length; 101 if (p.IsAlmost(0.0)) return sortedValues[0]; 102 if (p.IsAlmost(1.0)) return sortedValues[n - 1]; 103 104 double t = p * (n - 1); 105 int index = (int)Math.Floor(t); 106 double percentage = t - index; 107 return sortedValues[index] * (1 - percentage) + sortedValues[index + 1] * percentage; 108 } 89 109 } 90 110 } -
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleMatrixView.cs
r4600 r4652 23 23 using System.Collections.Generic; 24 24 using System.ComponentModel; 25 using System.Drawing; 25 26 using System.Linq; 26 27 using System.Text; … … 51 52 } 52 53 54 private bool showRowsAndColumnsTextBox; 55 public bool ShowRowsAndColumnsTextBox { 56 get { return showRowsAndColumnsTextBox; } 57 set { 58 if (value != showRowsAndColumnsTextBox) { 59 showRowsAndColumnsTextBox = value; 60 UpdateVisibilityOfTextBoxes(); 61 } 62 } 63 } 64 53 65 public StringConvertibleMatrixView() { 54 66 InitializeComponent(); 67 showRowsAndColumnsTextBox = true; 55 68 errorProvider.SetIconAlignment(rowsTextBox, ErrorIconAlignment.MiddleLeft); 56 69 errorProvider.SetIconPadding(rowsTextBox, 2); … … 99 112 100 113 private void UpdateData() { 101 102 114 rowsTextBox.Text = Content.Rows.ToString(); 103 115 rowsTextBox.Enabled = true; … … 472 484 new ColumnsVisibilityDialog(this.dataGridView.Columns.Cast<DataGridViewColumn>()).ShowDialog(); 473 485 } 486 487 private void UpdateVisibilityOfTextBoxes() { 488 rowsTextBox.Visible = columnsTextBox.Visible = showRowsAndColumnsTextBox; 489 rowsLabel.Visible = columnsLabel.Visible = showRowsAndColumnsTextBox; 490 491 int headerSize = columnsTextBox.Location.Y + columnsTextBox.Size.Height + 492 columnsTextBox.Margin.Bottom + dataGridView.Margin.Top; 493 494 int offset = showRowsAndColumnsTextBox ? headerSize : 0; 495 dataGridView.Location = new Point(0, offset); 496 dataGridView.Size = new Size(Size.Width, Size.Height - offset); 497 } 474 498 } 475 499 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBoxPlotView.Designer.cs
r4094 r4652 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); 48 49 System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series(); … … 51 52 this.yAxisLabel = new System.Windows.Forms.Label(); 52 53 this.yAxisComboBox = new System.Windows.Forms.ComboBox(); 53 this.chart = new System.Windows.Forms.DataVisualization.Charting.Chart();54 this.chart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart(); 54 55 this.noRunsLabel = new System.Windows.Forms.Label(); 56 this.splitContainer = new System.Windows.Forms.SplitContainer(); 57 this.statisticsGroupBox = new System.Windows.Forms.GroupBox(); 58 this.statisticsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); 59 this.tooltip = new System.Windows.Forms.ToolTip(this.components); 55 60 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 61 this.splitContainer.Panel1.SuspendLayout(); 62 this.splitContainer.Panel2.SuspendLayout(); 63 this.splitContainer.SuspendLayout(); 64 this.statisticsGroupBox.SuspendLayout(); 56 65 this.SuspendLayout(); 57 66 // … … 60 69 this.xAxisLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 61 70 this.xAxisLabel.AutoSize = true; 62 this.xAxisLabel.Location = new System.Drawing.Point( 306, 294);71 this.xAxisLabel.Location = new System.Drawing.Point(298, 256); 63 72 this.xAxisLabel.Name = "xAxisLabel"; 64 73 this.xAxisLabel.Size = new System.Drawing.Size(15, 13); … … 72 81 this.xAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 73 82 this.xAxisComboBox.FormattingEnabled = true; 74 this.xAxisComboBox.Location = new System.Drawing.Point(3 27, 290);83 this.xAxisComboBox.Location = new System.Drawing.Point(319, 253); 75 84 this.xAxisComboBox.Name = "xAxisComboBox"; 76 85 this.xAxisComboBox.Size = new System.Drawing.Size(221, 21); … … 81 90 // 82 91 this.yAxisLabel.AutoSize = true; 83 this.yAxisLabel.Location = new System.Drawing.Point(3, 7);92 this.yAxisLabel.Location = new System.Drawing.Point(3, 6); 84 93 this.yAxisLabel.Name = "yAxisLabel"; 85 94 this.yAxisLabel.Size = new System.Drawing.Size(15, 13); … … 92 101 this.yAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 93 102 this.yAxisComboBox.FormattingEnabled = true; 94 this.yAxisComboBox.Location = new System.Drawing.Point(24, 4);103 this.yAxisComboBox.Location = new System.Drawing.Point(24, 3); 95 104 this.yAxisComboBox.Name = "yAxisComboBox"; 96 105 this.yAxisComboBox.Size = new System.Drawing.Size(221, 21); … … 105 114 chartArea1.Name = "ChartArea1"; 106 115 this.chart.ChartAreas.Add(chartArea1); 107 this.chart.Location = new System.Drawing.Point( 3, 28);116 this.chart.Location = new System.Drawing.Point(6, 30); 108 117 this.chart.Name = "chart"; 109 118 series1.ChartArea = "ChartArea1"; … … 112 121 series1.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle; 113 122 series1.Name = "DataSeries"; 114 series1.YValuesPerPoint = 1;123 series1.YValuesPerPoint = 6; 115 124 this.chart.Series.Add(series1); 116 117 this.chart.Size = new System.Drawing.Size(546, 258); 125 this.chart.Size = new System.Drawing.Size(534, 217); 118 126 this.chart.TabIndex = 17; 119 127 this.chart.Text = "chart"; 120 128 this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart_AxisViewChanged); 129 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 121 130 // 122 131 // noRunsLabel … … 124 133 this.noRunsLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 125 134 this.noRunsLabel.AutoSize = true; 126 this.noRunsLabel.Location = new System.Drawing.Point(2 00, 134);135 this.noRunsLabel.Location = new System.Drawing.Point(212, 122); 127 136 this.noRunsLabel.Name = "noRunsLabel"; 128 137 this.noRunsLabel.Size = new System.Drawing.Size(138, 13); … … 130 139 this.noRunsLabel.Text = "No runs could be displayed."; 131 140 // 141 // splitContainer 142 // 143 this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 144 this.splitContainer.Location = new System.Drawing.Point(0, 0); 145 this.splitContainer.Name = "splitContainer"; 146 this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; 147 // 148 // splitContainer.Panel1 149 // 150 this.splitContainer.Panel1.Controls.Add(this.xAxisLabel); 151 this.splitContainer.Panel1.Controls.Add(this.noRunsLabel); 152 this.splitContainer.Panel1.Controls.Add(this.yAxisLabel); 153 this.splitContainer.Panel1.Controls.Add(this.xAxisComboBox); 154 this.splitContainer.Panel1.Controls.Add(this.yAxisComboBox); 155 this.splitContainer.Panel1.Controls.Add(this.chart); 156 // 157 // splitContainer.Panel2 158 // 159 this.splitContainer.Panel2.Controls.Add(this.statisticsGroupBox); 160 this.splitContainer.Size = new System.Drawing.Size(543, 416); 161 this.splitContainer.SplitterDistance = 277; 162 this.splitContainer.TabIndex = 23; 163 // 164 // statisticsGroupBox 165 // 166 this.statisticsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 167 | System.Windows.Forms.AnchorStyles.Left) 168 | System.Windows.Forms.AnchorStyles.Right))); 169 this.statisticsGroupBox.Controls.Add(this.statisticsMatrixView); 170 this.statisticsGroupBox.Location = new System.Drawing.Point(3, 3); 171 this.statisticsGroupBox.Name = "statisticsGroupBox"; 172 this.statisticsGroupBox.Size = new System.Drawing.Size(534, 129); 173 this.statisticsGroupBox.TabIndex = 1; 174 this.statisticsGroupBox.TabStop = false; 175 this.statisticsGroupBox.Text = "Statistics"; 176 // 177 // statisticsMatrixView 178 // 179 this.statisticsMatrixView.Caption = "StringConvertibleMatrix View"; 180 this.statisticsMatrixView.Content = null; 181 this.statisticsMatrixView.Dock = System.Windows.Forms.DockStyle.Fill; 182 this.statisticsMatrixView.Location = new System.Drawing.Point(3, 16); 183 this.statisticsMatrixView.Name = "statisticsMatrixView"; 184 this.statisticsMatrixView.ReadOnly = true; 185 this.statisticsMatrixView.ShowRowsAndColumnsTextBox = false; 186 this.statisticsMatrixView.Size = new System.Drawing.Size(528, 110); 187 this.statisticsMatrixView.TabIndex = 0; 188 // 132 189 // RunCollectionBoxPlotView 133 190 // … … 136 193 this.BackColor = System.Drawing.SystemColors.Window; 137 194 this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 138 this.Controls.Add(this.noRunsLabel); 139 this.Controls.Add(this.chart); 140 this.Controls.Add(this.xAxisLabel); 141 this.Controls.Add(this.xAxisComboBox); 142 this.Controls.Add(this.yAxisLabel); 143 this.Controls.Add(this.yAxisComboBox); 195 this.Controls.Add(this.splitContainer); 144 196 this.Name = "RunCollectionBoxPlotView"; 145 this.Size = new System.Drawing.Size(5 52, 316);197 this.Size = new System.Drawing.Size(543, 416); 146 198 ((System.ComponentModel.ISupportInitialize)(this.chart)).EndInit(); 199 this.splitContainer.Panel1.ResumeLayout(false); 200 this.splitContainer.Panel1.PerformLayout(); 201 this.splitContainer.Panel2.ResumeLayout(false); 202 this.splitContainer.ResumeLayout(false); 203 this.statisticsGroupBox.ResumeLayout(false); 147 204 this.ResumeLayout(false); 148 this.PerformLayout();149 205 150 206 } … … 156 212 private System.Windows.Forms.Label yAxisLabel; 157 213 private System.Windows.Forms.ComboBox yAxisComboBox; 158 private System.Windows.Forms.DataVisualization.Charting.Chart chart;214 private HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart chart; 159 215 private System.Windows.Forms.Label noRunsLabel; 216 private System.Windows.Forms.SplitContainer splitContainer; 217 private Data.Views.StringConvertibleMatrixView statisticsMatrixView; 218 private System.Windows.Forms.GroupBox statisticsGroupBox; 219 private System.Windows.Forms.ToolTip tooltip; 160 220 } 161 221 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBoxPlotView.cs
r4211 r4652 25 25 using System.Windows.Forms; 26 26 using System.Windows.Forms.DataVisualization.Charting; 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Data; … … 50 51 this.chart.Series.Clear(); 51 52 this.chart.ChartAreas.Add(BoxPlotChartAreaName); 53 this.chart.CustomizeAllChartAreas(); 52 54 } 53 55 … … 168 170 this.chart.Series.Add(s); 169 171 172 UpdateStatistics(); 170 173 if (seriesCache.Count > 0) { 171 174 Series boxPlotSeries = CreateBoxPlotSeries(); … … 176 179 } 177 180 UpdateNoRunsVisibleLabel(); 181 } 182 183 private void UpdateStatistics() { 184 DoubleMatrix matrix = new DoubleMatrix(6, seriesCache.Count); 185 matrix.SortableView = false; 186 List<string> columnNames = new List<string>(); 187 foreach (Series series in seriesCache.Values) { 188 DataPoint datapoint = series.Points.FirstOrDefault(); 189 if (datapoint != null) { 190 IRun run = (IRun)datapoint.Tag; 191 string selectedAxis = (string)xAxisComboBox.SelectedItem; 192 IItem value = null; 193 194 if (Enum.IsDefined(typeof(AxisDimension), selectedAxis)) { 195 AxisDimension axisDimension = (AxisDimension)Enum.Parse(typeof(AxisDimension), selectedAxis); 196 switch (axisDimension) { 197 case AxisDimension.Color: value = new StringValue(run.Color.ToString()); 198 break; 199 } 200 } else value = Content.GetValue(run, selectedAxis); 201 string columnName = string.Empty; 202 if (value is DoubleValue || value is IntValue) 203 columnName = selectedAxis + ": "; 204 columnName += value.ToString(); 205 columnNames.Add(columnName); 206 } 207 } 208 matrix.ColumnNames = columnNames; 209 matrix.RowNames = new string[] { "Mean", "Median", "Standard deviation", "Variance", "25th percentile", "75th percentile" }; 210 211 for (int i = 0; i < seriesCache.Count; i++) { 212 Series series = seriesCache.ElementAt(i).Value; 213 double[] seriesValues = series.Points.Select(p => p.YValues[0]).OrderBy(d => d).ToArray(); 214 matrix[0, i] = seriesValues.Average(); 215 matrix[1, i] = seriesValues.Median(); 216 matrix[2, i] = seriesValues.StandardDeviation(); 217 matrix[3, i] = seriesValues.Variance(); 218 matrix[4, i] = seriesValues.Percentile(0.25); 219 matrix[5, i] = seriesValues.Percentile(0.75); 220 } 221 statisticsMatrixView.Content = matrix; 178 222 } 179 223 … … 214 258 Series series = seriesCache[xValue.Value]; 215 259 DataPoint point = new DataPoint(xValue.Value, yValue.Value); 260 point.Tag = run; 216 261 series.Points.Add(point); 217 262 } … … 293 338 SetCustomAxisLabels(xAxis, xAxisComboBox.SelectedIndex - axisDimensionCount); 294 339 SetCustomAxisLabels(yAxis, yAxisComboBox.SelectedIndex - axisDimensionCount); 340 if (xAxisComboBox.SelectedItem != null) 341 xAxis.Title = xAxisComboBox.SelectedItem.ToString(); 342 if (yAxisComboBox.SelectedItem != null) 343 yAxis.Title = yAxisComboBox.SelectedItem.ToString(); 295 344 } 296 345 … … 340 389 } 341 390 } 391 392 private void chart_MouseMove(object sender, MouseEventArgs e) { 393 string newTooltipText = string.Empty; 394 string oldTooltipText; 395 HitTestResult h = this.chart.HitTest(e.X, e.Y); 396 if (h.ChartElementType == ChartElementType.AxisLabels) { 397 newTooltipText = ((CustomLabel)h.Object).ToolTip; 398 } 399 400 oldTooltipText = this.tooltip.GetToolTip(chart); 401 if (newTooltipText != oldTooltipText) 402 this.tooltip.SetToolTip(chart, newTooltipText); 403 } 342 404 #endregion 405 343 406 } 344 407 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r4636 r4652 131 131 AddDataPoint(run); 132 132 UpdateCursorInterval(); 133 chart.ChartAreas[0].RecalculateAxesScale(); 133 134 134 135
Note: See TracChangeset
for help on using the changeset viewer.