Changeset 6011 for branches/histogram
- Timestamp:
- 04/15/11 14:54:43 (14 years ago)
- Location:
- branches/histogram
- Files:
-
- 60 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 5962-5963,5971-5972,5975-5976,5983-5984,5987,5993,5997-5998,6002-6003,6009
- Property svn:mergeinfo changed
-
branches/histogram/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/HeuristicLab.Algorithms.DataAnalysis.Views-3.4.csproj
r5829 r6011 114 114 </ItemGroup> 115 115 <ItemGroup> 116 <Compile Include="KMeansClusteringModelView.cs"> 117 <SubType>UserControl</SubType> 118 </Compile> 119 <Compile Include="KMeansClusteringModelView.Designer.cs"> 120 <DependentUpon>KMeansClusteringModelView.cs</DependentUpon> 121 </Compile> 116 122 <Compile Include="SupportVectorMachineModelSupportVectorsView.cs"> 117 123 <SubType>UserControl</SubType> -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/SupportVectorMachineModelSupportVectorsView.cs
r5834 r6011 25 25 26 26 namespace HeuristicLab.Algorithms.DataAnalysis.Views { 27 [View("S upportVectorMachineModel SupportVectorsView")]27 [View("SVM Support Vectors")] 28 28 [Content(typeof(SupportVectorMachineModel), false)] 29 29 public partial class SupportVectorMachineModelSupportVectorsView : AsynchronousContentView { -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/SupportVectorMachineModelView.cs
r5834 r6011 26 26 27 27 namespace HeuristicLab.Algorithms.DataAnalysis.Views { 28 [View("S upportVectorMachineModel view")]28 [View("SVM Model")] 29 29 [Content(typeof(SupportVectorMachineModel), true)] 30 30 public partial class SupportVectorMachineModelView : AsynchronousContentView { -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/AlglibUtil.cs
r5809 r6011 27 27 public static class AlglibUtil { 28 28 public static double[,] PrepareInputMatrix(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) { 29 List<int> allowedRows = CalculateAllowedRows(dataset, variables, rows).ToList(); 29 List<string> variablesList = variables.ToList(); 30 List<int> rowsList = rows.ToList(); 30 31 31 double[,] matrix = new double[ allowedRows.Count, variables.Count()];32 for (int row = 0; row < allowedRows.Count; row++) {32 double[,] matrix = new double[rowsList.Count, variablesList.Count]; 33 for (int row = 0; row < rowsList.Count; row++) { 33 34 int col = 0; 34 35 foreach (string column in variables) { 35 matrix[row, col] = dataset[column, row ];36 matrix[row, col] = dataset[column, rowsList[row]]; 36 37 col++; 37 38 } … … 39 40 return matrix; 40 41 } 41 42 private static IEnumerable<int> CalculateAllowedRows(Dataset dataset, IEnumerable<string> variables, IEnumerable<int> rows) {43 // return only rows that contain no infinity or NaN values44 return from row in rows45 where (from variable in variables46 let x = dataset[variable, row]47 where double.IsInfinity(x) || double.IsNaN(x)48 select 1)49 .Any() == false50 select row;51 }52 42 } 53 43 } -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearDiscriminantAnalysis.cs
r5809 r6011 73 73 int nClasses = problemData.ClassNames.Count(); 74 74 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables.Concat(new string[] { targetVariable }), rows); 75 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x))) 76 throw new NotSupportedException("Linear discriminant analysis does not support NaN or infinity values in the input dataset."); 75 77 76 78 // change class values into class index -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/Linear/LinearRegression.cs
r5809 r6011 76 76 IEnumerable<int> rows = Enumerable.Range(samplesStart, samplesEnd - samplesStart); 77 77 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables.Concat(new string[] { targetVariable }), rows); 78 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x))) 79 throw new NotSupportedException("Linear regression does not support NaN or infinity values in the input dataset."); 78 80 79 81 alglib.linearmodel lm = new alglib.linearmodel(); -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/SupportVectorMachine/SupportVectorMachineUtil.cs
r5809 r6011 41 41 int maxNodeIndex = 0; 42 42 int svmProblemRowIndex = 0; 43 List<string> inputVariablesList = inputVariables.ToList(); 43 44 foreach (int row in rowIndices) { 44 45 tempRow = new List<SVM.Node>(); 45 foreach (var inputVariable in inputVariables) { 46 int col = dataset.GetVariableIndex(inputVariable); 47 double value = dataset[row, col]; 46 int colIndex = 1; // make sure the smallest node index for SVM = 1 47 foreach (var inputVariable in inputVariablesList) { 48 double value = dataset[row, dataset.GetVariableIndex(inputVariable)]; 49 // SVM also works with missing values 50 // => don't add NaN values in the dataset to the sparse SVM matrix representation 48 51 if (!double.IsNaN(value)) { 49 int nodeIndex = col + 1; // make sure the smallest nodeIndex is 1 (libSVM convention) 50 tempRow.Add(new SVM.Node(nodeIndex, value)); 51 if (nodeIndex > maxNodeIndex) maxNodeIndex = nodeIndex; 52 tempRow.Add(new SVM.Node(colIndex, value)); // nodes must be sorted in ascending ordered by column index 53 if (colIndex > maxNodeIndex) maxNodeIndex = colIndex; 52 54 } 55 colIndex++; 53 56 } 54 nodes[svmProblemRowIndex++] = tempRow. OrderBy(x => x.Index).ToArray(); // make sure the values are sorted by node index57 nodes[svmProblemRowIndex++] = tempRow.ToArray(); 55 58 } 56 59 -
branches/histogram/HeuristicLab.Algorithms.DataAnalysis/3.4/kMeans/KMeansClustering.cs
r5914 r6011 92 92 int[] xyc; 93 93 double[,] inputMatrix = AlglibUtil.PrepareInputMatrix(dataset, allowedInputVariables, rows); 94 if (inputMatrix.Cast<double>().Any(x => double.IsNaN(x) || double.IsInfinity(x))) 95 throw new NotSupportedException("k-Means clustering does not support NaN or infinity values in the input dataset."); 96 94 97 alglib.kmeansgenerate(inputMatrix, inputMatrix.GetLength(0), inputMatrix.GetLength(1), k, restarts + 1, out info, out centers, out xyc); 95 98 if (info != 1) throw new ArgumentException("Error in calculation of k-Means clustering solution"); -
branches/histogram/HeuristicLab.Analysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Analysis (added) merged: 5997
- Property svn:mergeinfo changed
-
branches/histogram/HeuristicLab.Analysis.Views/3.3/DataRowVisualPropertiesControl.Designer.cs
r6010 r6011 57 57 this.commonGroupBox = new System.Windows.Forms.GroupBox(); 58 58 this.histoGramGroupBox = new System.Windows.Forms.GroupBox(); 59 this.secondXAxisCheckBox = new System.Windows.Forms.CheckBox(); 59 60 ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).BeginInit(); 60 61 this.commonGroupBox.SuspendLayout(); … … 104 105 this.startIndexZeroCheckBox.AutoSize = true; 105 106 this.startIndexZeroCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 106 this.startIndexZeroCheckBox.Location = new System.Drawing.Point(17, 98);107 this.startIndexZeroCheckBox.Location = new System.Drawing.Point(17, 121); 107 108 this.startIndexZeroCheckBox.Name = "startIndexZeroCheckBox"; 108 109 this.startIndexZeroCheckBox.Size = new System.Drawing.Size(89, 17); … … 164 165 | System.Windows.Forms.AnchorStyles.Right))); 165 166 this.commonGroupBox.Controls.Add(this.colorButton); 167 this.commonGroupBox.Controls.Add(this.secondXAxisCheckBox); 166 168 this.commonGroupBox.Controls.Add(this.secondYAxisCheckBox); 167 169 this.commonGroupBox.Controls.Add(this.label1); … … 171 173 this.commonGroupBox.Location = new System.Drawing.Point(3, 3); 172 174 this.commonGroupBox.Name = "commonGroupBox"; 173 this.commonGroupBox.Size = new System.Drawing.Size(473, 1 22);175 this.commonGroupBox.Size = new System.Drawing.Size(473, 142); 174 176 this.commonGroupBox.TabIndex = 7; 175 177 this.commonGroupBox.TabStop = false; … … 183 185 this.histoGramGroupBox.Controls.Add(this.exactBinsCheckBox); 184 186 this.histoGramGroupBox.Controls.Add(this.label3); 185 this.histoGramGroupBox.Location = new System.Drawing.Point(3, 1 31);187 this.histoGramGroupBox.Location = new System.Drawing.Point(3, 151); 186 188 this.histoGramGroupBox.Name = "histoGramGroupBox"; 187 189 this.histoGramGroupBox.Size = new System.Drawing.Size(473, 49); … … 190 192 this.histoGramGroupBox.Text = "Histogram"; 191 193 // 194 // secondXAxisCheckBox 195 // 196 this.secondXAxisCheckBox.AutoSize = true; 197 this.secondXAxisCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight; 198 this.secondXAxisCheckBox.Location = new System.Drawing.Point(8, 98); 199 this.secondXAxisCheckBox.Name = "secondXAxisCheckBox"; 200 this.secondXAxisCheckBox.Size = new System.Drawing.Size(98, 17); 201 this.secondXAxisCheckBox.TabIndex = 1; 202 this.secondXAxisCheckBox.Text = "Second X Axis:"; 203 this.secondXAxisCheckBox.UseVisualStyleBackColor = true; 204 this.secondXAxisCheckBox.CheckedChanged += new System.EventHandler(this.secondXAxisCheckBox_CheckedChanged); 205 // 192 206 // DataRowVisualPropertiesControl 193 207 // … … 197 211 this.Controls.Add(this.commonGroupBox); 198 212 this.Name = "DataRowVisualPropertiesControl"; 199 this.Size = new System.Drawing.Size(479, 185);213 this.Size = new System.Drawing.Size(479, 205); 200 214 ((System.ComponentModel.ISupportInitialize)(this.binsNumericUpDown)).EndInit(); 201 215 this.commonGroupBox.ResumeLayout(false); … … 221 235 private System.Windows.Forms.GroupBox commonGroupBox; 222 236 private System.Windows.Forms.GroupBox histoGramGroupBox; 237 private System.Windows.Forms.CheckBox secondXAxisCheckBox; 223 238 } 224 239 } -
branches/histogram/HeuristicLab.Analysis.Views/3.3/DataRowVisualPropertiesControl.cs
r6010 r6011 53 53 colorButton.BackColor = SystemColors.Control; 54 54 secondYAxisCheckBox.Checked = false; 55 secondXAxisCheckBox.Checked = false; 55 56 startIndexZeroCheckBox.Checked = false; 56 57 binsNumericUpDown.Value = 1; … … 58 59 } else { 59 60 chartTypeComboBox.SelectedItem = Content.ChartType; 60 colorButton.BackColor = Content.Color; 61 if (Content.Color.IsEmpty) { 62 colorButton.BackColor = SystemColors.Control; 63 colorButton.Text = "?"; 64 } else colorButton.BackColor = Content.Color; 61 65 secondYAxisCheckBox.Checked = Content.SecondYAxis; 66 secondXAxisCheckBox.Checked = Content.SecondXAxis; 62 67 startIndexZeroCheckBox.Checked = Content.StartIndexZero; 63 68 binsNumericUpDown.Value = Content.Bins; … … 85 90 Content.Color = colorDialog.Color; 86 91 colorButton.BackColor = Content.Color; 92 colorButton.Text = String.Empty; 87 93 } 88 94 } … … 91 97 if (!SuppressEvents && Content != null) { 92 98 Content.SecondYAxis = secondYAxisCheckBox.Checked; 99 } 100 } 101 102 private void secondXAxisCheckBox_CheckedChanged(object sender, EventArgs e) { 103 if (!SuppressEvents && Content != null) { 104 Content.SecondXAxis = secondXAxisCheckBox.Checked; 93 105 } 94 106 } -
branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.cs
r6010 r6011 142 142 } 143 143 series.YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary; 144 series.XAxisType = row.VisualProperties.SecondXAxis ? AxisType.Secondary : AxisType.Primary; 144 145 if (row.VisualProperties.Color != Color.Empty) series.Color = row.VisualProperties.Color; 145 146 series.ToolTip = row.Name + " X = #INDEX, Y = #VAL"; … … 305 306 chart.Series[row.Name].ChartType = SeriesChartType.Column; 306 307 chart.Series[row.Name]["PointWidth"] = "1"; 308 CalculateHistogram(chart.Series[row.Name], row); 307 309 break; 308 310 default: … … 311 313 } 312 314 chart.Series[row.Name].YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary; 315 chart.Series[row.Name].XAxisType = row.VisualProperties.SecondXAxis ? AxisType.Secondary : AxisType.Primary; 313 316 if (row.VisualProperties.Color != Color.Empty) chart.Series[row.Name].Color = row.VisualProperties.Color; 314 317 chart.ChartAreas[0].RecalculateAxesScale(); … … 444 447 445 448 private void FillSeriesWithRowValues(Series series, DataRow row) { 446 if (row.VisualProperties.ChartType == DataRowVisualProperties.DataRowChartType.Histogram) { 447 series.Points.Clear(); 448 if (!row.Values.Any()) return; 449 int bins = row.VisualProperties.Bins; 450 451 double minValue = row.Values.Min(); 452 double maxValue = row.Values.Max(); 453 double intervalWidth = (maxValue - minValue) / bins; 454 if (intervalWidth <= 0) return; 455 456 if (!row.VisualProperties.ExactBins) { 457 intervalWidth = HumanRoundRange(intervalWidth); 458 minValue = Math.Floor(minValue / intervalWidth) * intervalWidth; 459 maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth; 460 } 461 462 double current = minValue, intervalCenter = intervalWidth / 2.0; 463 int frequency = 0; 464 foreach (double v in row.Values.Where(x => !IsInvalidValue(x)).OrderBy(x => x)) { 465 while (v > current + intervalWidth) { 466 series.Points.AddXY(current + intervalCenter, frequency); 467 current += intervalWidth; 468 frequency = 0; 469 } 470 frequency++; 471 } 472 series.Points.AddXY(current + intervalCenter, frequency); 473 } else { 474 for (int i = 0; i < row.Values.Count; i++) { 475 var value = row.Values[i]; 476 DataPoint point = new DataPoint(); 477 point.XValue = row.VisualProperties.StartIndexZero ? i : i + 1; 478 if (IsInvalidValue(value)) 479 point.IsEmpty = true; 480 else 481 point.YValues = new double[] { value }; 482 series.Points.Add(point); 483 } 484 } 449 switch (row.VisualProperties.ChartType) { 450 case DataRowVisualProperties.DataRowChartType.Histogram: 451 CalculateHistogram(series, row); 452 break; 453 default: { 454 for (int i = 0; i < row.Values.Count; i++) { 455 var value = row.Values[i]; 456 DataPoint point = new DataPoint(); 457 point.XValue = row.VisualProperties.StartIndexZero ? i : i + 1; 458 if (IsInvalidValue(value)) 459 point.IsEmpty = true; 460 else 461 point.YValues = new double[] { value }; 462 series.Points.Add(point); 463 } 464 } 465 break; 466 } 467 } 468 469 private void CalculateHistogram(Series series, DataRow row) { 470 series.Points.Clear(); 471 if (!row.Values.Any()) return; 472 int bins = row.VisualProperties.Bins; 473 474 double minValue = row.Values.Min(); 475 double maxValue = row.Values.Max(); 476 double intervalWidth = (maxValue - minValue) / bins; 477 if (intervalWidth <= 0) return; 478 479 if (!row.VisualProperties.ExactBins) { 480 intervalWidth = HumanRoundRange(intervalWidth); 481 minValue = Math.Floor(minValue / intervalWidth) * intervalWidth; 482 maxValue = Math.Ceiling(maxValue / intervalWidth) * intervalWidth; 483 } 484 485 double current = minValue, intervalCenter = intervalWidth / 2.0; 486 int frequency = 0; 487 foreach (double v in row.Values.Where(x => !IsInvalidValue(x)).OrderBy(x => x)) { 488 while (v > current + intervalWidth) { 489 series.Points.AddXY(current + intervalCenter, frequency); 490 current += intervalWidth; 491 frequency = 0; 492 } 493 frequency++; 494 } 495 series.Points.AddXY(current + intervalCenter, frequency); 485 496 } 486 497 -
branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesDialog.cs
r6010 r6011 64 64 private void cancelButton_Click(object sender, System.EventArgs e) { 65 65 DialogResult = DialogResult.Cancel; 66 Content.VisualProperties = originalDataTableVPs;67 66 foreach (DataRow row in Content.Rows) { 68 67 row.VisualProperties = originalDataRowVPs[row.Name]; 69 68 } 69 Content.VisualProperties = originalDataTableVPs; 70 70 Close(); 71 71 } -
branches/histogram/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs
r6010 r6011 61 61 } 62 62 } 63 private bool secondXAxis; 64 public bool SecondXAxis { 65 get { return secondXAxis; } 66 set { 67 if (secondXAxis != value) { 68 secondXAxis = value; 69 OnPropertyChanged("SecondXAxis"); 70 } 71 } 72 } 63 73 private Color color; 64 74 public Color Color { … … 113 123 set { secondYAxis = value; } 114 124 } 125 [Storable(Name = "SecondXAxis")] 126 private bool StorableSecondXAxis { 127 get { return secondXAxis; } 128 set { secondXAxis = value; } 129 } 115 130 [Storable(Name = "Color")] 116 131 private Color StorableColor { … … 141 156 this.chartType = original.chartType; 142 157 this.secondYAxis = original.secondYAxis; 158 this.secondXAxis = original.secondXAxis; 143 159 this.color = original.color; 144 160 this.startIndexZero = original.startIndexZero; 161 this.bins = original.bins; 162 this.exactBins = original.exactBins; 145 163 } 146 164 public DataRowVisualProperties() { 147 165 chartType = DataRowChartType.Line; 148 166 secondYAxis = false; 167 secondXAxis = false; 149 168 color = Color.Empty; 150 169 startIndexZero = false; 170 bins = 10; 171 exactBins = false; 151 172 } 152 173 -
branches/histogram/HeuristicLab.Analysis/3.3/Tests
- Property svn:ignore
-
old new 1 1 bin 2 2 obj 3 *.vs10x
-
- Property svn:ignore
-
branches/histogram/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.Designer.cs
r5908 r6011 59 59 // valueTextBox 60 60 // 61 this.valueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 61 this.valueTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 62 62 | System.Windows.Forms.AnchorStyles.Right))); 63 63 this.valueTextBox.Location = new System.Drawing.Point(17, 0); 64 64 this.valueTextBox.Name = "valueTextBox"; 65 65 this.valueTextBox.Size = new System.Drawing.Size(135, 20); 66 this.valueTextBox.TabIndex = 1;66 this.valueTextBox.TabIndex = 2; 67 67 this.valueTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.valueTextBox_KeyDown); 68 68 this.valueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.valueTextBox_Validating); … … 80 80 this.valueLabel.Name = "valueLabel"; 81 81 this.valueLabel.Size = new System.Drawing.Size(37, 13); 82 this.valueLabel.TabIndex = 0;82 this.valueLabel.TabIndex = 1; 83 83 this.valueLabel.Text = "&Value:"; 84 84 // … … 101 101 this.splitContainer.SplitterDistance = 41; 102 102 this.splitContainer.SplitterWidth = 1; 103 this.splitContainer.TabIndex = 2; 103 this.splitContainer.TabIndex = 0; 104 this.splitContainer.TabStop = false; 104 105 // 105 106 // StringConvertibleValueView -
branches/histogram/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
r5908 r6011 91 91 if (e.KeyCode == Keys.Escape) { 92 92 valueTextBox.Text = Content.GetValue(); 93 valueLabel. Focus(); // select label to validate data93 valueLabel.Select(); // select label to validate data 94 94 } 95 95 } -
branches/histogram/HeuristicLab.Encodings.PermutationEncoding
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Analyzers/SymbolicExpressionSymbolFrequencyAnalyzer.cs
r5809 r6011 25 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 27 28 using HeuristicLab.Operators; 28 29 using HeuristicLab.Optimization; … … 40 41 private const string ResultsParameterName = "Results"; 41 42 private const string SymbolFrequenciesParameterName = "SymbolFrequencies"; 43 private const string AggregateSymbolsWithDifferentSubtreeCountParameterName = "AggregateSymbolsWithDifferentSubtreeCount"; 42 44 43 45 #region parameter properties … … 51 53 get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; } 52 54 } 55 public IValueParameter<BoolValue> AggregateSymbolsWithDifferentSubtreeCountParameter { 56 get { return (IValueParameter<BoolValue>)Parameters[AggregateSymbolsWithDifferentSubtreeCountParameterName]; } 57 } 53 58 #endregion 54 59 #region properties 55 public DataTable SymbolFrequencies{56 get { return SymbolFrequenciesParameter.ActualValue; }57 set { SymbolFrequenciesParameter.ActualValue = value; }60 public BoolValue AggregrateSymbolsWithDifferentSubtreeCount { 61 get { return AggregateSymbolsWithDifferentSubtreeCountParameter.Value; } 62 set { AggregateSymbolsWithDifferentSubtreeCountParameter.Value = value; } 58 63 } 59 64 #endregion … … 65 70 : base() { 66 71 Parameters.Add(new ScopeTreeLookupParameter<ISymbolicExpressionTree>(SymbolicExpressionTreeParameterName, "The symbolic expression trees to analyze.")); 67 Parameters.Add(new ValueLookupParameter<DataTable>(SymbolFrequenciesParameterName, "The data table to store the symbol frequencies."));72 Parameters.Add(new LookupParameter<DataTable>(SymbolFrequenciesParameterName, "The data table to store the symbol frequencies.")); 68 73 Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection where the symbol frequencies should be stored.")); 74 Parameters.Add(new ValueParameter<BoolValue>(AggregateSymbolsWithDifferentSubtreeCountParameterName, "Flag that indicates if the frequencies of symbols with the same name but different number of sub-trees should be aggregated.", new BoolValue(true))); 69 75 } 70 76 public override IDeepCloneable Clone(Cloner cloner) { … … 72 78 } 73 79 80 [StorableHook(HookType.AfterDeserialization)] 81 private void AfterDeserialization() { 82 #region remove with HL 3.4 83 if (!Parameters.ContainsKey(AggregateSymbolsWithDifferentSubtreeCountParameterName)) 84 Parameters.Add(new ValueParameter<BoolValue>(AggregateSymbolsWithDifferentSubtreeCountParameterName, "Flag that indicates if the frequencies of symbols with the same name but different number of sub-trees should be aggregated.", new BoolValue(true))); 85 #endregion 86 } 87 74 88 public override IOperation Apply() { 75 89 ItemArray<ISymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue; 76 90 ResultCollection results = ResultsParameter.ActualValue; 91 DataTable symbolFrequencies = SymbolFrequenciesParameter.ActualValue; 92 if (symbolFrequencies == null) { 93 symbolFrequencies = new DataTable("Symbol frequencies", "Relative frequency of symbols aggregated over the whole population."); 94 symbolFrequencies.VisualProperties.YAxisTitle = "Relative Symbol Frequency"; 77 95 78 if (SymbolFrequencies == null) { 79 SymbolFrequencies = new DataTable("Symbol frequencies", "Relative frequency of symbols aggregated over the whole population."); 80 SymbolFrequencies.VisualProperties.YAxisTitle = "Relative Symbol Frequency"; 81 results.Add(new Result("Symbol frequencies", SymbolFrequencies)); 96 SymbolFrequenciesParameter.ActualValue = symbolFrequencies; 97 results.Add(new Result("Symbol frequencies", symbolFrequencies)); 82 98 } 83 99 84 100 // all rows must have the same number of values so we can just take the first 85 int numberOfValues = SymbolFrequencies.Rows.Select(r => r.Values.Count).DefaultIfEmpty().First();101 int numberOfValues = symbolFrequencies.Rows.Select(r => r.Values.Count).DefaultIfEmpty().First(); 86 102 87 foreach (var pair in SymbolicExpressionSymbolFrequencyAnalyzer.CalculateSymbolFrequencies(expressions )) {88 if (! SymbolFrequencies.Rows.ContainsKey(pair.Key)) {103 foreach (var pair in SymbolicExpressionSymbolFrequencyAnalyzer.CalculateSymbolFrequencies(expressions, AggregrateSymbolsWithDifferentSubtreeCount.Value)) { 104 if (!symbolFrequencies.Rows.ContainsKey(pair.Key)) { 89 105 // initialize a new row for the symbol and pad with zeros 90 106 DataRow row = new DataRow(pair.Key, "", Enumerable.Repeat(0.0, numberOfValues)); 91 107 row.VisualProperties.StartIndexZero = true; 92 SymbolFrequencies.Rows.Add(row);108 symbolFrequencies.Rows.Add(row); 93 109 } 94 SymbolFrequencies.Rows[pair.Key].Values.Add(pair.Value);110 symbolFrequencies.Rows[pair.Key].Values.Add(pair.Value); 95 111 } 96 112 97 113 // add a zero for each data row that was not modified in the previous loop 98 foreach (var row in SymbolFrequencies.Rows.Where(r => r.Values.Count != numberOfValues + 1))114 foreach (var row in symbolFrequencies.Rows.Where(r => r.Values.Count != numberOfValues + 1)) 99 115 row.Values.Add(0.0); 100 116 … … 102 118 } 103 119 104 public static IEnumerable<KeyValuePair<string, double>> CalculateSymbolFrequencies(IEnumerable<ISymbolicExpressionTree> trees ) {120 public static IEnumerable<KeyValuePair<string, double>> CalculateSymbolFrequencies(IEnumerable<ISymbolicExpressionTree> trees, bool aggregateDifferentNumberOfSubtrees = true) { 105 121 Dictionary<string, double> symbolFrequencies = new Dictionary<string, double>(); 106 122 int totalNumberOfSymbols = 0; … … 108 124 foreach (var tree in trees) { 109 125 foreach (var node in tree.IterateNodesPrefix()) { 110 if (symbolFrequencies.ContainsKey(node.Symbol.Name)) symbolFrequencies[node.Symbol.Name] += 1; 111 else symbolFrequencies.Add(node.Symbol.Name, 1); 126 string symbolName; 127 if (aggregateDifferentNumberOfSubtrees) symbolName = node.Symbol.Name; 128 else symbolName = node.Symbol.Name + "-" + node.SubtreesCount; 129 if (symbolFrequencies.ContainsKey(symbolName)) symbolFrequencies[symbolName] += 1; 130 else symbolFrequencies.Add(symbolName, 1); 112 131 totalNumberOfSymbols++; 113 132 } -
branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r5925 r6011 103 103 public static void PTC2(IRandom random, ISymbolicExpressionTreeNode seedNode, 104 104 int maxLength, int maxDepth) { 105 // make sure it is possible to create a trees smaller than maxLength and maxDepth 106 if (seedNode.Grammar.GetMinimumExpressionLength(seedNode.Symbol) > maxLength) 107 throw new ArgumentException("Cannot create trees of length " + maxLength + " or shorter because of grammar constraints.", "maxLength"); 108 if (seedNode.Grammar.GetMinimumExpressionDepth(seedNode.Symbol) > maxDepth) 109 throw new ArgumentException("Cannot create trees of depth " + maxDepth + " or smaller because of grammar constraints.", "maxDepth"); 110 105 111 // tree length is limited by the grammar and by the explicit size constraints 106 112 int allowedMinLength = seedNode.Grammar.GetMinimumExpressionLength(seedNode.Symbol); … … 149 155 int argumentIndex = nextExtension.ChildIndex; 150 156 int extensionDepth = nextExtension.ExtensionPointDepth; 151 if ( extensionDepth + parent.Grammar.GetMinimumExpressionDepth(parent.Symbol) >= maxDepth) {157 if (parent.Grammar.GetMinimumExpressionDepth(parent.Symbol) >= maxDepth - extensionDepth) { 152 158 ReplaceWithMinimalTree(random, root, parent, argumentIndex); 153 159 } else { … … 155 161 where s.InitialFrequency > 0.0 156 162 where parent.Grammar.IsAllowedChildSymbol(parent.Symbol, s, argumentIndex) 157 where parent.Grammar.GetMinimumExpressionDepth(s) + extensionDepth - 1 < maxDepth163 where parent.Grammar.GetMinimumExpressionDepth(s) < maxDepth - extensionDepth + 1 158 164 where parent.Grammar.GetMaximumExpressionLength(s) > targetLength - totalListMinLength - currentLength 159 165 select s) -
branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r5809 r6011 229 229 230 230 public virtual IEnumerable<ISymbol> GetAllowedChildSymbols(ISymbol parent) { 231 return from s in Symbols where IsAllowedChildSymbol(parent, s) select s;231 return from s in AllowedSymbols where IsAllowedChildSymbol(parent, s) select s; 232 232 } 233 233 … … 265 265 cachedMinExpressionLength[symbol.Name] = int.MaxValue; // prevent infinite recursion 266 266 long sumOfMinExpressionLengths = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 267 let minForSlot = (long)(from s in Symbols267 let minForSlot = (long)(from s in AllowedSymbols 268 268 where IsAllowedChildSymbol(symbol, s, argIndex) 269 269 select GetMinimumExpressionLength(s)).DefaultIfEmpty(0).Min() … … 282 282 cachedMaxExpressionLength[symbol.Name] = int.MaxValue; // prevent infinite recursion 283 283 long sumOfMaxTrees = 1 + (from argIndex in Enumerable.Range(0, GetMaximumSubtreeCount(symbol)) 284 let maxForSlot = (long)(from s in Symbols284 let maxForSlot = (long)(from s in AllowedSymbols 285 285 where IsAllowedChildSymbol(symbol, s, argIndex) 286 286 select GetMaximumExpressionLength(s)).DefaultIfEmpty(0).Max() 287 287 select maxForSlot).DefaultIfEmpty(0).Sum(); 288 long limit = int.MaxValue; 289 cachedMaxExpressionLength[symbol.Name] = (int)Math.Min(sumOfMaxTrees, limit); 288 cachedMaxExpressionLength[symbol.Name] = (int)Math.Min(sumOfMaxTrees, int.MaxValue); 290 289 return cachedMaxExpressionLength[symbol.Name]; 291 290 } … … 298 297 if (!cachedMinExpressionDepth.TryGetValue(symbol.Name, out temp)) { 299 298 cachedMinExpressionDepth[symbol.Name] = int.MaxValue; // prevent infinite recursion 300 cachedMinExpressionDepth[symbol.Name] = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 301 let minForSlot = (from s in Symbols 302 where IsAllowedChildSymbol(symbol, s, argIndex) 303 select GetMinimumExpressionDepth(s)).DefaultIfEmpty(0).Min() 304 select minForSlot).DefaultIfEmpty(0).Max(); 299 long minDepth = 1 + (from argIndex in Enumerable.Range(0, GetMinimumSubtreeCount(symbol)) 300 let minForSlot = (long)(from s in AllowedSymbols 301 where IsAllowedChildSymbol(symbol, s, argIndex) 302 select GetMinimumExpressionDepth(s)).DefaultIfEmpty(0).Min() 303 select minForSlot).DefaultIfEmpty(0).Max(); 304 cachedMinExpressionDepth[symbol.Name] = (int)Math.Min(minDepth, int.MaxValue); 305 305 return cachedMinExpressionDepth[symbol.Name]; 306 306 } -
branches/histogram/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.Designer.cs
r5824 r6011 204 204 this.chart.Text = "chart"; 205 205 this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart_AxisViewChanged); 206 this.chart.MouseDo wn += new System.Windows.Forms.MouseEventHandler(this.chart_MouseDown);206 this.chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.chart_DoubleClick); 207 207 this.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart_MouseMove); 208 208 this.chart.MouseUp += new System.Windows.Forms.MouseEventHandler(this.chart_MouseUp); -
branches/histogram/HeuristicLab.Optimization.Views/3.3/RunCollectionBubbleChartView.cs
r5837 r6011 432 432 433 433 #region Drag & drop and tooltip 434 private IRun draggedRun; 435 private void chart_MouseDown(object sender, MouseEventArgs e) { 434 private void chart_DoubleClick(object sender, MouseEventArgs e) { 436 435 HitTestResult h = this.chart.HitTest(e.X, e.Y); 437 436 if (h.ChartElementType == ChartElementType.DataPoint) { 438 437 IRun run = (IRun)((DataPoint)h.Object).Tag; 439 if (e.Clicks >= 2) { 440 IContentView view = MainFormManager.MainForm.ShowContent(run); 441 if (view != null) { 442 view.ReadOnly = this.ReadOnly; 443 view.Locked = this.Locked; 444 } 445 } else 446 this.draggedRun = run; 438 IContentView view = MainFormManager.MainForm.ShowContent(run); 439 if (view != null) { 440 view.ReadOnly = this.ReadOnly; 441 view.Locked = this.Locked; 442 } 447 443 this.chart.ChartAreas[0].CursorX.SetSelectionPosition(double.NaN, double.NaN); 448 444 this.chart.ChartAreas[0].CursorY.SetSelectionPosition(double.NaN, double.NaN); … … 452 448 private void chart_MouseUp(object sender, MouseEventArgs e) { 453 449 if (isSelecting) { 454 Content.UpdateOfRunsInProgress = true;455 450 System.Windows.Forms.DataVisualization.Charting.Cursor xCursor = chart.ChartAreas[0].CursorX; 456 451 System.Windows.Forms.DataVisualization.Charting.Cursor yCursor = chart.ChartAreas[0].CursorY; … … 484 479 this.chart.ChartAreas[0].CursorX.SelectionStart = this.chart.ChartAreas[0].CursorX.SelectionEnd; 485 480 this.chart.ChartAreas[0].CursorY.SelectionStart = this.chart.ChartAreas[0].CursorY.SelectionEnd; 486 Content.UpdateOfRunsInProgress = false;487 481 } 488 482 } … … 490 484 private void chart_MouseMove(object sender, MouseEventArgs e) { 491 485 HitTestResult h = this.chart.HitTest(e.X, e.Y); 492 if (!Locked) {493 if (this.draggedRun != null && h.ChartElementType != ChartElementType.DataPoint) {494 DataObject data = new DataObject();495 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, draggedRun);496 if (ReadOnly)497 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);498 else {499 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);500 if ((result & DragDropEffects.Move) == DragDropEffects.Move)501 Content.Remove(draggedRun);502 }503 this.chart.ChartAreas[0].AxisX.ScaleView.Zoomable = !isSelecting;504 this.chart.ChartAreas[0].AxisY.ScaleView.Zoomable = !isSelecting;505 this.draggedRun = null;506 }507 }508 509 486 string newTooltipText = string.Empty; 510 487 string oldTooltipText; … … 670 647 671 648 private void ColorRuns(string axisValue) { 672 Content.UpdateOfRunsInProgress = true;673 649 var runs = Content.Select(r => new { Run = r, Value = GetValue(r, axisValue) }).Where(r => r.Value.HasValue); 674 650 double minValue = runs.Min(r => r.Value.Value); … … 678 654 foreach (var r in runs) { 679 655 int colorIndex = 0; 680 if (!range.IsAlmost(0)) colorIndex = (int)((ColorGradient.Colors.Count - 1) * (r.Value.Value - minValue) / ( maxValue - minValue));656 if (!range.IsAlmost(0)) colorIndex = (int)((ColorGradient.Colors.Count - 1) * (r.Value.Value - minValue) / (range)); 681 657 r.Run.Color = ColorGradient.Colors[colorIndex]; 682 658 } 683 Content.UpdateOfRunsInProgress = false;684 659 } 685 660 #endregion -
branches/histogram/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/histogram/HeuristicLab.Persistence
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/histogram/HeuristicLab.PluginInfrastructure/3.3/ErrorHandling/ErrorHandling.cs
r5445 r6011 25 25 namespace HeuristicLab.PluginInfrastructure { 26 26 public static class ErrorHandling { 27 public static readonly string NewLine = Environment.NewLine;28 29 27 public static string BuildErrorMessage(Exception exception) { 30 28 if (exception == null) { 31 29 return string.Empty; 32 30 } else { 33 string message = exception.GetType().Name + ": " + exception.Message + NewLine +31 string message = exception.GetType().Name + ": " + exception.Message + Environment.NewLine + 34 32 exception.StackTrace; 35 33 36 34 while (exception.InnerException != null) { 37 35 exception = exception.InnerException; 38 message += NewLine +39 "-----" + NewLine +40 exception.GetType().Name + ": " + exception.Message + NewLine +36 message += Environment.NewLine + 37 "-----" + Environment.NewLine + 38 exception.GetType().Name + ": " + exception.Message + Environment.NewLine + 41 39 exception.StackTrace; 42 40 } … … 53 51 public static void ShowErrorDialog(string message, Exception exception) { 54 52 using (ErrorDialog dialog = new ErrorDialog(message, exception)) { 53 dialog.StartPosition = FormStartPosition.CenterScreen; 55 54 dialog.ShowDialog(); 56 55 } -
branches/histogram/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj
r5741 r6011 229 229 <Compile Include="ErrorHandling\ErrorHandling.cs"> 230 230 </Compile> 231 <Compile Include="ErrorHandling\FrameworkVersionErrorDialog.cs"> 232 <SubType>Form</SubType> 233 </Compile> 234 <Compile Include="ErrorHandling\FrameworkVersionErrorDialog.Designer.cs"> 235 <DependentUpon>FrameworkVersionErrorDialog.cs</DependentUpon> 236 </Compile> 231 237 <Compile Include="LightweightApplicationManager.cs" /> 232 238 <Compile Include="Interfaces\IPluginFile.cs" /> -
branches/histogram/HeuristicLab.PluginInfrastructure/3.3/Main.cs
r5445 r6011 34 34 /// <param name="args">Command line arguments</param> 35 35 public static void Run(string[] args) { 36 try{36 if (!FrameworkVersionErrorDialog.NET4FullProfileInstalled) { 37 37 Application.EnableVisualStyles(); 38 38 Application.SetCompatibleTextRenderingDefault(false); 39 Application.Run(new StarterForm()); 40 } 41 catch (Exception ex) { 42 ErrorHandling.ShowErrorDialog(ex); 39 Application.Run(new FrameworkVersionErrorDialog()); 40 } else { 41 try { 42 Application.EnableVisualStyles(); 43 Application.SetCompatibleTextRenderingDefault(false); 44 Application.Run(new StarterForm()); 45 } 46 catch (Exception ex) { 47 ErrorHandling.ShowErrorDialog(ex); 48 } 43 49 } 44 50 } -
branches/histogram/HeuristicLab.PluginInfrastructure/3.3/Starter/SplashScreen.Designer.cs
r5445 r6011 113 113 this.Controls.Add(this.infoLabel); 114 114 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 115 this.Icon = HeuristicLab.PluginInfrastructure.Resources.HeuristicLab; 115 116 this.MaximizeBox = false; 116 117 this.MinimizeBox = false; 117 118 this.Name = "SplashScreen"; 118 this.Opacity = 0.99 ;119 this.Opacity = 0.99D; 119 120 this.ShowInTaskbar = false; 120 121 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; -
branches/histogram/HeuristicLab.Problems.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis (added) merged: 5962-5963
- Property svn:mergeinfo changed
-
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
r5942 r6011 59 59 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 60 60 Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 61 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 62 if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) { 63 replacementValues[node] = CalculateReplacementValue(node); 64 } 61 foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 62 replacementValues[node] = CalculateReplacementValue(node, tree); 65 63 } 66 64 return replacementValues; … … 90 88 foreach (ISymbolicExpressionTreeNode node in nodes) { 91 89 var parent = node.Parent; 92 constantNode.Value = CalculateReplacementValue(node );90 constantNode.Value = CalculateReplacementValue(node, tree); 93 91 ISymbolicExpressionTreeNode replacementNode = constantNode; 94 92 SwitchNode(parent, node, replacementNode); … … 111 109 } 112 110 113 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node) { 111 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) { 112 // remove old ADFs 113 while (tempTree.Root.SubtreesCount > 1) tempTree.Root.RemoveSubtree(1); 114 // clone ADFs of source tree 115 for (int i = 1; i < sourceTree.Root.SubtreesCount; i++) { 116 tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone()); 117 } 114 118 var start = tempTree.Root.GetSubtree(0); 115 119 while (start.SubtreesCount > 0) start.RemoveSubtree(0); -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/SymbolicDiscriminantFunctionClassificationSolutionView.cs
r5834 r6011 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views { 28 28 [Content(typeof(SymbolicDiscriminantFunctionClassificationSolution), true)] 29 [View("SymbolicDiscriminan 29 [View("SymbolicDiscriminantFunctionClassificationSolution View")] 30 30 public partial class SymbolicDiscriminantFunctionClassificationSolutionView : DiscriminantFunctionClassificationSolutionView { 31 31 public SymbolicDiscriminantFunctionClassificationSolutionView() { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicDiscriminantFunctionClassificationSolution.cs
r5818 r6011 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 using System; 24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Data; 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Operators; 29 using HeuristicLab.Parameters; 26 using HeuristicLab.Optimization; 30 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Optimization;32 using System;33 28 34 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification { … … 39 34 [Item(Name = "SymbolicDiscriminantFunctionClassificationSolution", Description = "Represents a symbolic classification solution (model + data) and attributes of the solution like accuracy and complexity.")] 40 35 public sealed class SymbolicDiscriminantFunctionClassificationSolution : DiscriminantFunctionClassificationSolution, ISymbolicClassificationSolution { 41 private const string ModelLengthResultName = "Model Length";42 private const string ModelDepthResultName = "Model Depth";36 private const string ModelLengthResultName = "Model Length"; 37 private const string ModelDepthResultName = "Model Depth"; 43 38 44 39 public new ISymbolicDiscriminantFunctionClassificationModel Model { … … 87 82 ModelLength = Model.SymbolicExpressionTree.Length; 88 83 ModelDepth = Model.SymbolicExpressionTree.Depth; 89 } 84 } 90 85 } 91 86 } -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
r5942 r6011 60 60 protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) { 61 61 Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>(); 62 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 63 if (!(node.Symbol is ProgramRootSymbol || node.Symbol is StartSymbol)) { 64 replacementValues[node] = CalculateReplacementValue(node); 65 } 62 foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 63 replacementValues[node] = CalculateReplacementValue(node, tree); 66 64 } 67 65 return replacementValues; … … 84 82 foreach (ISymbolicExpressionTreeNode node in nodes) { 85 83 var parent = node.Parent; 86 constantNode.Value = CalculateReplacementValue(node );84 constantNode.Value = CalculateReplacementValue(node, tree); 87 85 ISymbolicExpressionTreeNode replacementNode = constantNode; 88 86 SwitchNode(parent, node, replacementNode); … … 100 98 } 101 99 102 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node) { 100 private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) { 101 // remove old ADFs 102 while (tempTree.Root.SubtreesCount > 1) tempTree.Root.RemoveSubtree(1); 103 // clone ADFs of source tree 104 for (int i = 1; i < sourceTree.Root.SubtreesCount; i++) { 105 tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone()); 106 } 103 107 var start = tempTree.Root.GetSubtree(0); 104 108 while (start.SubtreesCount > 0) start.RemoveSubtree(0); -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r5914 r6011 34 34 [Item(Name = "SymbolicRegressionSolution", Description = "Represents a symbolic regression solution (model + data) and attributes of the solution like accuracy and complexity.")] 35 35 public sealed class SymbolicRegressionSolution : RegressionSolution, ISymbolicRegressionSolution { 36 private const string ModelLengthResultName = "Model Length";37 private const string ModelDepthResultName = "Model Depth";36 private const string ModelLengthResultName = "Model Length"; 37 private const string ModelDepthResultName = "Model Depth"; 38 38 39 39 public new ISymbolicRegressionModel Model { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/GraphicalSymbolicDataAnalysisModelView.cs
r5834 r6011 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 27 [View(" SymbolicDataAnalysisModel GraphicalRepresentation")]27 [View("Graphical Representation")] 28 28 [Content(typeof(ISymbolicDataAnalysisModel), true)] 29 29 public partial class GraphicalSymbolicDataAnalysisModelView : AsynchronousContentView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r5809 r6011 96 96 for (int subTreeIndex = 0; subTreeIndex < parent.SubtreesCount; subTreeIndex++) { 97 97 var child = parent.GetSubtree(subTreeIndex); 98 if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost( 1.0)) {98 if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(0.0)) { 99 99 SwitchNodeWithReplacementNode(parent, subTreeIndex); 100 100 } 101 101 } 102 102 } 103 // show only interesting part of solution 104 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 103 // show only interesting part of solution 104 if (tree.Root.SubtreesCount > 1) 105 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs 106 else 107 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB 105 108 this.PaintNodeImpacts(); 106 109 } … … 126 129 for (int i = 0; i < treeNode.SubtreesCount; i++) { 127 130 ISymbolicExpressionTreeNode subTree = treeNode.GetSubtree(i); 128 if (subTree == visualTreeNode.SymbolicExpressionTreeNode) { 131 // only allow to replace nodes for which a replacement value is known (replacement value for ADF nodes are not available) 132 if (subTree == visualTreeNode.SymbolicExpressionTreeNode && replacementNodes.ContainsKey(subTree)) { 133 double replacementImpact = nodeImpacts.ContainsKey(replacementNodes[subTree]) ? nodeImpacts[replacementNodes[subTree]] : 0.0; 134 double originalImpact = nodeImpacts.ContainsKey(subTree) ? nodeImpacts[subTree] : 0.0; 129 135 SwitchNodeWithReplacementNode(treeNode, i); 130 } 131 } 132 } 133 134 // show only interesting part of solution 135 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 136 137 UpdateModel(tree); 136 137 // show only interesting part of solution 138 if (tree.Root.SubtreesCount > 1) 139 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs 140 else 141 this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB 142 if (!(originalImpact.IsAlmost(0.0) && replacementImpact.IsAlmost(0.0))) { 143 // update everything after the change if necessary (impact != 0) 144 UpdateModel(tree); 145 } else { 146 // both impacts are zero, so we only need to repaint the nodes 147 PaintNodeImpacts(); 148 } 149 return; // break all loops 150 } 151 } 152 } 138 153 } 139 154 … … 176 191 visualTree.ToolTip += Environment.NewLine + "Replacement value: " + constantReplacementNode.Value; 177 192 } 178 } 193 } 179 194 } 180 195 this.PaintCollapsedNodes(); -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/RunCollectionVariableImpactView.cs
r5834 r6011 32 32 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 33 33 [Content(typeof(RunCollection), false)] 34 [View(" RunCollection VariableImpacts")]34 [View("Variable Impacts")] 35 35 public sealed partial class RunCollectionVariableImpactView : AsynchronousContentView { 36 36 private const string variableImpactResultName = "Variable impacts"; -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TextualSymbolicDataAnalysisModelView.cs
r5834 r6011 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 27 [View(" SymbolicDataAnalysisModel TextualRepresentation")]27 [View("Textual Representation")] 28 28 [Content(typeof(ISymbolicDataAnalysisModel), false)] 29 29 public partial class TextualSymbolicDataAnalysisModelView : AsynchronousContentView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeInterpreter.cs
r5925 r6011 36 36 #region private classes 37 37 private class InterpreterState { 38 private const int ARGUMENT_STACK_SIZE = 1024;39 38 private double[] argumentStack; 40 39 private int argumentStackPointer; … … 45 44 set { pc = value; } 46 45 } 47 internal InterpreterState(Instruction[] code ) {46 internal InterpreterState(Instruction[] code, int argumentStackSize) { 48 47 this.code = code; 49 48 this.pc = 0; 50 this.argumentStack = new double[ARGUMENT_STACK_SIZE]; 49 if (argumentStackSize > 0) { 50 this.argumentStack = new double[argumentStackSize]; 51 } 51 52 this.argumentStackPointer = 0; 52 53 } … … 202 203 var compiler = new SymbolicExpressionTreeCompiler(); 203 204 Instruction[] code = compiler.Compile(tree, MapSymbolToOpCode); 204 205 int necessaryArgStackSize = 0; 205 206 for (int i = 0; i < code.Length; i++) { 206 207 Instruction instr = code[i]; … … 216 217 var variableConditionTreeNode = instr.dynamicNode as VariableConditionTreeNode; 217 218 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableConditionTreeNode.VariableName); 219 } else if (instr.opCode == OpCodes.Call) { 220 necessaryArgStackSize += instr.nArguments + 1; 218 221 } 219 222 } 220 var state = new InterpreterState(code );223 var state = new InterpreterState(code, necessaryArgStackSize); 221 224 222 225 foreach (var rowEnum in rows) { … … 370 373 double f_3 = Evaluate(dataset, ref row, state); row--; 371 374 state.ProgramCounter = savedPc; 372 double f_4 = Evaluate(dataset, ref row, state); 375 double f_4 = Evaluate(dataset, ref row, state); 373 376 row += 4; 374 377 -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionConfusionMatrixView.cs
r5834 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View("C lassificationSolution ConfusionMatrix")]31 [View("Confusion Matrix")] 32 32 [Content(typeof(IClassificationSolution))] 33 33 public partial class ClassificationSolutionConfusionMatrixView : ItemView, IClassificationSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationSolutionEstimatedClassValuesView.cs
r5834 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View(" ClassificationSolution EstimatedClassValues")]31 [View("Estimated Class Values")] 32 32 [Content(typeof(IClassificationSolution))] 33 33 public partial class ClassificationSolutionEstimatedClassValuesView : ItemView, IClassificationSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationRocCurvesView.cs
r5834 r6011 32 32 using HeuristicLab.MainForm.WindowsForms; 33 33 namespace HeuristicLab.Problems.DataAnalysis.Views { 34 [View(" DiscriminantFunctionClassificationSolutionROC Curves")]34 [View("ROC Curves")] 35 35 [Content(typeof(IDiscriminantFunctionClassificationSolution))] 36 36 public partial class DiscriminantFunctionClassificationRocCurvesView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionEstimatedClassValuesView.cs
r5834 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View(" DiscriminantFunctionClassificationSolution EstimatedClassValues")]31 [View("Estimated Class Values")] 32 32 [Content(typeof(IDiscriminantFunctionClassificationSolution))] 33 33 public partial class DiscriminantFunctionClassificationSolutionEstimatedClassValuesView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/DiscriminantFunctionClassificationSolutionThresholdView.cs
r5834 r6011 32 32 33 33 namespace HeuristicLab.Problems.DataAnalysis.Views { 34 [View(" DsicriminantFunctionClassificationSolution ThresholdView")]34 [View("Classification Threshold")] 35 35 [Content(typeof(IDiscriminantFunctionClassificationSolution), true)] 36 36 public sealed partial class DiscriminantFunctionClassificationSolutionThresholdView : ItemView, IDiscriminantFunctionClassificationSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Clustering/ClusteringSolutionEstimatedClusterView.cs
r5853 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View(" ClusteringSolution EstimatedCluster")]31 [View("Estimated Clusters")] 32 32 [Content(typeof(IClusteringSolution))] 33 33 public partial class ClusteringSolutionEstimatedClusterView : ItemView, IClusteringSolutionEvaluationView { … … 101 101 102 102 matrix = new DoubleMatrix(values); 103 var columnNames = dataset.VariableNames.ToList();103 var columnNames = Content.ProblemData.AllowedInputVariables.ToList(); 104 104 columnNames.Insert(0, CLUSTER_NAMES); 105 105 matrix.ColumnNames = columnNames; -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/ClusteringSolutionView.cs
r5853 r6011 26 26 27 27 namespace HeuristicLab.Problems.DataAnalysis.Views { 28 [View(" RegressionSolution View")]28 [View("ClusteringSolution View")] 29 29 [Content(typeof(ClusteringSolution), true)] 30 30 public partial class ClusteringSolutionView : DataAnalysisSolutionView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionEstimatedValuesView.cs
r5834 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View(" RegressionSolution EstimatedValues")]31 [View("Estimated Values")] 32 32 [Content(typeof(IRegressionSolution))] 33 33 public partial class RegressionSolutionEstimatedValuesView : ItemView, IRegressionSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionLineChartView.cs
r5834 r6011 29 29 30 30 namespace HeuristicLab.Problems.DataAnalysis.Views { 31 [View(" RegressionSolution LineChart")]31 [View("Line Chart")] 32 32 [Content(typeof(IRegressionSolution))] 33 33 public partial class RegressionSolutionLineChartView : ItemView, IRegressionSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionScatterPlotView.cs
r5834 r6011 30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis.Views { 32 [View(" RegressionSolution ScatterPlot")]32 [View("Scatter Plot")] 33 33 [Content(typeof(IRegressionSolution))] 34 34 public partial class RegressionSolutionScatterPlotView : ItemView, IRegressionSolutionEvaluationView { -
branches/histogram/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionSolution.cs
r5942 r6011 107 107 Add(new Result(TrainingRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the training partition", new PercentValue())); 108 108 Add(new Result(TestRelativeErrorResultName, "Average of the relative errors of the model output and the actual values on the test partition", new PercentValue())); 109 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, " ", new DoubleValue()));110 Add(new Result(TestNormalizedMeanSquaredErrorResultName, " ", new DoubleValue()));109 Add(new Result(TrainingNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the training partition", new DoubleValue())); 110 Add(new Result(TestNormalizedMeanSquaredErrorResultName, "Normalized mean of squared errors of the model on the test partition", new DoubleValue())); 111 111 112 112 RecalculateResults(); -
branches/histogram/HeuristicLab.Problems.DataAnalysis/3.4/OnlineCalculators/OnlineNormalizedMeanSquaredErrorCalculator.cs
r5945 r6011 68 68 OnlineNormalizedMeanSquaredErrorCalculator normalizedMSECalculator = new OnlineNormalizedMeanSquaredErrorCalculator(); 69 69 70 //needed because otherwise the normalizedMSECalculator is in ErrorState.InsufficientValuesAdded 71 if (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) { 72 double estimated = secondEnumerator.Current; 73 double original = firstEnumerator.Current; 74 normalizedMSECalculator.Add(original, estimated); 75 } 76 70 77 // always move forward both enumerators (do not use short-circuit evaluation!) 71 78 while (firstEnumerator.MoveNext() & secondEnumerator.MoveNext()) { -
branches/histogram/HeuristicLab.Problems.DataAnalysis/3.4/Tests/OnlineCalculatorPerformanceTest.cs
r5952 r6011 75 75 var twister = new MersenneTwister(31415); 76 76 var dataset = CreateRandomDataset(twister, Rows, Columns); 77 var errorState = new OnlineCalculatorError();77 OnlineCalculatorError errorState = OnlineCalculatorError.None; ; 78 78 79 79 Stopwatch watch = new Stopwatch(); … … 81 81 for (int i = 0; i < Repetitions; i++) { 82 82 double value = calculateFunc(dataset.GetEnumeratedVariableValues(0), dataset.GetEnumeratedVariableValues(1), out errorState); 83 84 83 } 84 Assert.AreEqual(errorState, OnlineCalculatorError.None); 85 85 watch.Stop(); 86 86 -
branches/histogram/HeuristicLab.Problems.QuadraticAssignment.Views/3.3
- Property svn:ignore
-
old new 2 2 obj 3 3 Plugin.cs 4 *.vs10x
-
- Property svn:ignore
-
branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3
- Property svn:ignore
-
old new 3 3 Plugin.cs 4 4 *.user 5 *.vs10x
-
- Property svn:ignore
-
branches/histogram/HeuristicLab.Problems.QuadraticAssignment/3.3/Tests
- Property svn:ignore
-
old new 1 1 bin 2 2 obj 3 *.vs10x
-
- Property svn:ignore
-
branches/histogram/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/histogram/HeuristicLab.Problems.VehicleRouting.Views
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/histogram/HeuristicLab.Selection/3.3/NoSameMatesSelector.cs
r5957 r6011 1 1 using System; 2 using System.Collections.Generic; 2 3 using System.Linq; 3 using System.Collections.Generic;4 4 using System.Threading; 5 5 using HeuristicLab.Common; … … 55 55 [StorableConstructor] 56 56 protected NoSameMatesSelector(bool deserializing) : base(deserializing) { } 57 protected NoSameMatesSelector(NoSameMatesSelector original, Cloner cloner) : base(original, cloner) { 57 protected NoSameMatesSelector(NoSameMatesSelector original, Cloner cloner) 58 : base(original, cloner) { 58 59 RegisterParameterEventHandlers(); 59 60 } … … 62 63 } 63 64 64 public NoSameMatesSelector() : base() { 65 public NoSameMatesSelector() 66 : base() { 65 67 #region Create parameters 66 68 Parameters.Add(new ValueParameter<ISingleObjectiveSelector>(SelectorParameterName, "The inner selection operator to select the parents.", new TournamentSelector())); … … 85 87 Parameters.Add(new ValueParameter<ISingleObjectiveSelector>(SelectorParameterName, "The inner selection operator to select the parents.", selector)); 86 88 } 87 } 89 } 88 90 // FixedValueParameter for quality difference percentage, max attempts, use range 89 91 if (Parameters.ContainsKey(QualityDifferencePercentageParameterName)) { … … 153 155 ScopeList parents = CurrentScope.SubScopes[1].SubScopes; 154 156 155 for (int indexParent1 = 0, indexParent2 = 1; 156 indexParent1 < parents.Count - 1 && selectedParents < parentsToSelect - 1; 157 for (int indexParent1 = 0, indexParent2 = 1; 158 indexParent1 < parents.Count - 1 && selectedParents < parentsToSelect - 1; 157 159 indexParent1 += 2, indexParent2 += 2) { 158 160 double qualityParent1 = ((DoubleValue)parents[indexParent1].Variables[qualityName].Value).Value; … … 168 170 } 169 171 170 if (parentsDifferent) { 172 if (parentsDifferent) { 171 173 // inner selector already copied scopes, no cloning necessary here 172 174 selected[selectedParents++] = parents[indexParent1]; … … 204 206 if (CopySelected.Value != true) { 205 207 CopySelected.Value = true; 206 throw new ArgumentException(Name + ": CopySelected must always be true."); 207 } 208 } 209 #endregion 210 211 #region Helpers 208 } 209 } 210 #endregion 211 212 #region Helpers 212 213 private void ParameterizeSelector(ISingleObjectiveSelector selector) { 213 214 selector.CopySelected = new BoolValue(true); // must always be true
Note: See TracChangeset
for help on using the changeset viewer.