- Timestamp:
- 07/06/17 10:19:37 (8 years ago)
- Location:
- stable
- Files:
-
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Views (added) merged: 14240-14241,14248,14251,14277,14330,14351,14421,14449,14497-14499,14542,14591-14592,14762,14825
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/DensityChart.cs
r14099 r15131 30 30 } 31 31 32 public void UpdateChart(IList<string> data, double minimumHeight = 0.1) { 33 if (data == null || !data.Any()) 34 return; 35 UpdateChartWithBuckets(CalculateBuckets(data)); 36 } 37 38 32 39 public void UpdateChart(IList<double> data, double min, double max, int numBuckets, double minimumHeight = 0.1) { 33 40 if (data == null || numBuckets < 0 || min > max || max < min) 34 41 return; 35 42 36 var buckets = CalculateBuckets(data, numBuckets, min, max); 43 UpdateChartWithBuckets(CalculateBuckets(data, numBuckets, min, max)); 44 } 37 45 46 47 private void UpdateChartWithBuckets(double[] buckets) { 38 48 // set minimum height of all non-zero buckets on 10% of maximum 39 49 double minHeight = buckets.Max() * 0.1; … … 69 79 return buckets; 70 80 } 81 private double[] CalculateBuckets(IList<string> data) { 82 return data.GroupBy(val => val).OrderBy(g => g.Key).Select(g => (double)g.Count()).Concat(new double[] { 0.0 }).ToArray(); 83 } 71 84 } 72 85 } -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/GradientChart.Designer.cs
r14166 r15131 25 25 private void InitializeComponent() { 26 26 this.components = new System.ComponentModel.Container(); 27 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GradientChart));28 27 System.Windows.Forms.DataVisualization.Charting.VerticalLineAnnotation verticalLineAnnotation1 = new System.Windows.Forms.DataVisualization.Charting.VerticalLineAnnotation(); 29 28 System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); -
stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Controls/GradientChart.cs
r14570 r15131 21 21 22 22 using System; 23 using System.Collections; 23 24 using System.Collections.Generic; 24 25 using System.Drawing; … … 34 35 35 36 namespace HeuristicLab.Problems.DataAnalysis.Views { 36 public partial class GradientChart : UserControl {37 public partial class GradientChart : UserControl, IGradientChart { 37 38 private ModifiableDataset sharedFixedVariables; // used for syncronising variable values between charts 38 39 private ModifiableDataset internalDataset; // holds the x values for each point drawn … … 319 320 if (updateOnFinish) 320 321 Update(); 321 } 322 catch (OperationCanceledException) { } 323 catch (AggregateException ae) { 322 } catch (OperationCanceledException) { } catch (AggregateException ae) { 324 323 if (!ae.InnerExceptions.Any(e => e is OperationCanceledException)) 325 324 throw; … … 347 346 try { 348 347 chart.ChartAreas[0].RecalculateAxesScale(); 349 } 350 catch (InvalidOperationException) { 348 } catch (InvalidOperationException) { 351 349 // Can occur if eg. axis min == axis max 352 350 } … … 381 379 xvalues.Add(xmin + i * step); 382 380 383 var variables = sharedFixedVariables.DoubleVariables.ToList(); 384 internalDataset = new ModifiableDataset(variables, 385 variables.Select(x => x == FreeVariable 386 ? xvalues 387 : Enumerable.Repeat(sharedFixedVariables.GetDoubleValue(x, 0), xvalues.Count).ToList() 388 ) 389 ); 381 if (sharedFixedVariables == null) 382 return; 383 384 var variables = sharedFixedVariables.VariableNames.ToList(); 385 var values = new List<IList>(); 386 foreach (var varName in variables) { 387 if (varName == FreeVariable) { 388 values.Add(xvalues); 389 } else if (sharedFixedVariables.VariableHasType<double>(varName)) { 390 values.Add(Enumerable.Repeat(sharedFixedVariables.GetDoubleValue(varName, 0), xvalues.Count).ToList()); 391 } else if (sharedFixedVariables.VariableHasType<string>(varName)) { 392 values.Add(Enumerable.Repeat(sharedFixedVariables.GetStringValue(varName, 0), xvalues.Count).ToList()); 393 } 394 } 395 396 internalDataset = new ModifiableDataset(variables, values); 390 397 } 391 398 … … 552 559 553 560 private static bool SolutionsCompatible(IEnumerable<IRegressionSolution> solutions) { 554 foreach (var solution1 in solutions) { 555 var variables1 = solution1.ProblemData.Dataset.DoubleVariables; 556 foreach (var solution2 in solutions) { 557 if (solution1 == solution2) 558 continue; 559 var variables2 = solution2.ProblemData.Dataset.DoubleVariables; 560 if (!variables1.All(variables2.Contains)) 561 return false; 561 var refSolution = solutions.First(); 562 var refSolVars = refSolution.ProblemData.Dataset.VariableNames; 563 foreach (var solution in solutions.Skip(1)) { 564 var variables1 = solution.ProblemData.Dataset.VariableNames; 565 if (!variables1.All(refSolVars.Contains)) 566 return false; 567 568 foreach (var factorVar in variables1.Where(solution.ProblemData.Dataset.VariableHasType<string>)) { 569 var distinctVals = refSolution.ProblemData.Dataset.GetStringValues(factorVar).Distinct(); 570 if (solution.ProblemData.Dataset.GetStringValues(factorVar).Any(val => !distinctVals.Contains(val))) return false; 562 571 } 563 572 } … … 608 617 private void sharedFixedVariables_ItemChanged(object o, EventArgs<int, int> e) { 609 618 if (o != sharedFixedVariables) return; 610 var variables = sharedFixedVariables. DoubleVariables.ToList();619 var variables = sharedFixedVariables.VariableNames.ToList(); 611 620 var rowIndex = e.Value; 612 621 var columnIndex = e.Value2; … … 614 623 var variableName = variables[columnIndex]; 615 624 if (variableName == FreeVariable) return; 616 var v = sharedFixedVariables.GetDoubleValue(variableName, rowIndex); 617 var values = new List<double>(Enumerable.Repeat(v, DrawingSteps)); 618 internalDataset.ReplaceVariable(variableName, values); 625 if (internalDataset.VariableHasType<double>(variableName)) { 626 var v = sharedFixedVariables.GetDoubleValue(variableName, rowIndex); 627 var values = new List<double>(Enumerable.Repeat(v, internalDataset.Rows)); 628 internalDataset.ReplaceVariable(variableName, values); 629 } else if (internalDataset.VariableHasType<string>(variableName)) { 630 var v = sharedFixedVariables.GetStringValue(variableName, rowIndex); 631 var values = new List<String>(Enumerable.Repeat(v, internalDataset.Rows)); 632 internalDataset.ReplaceVariable(variableName, values); 633 } else { 634 // unsupported type 635 throw new NotSupportedException(); 636 } 619 637 } 620 638 … … 635 653 UpdateCursor(); 636 654 } 637 void UpdateCursor() {655 private void UpdateCursor() { 638 656 var x = VerticalLineAnnotation.X; 639 657 sharedFixedVariables.SetVariableValue(x, FreeVariable, 0);
Note: See TracChangeset
for help on using the changeset viewer.