Changeset 1215
- Timestamp:
- 02/11/09 13:39:30 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/Problem.cs
r1214 r1215 52 52 public HeuristicLab.DataAnalysis.Dataset DataSet { 53 53 get { return dataset; } 54 }55 56 public string[] VariableNames {57 get { return DataSet.VariableNames; }58 54 } 59 55 … … 123 119 } 124 120 121 122 public string GetVariableName(int index) { 123 return dataset.GetVariableName(index); 124 } 125 125 126 public override IView CreateView() { 126 127 return new ProblemView(this); … … 177 178 AutoRegressive = bool.Parse(node.Attributes["AutoRegressive"].Value); 178 179 allowedTargetVariables.Clear(); 179 foreach (string tok in node.SelectSingleNode("AllowedTargetVariables").InnerText.Split(new string[] {";"}, StringSplitOptions.RemoveEmptyEntries))180 foreach (string tok in node.SelectSingleNode("AllowedTargetVariables").InnerText.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)) 180 181 allowedTargetVariables.Add(int.Parse(tok)); 181 182 allowedInputVariables.Clear(); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs
r1043 r1215 64 64 inputsListBox.Items.Clear(); 65 65 for (int i = 0; i < problem.DataSet.Columns; i++) { 66 targetsListBox.Items.Add(problem.DataSet. VariableNames[i], problem.AllowedTargetVariables.Contains(i));67 inputsListBox.Items.Add(problem.DataSet. VariableNames[i], problem.AllowedInputVariables.Contains(i));66 targetsListBox.Items.Add(problem.DataSet.GetVariableName(i), problem.AllowedTargetVariables.Contains(i)); 67 inputsListBox.Items.Add(problem.DataSet.GetVariableName(i), problem.AllowedInputVariables.Contains(i)); 68 68 } 69 69 } … … 94 94 dataset.Rows = parser.Rows; 95 95 dataset.Columns = parser.Columns; 96 dataset.VariableNames = parser.VariableNames; 96 for (int i = 0; i < parser.VariableNames.Length; i++) { 97 dataset.SetVariableName(i, parser.VariableNames[i]); 98 } 97 99 dataset.Name = parser.ProblemName; 98 100 dataset.Samples = new double[dataset.Rows * dataset.Columns]; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.DataAnalysis/Dataset.cs
r534 r1215 52 52 public int Columns { 53 53 get { return columns; } 54 set { columns = value; } 54 set { 55 columns = value; 56 if (variableNames == null || variableNames.Length != columns) { 57 variableNames = new string[columns]; 58 } 59 } 55 60 } 56 61 … … 90 95 91 96 private string[] variableNames; 92 public string[] VariableNames {93 get { return variableNames; }94 set { variableNames = value; }95 }96 97 97 98 public Dataset() { 98 99 Name = "-"; 99 VariableNames = new string[] { "Var0" };100 variableNames = new string[] { "Var0" }; 100 101 Columns = 1; 101 102 Rows = 1; … … 114 115 } 115 116 } 117 118 public string GetVariableName(int variableIndex) { 119 return variableNames[variableIndex]; 120 } 121 122 public void SetVariableName(int variableIndex, string name) { 123 variableNames[variableIndex] = name; 124 } 125 116 126 117 127 public override IView CreateView() { … … 128 138 clone.Samples = cloneSamples; 129 139 clone.Name = Name; 130 clone. VariableNames = new string[VariableNames.Length];131 Array.Copy( VariableNames, clone.VariableNames, VariableNames.Length);140 clone.variableNames = new string[variableNames.Length]; 141 Array.Copy(variableNames, clone.variableNames, variableNames.Length); 132 142 Array.Copy(scalingFactor, clone.scalingFactor, columns); 133 143 Array.Copy(scalingOffset, clone.scalingOffset, columns); … … 165 175 columns = int.Parse(node.Attributes["Dimension2"].Value, CultureInfo.InvariantCulture.NumberFormat); 166 176 167 VariableNames = ParseVariableNamesString(node.Attributes["VariableNames"].Value);177 variableNames = ParseVariableNamesString(node.Attributes["VariableNames"].Value); 168 178 if(node.Attributes["ScalingFactors"] != null) 169 179 scalingFactor = ParseDoubleString(node.Attributes["ScalingFactors"].Value); -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.DataAnalysis/DatasetView.cs
r473 r1215 135 135 136 136 private string GetColumnName(int index) { 137 if(Dataset. VariableNames.Length== dataGridView.Columns.Count) {138 return Dataset. VariableNames[index];137 if(Dataset.Columns == dataGridView.Columns.Count) { 138 return Dataset.GetVariableName(index); 139 139 } else { 140 140 return "Var " + index; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StructIdProblemInjectorView.cs
r656 r1215 63 63 protected override void UpdateControls() { 64 64 base.UpdateControls(); 65 if (StructIdProblemInjector == null) {65 if (StructIdProblemInjector == null) { 66 66 importInstanceButton.Enabled = false; 67 67 } else { … … 73 73 74 74 private void importInstanceButton_Click(object sender, EventArgs e) { 75 if (openFileDialog.ShowDialog(this) == DialogResult.OK) {75 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 76 76 DatasetParser parser = new DatasetParser(); 77 77 bool success = false; … … 80 80 parser.Import(openFileDialog.FileName, true); 81 81 success = true; 82 } catch(DataFormatException ex) { 82 } 83 catch (DataFormatException ex) { 83 84 ShowWarningMessageBox(ex); 84 85 // not possible to parse strictly => clear and try to parse non-strict … … 87 88 success = true; 88 89 } 89 } catch(DataFormatException ex) { 90 } 91 catch (DataFormatException ex) { 90 92 // if the non-strict parsing also failed then show the exception 91 93 ShowErrorMessageBox(ex); 92 94 } 93 if (success) {95 if (success) { 94 96 Dataset dataset = (Dataset)StructIdProblemInjector.GetVariable("Dataset").Value; 95 97 dataset.Rows = parser.Rows; 96 98 dataset.Columns = parser.Columns; 97 dataset.VariableNames = parser.VariableNames; 99 for (int i = 0; i < parser.VariableNames.Length; i++) { 100 dataset.SetVariableName(i, parser.VariableNames[i]); 101 } 98 102 dataset.Name = parser.ProblemName; 99 103 dataset.Samples = new double[dataset.Rows * dataset.Columns]; … … 109 113 110 114 IVariable var = StructIdProblemInjector.GetVariable("AllowedFeatures"); 111 if (var != null) {115 if (var != null) { 112 116 ItemList<IntData> allowedFeatures = (ItemList<IntData>)var.Value; 113 117 allowedFeatures.Clear(); 114 118 List<int> nonInputVariables = parser.NonInputVariables; 115 for (int i = 0; i < dataset.Columns; i++) {116 if (!nonInputVariables.Contains(i)) allowedFeatures.Add(new IntData(i));119 for (int i = 0; i < dataset.Columns; i++) { 120 if (!nonInputVariables.Contains(i)) allowedFeatures.Add(new IntData(i)); 117 121 } 118 122 } … … 124 128 private void TrySetVariable(string name, int value) { 125 129 IVariable var = StructIdProblemInjector.GetVariable(name); 126 if (var != null) {130 if (var != null) { 127 131 ((IntData)var.Value).Data = value; 128 132 } … … 145 149 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); 146 150 147 while (ex.InnerException != null) {151 while (ex.InnerException != null) { 148 152 ex = ex.InnerException; 149 153 sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
Note: See TracChangeset
for help on using the changeset viewer.