- Timestamp:
- 12/20/08 11:11:03 (16 years ago)
- Location:
- branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.Designer.cs
r1003 r1042 45 45 private void InitializeComponent() { 46 46 this.importButton = new System.Windows.Forms.Button(); 47 this.t extBox1= new System.Windows.Forms.TextBox();47 this.trainingSamplesStartTextBox = new System.Windows.Forms.TextBox(); 48 48 this.trainingLabel = new System.Windows.Forms.Label(); 49 this.t extBox4= new System.Windows.Forms.TextBox();50 this. textBox2= new System.Windows.Forms.TextBox();51 this. textBox3= new System.Windows.Forms.TextBox();49 this.trainingSamplesEndTextBox = new System.Windows.Forms.TextBox(); 50 this.validationSamplesEndTextBox = new System.Windows.Forms.TextBox(); 51 this.validationSamplesStartTextBox = new System.Windows.Forms.TextBox(); 52 52 this.validationLabel = new System.Windows.Forms.Label(); 53 this.te xtBox5= new System.Windows.Forms.TextBox();54 this.te xtBox6= new System.Windows.Forms.TextBox();53 this.testSamplesEndTextBox = new System.Windows.Forms.TextBox(); 54 this.testSamplesStartTextBox = new System.Windows.Forms.TextBox(); 55 55 this.testLabel = new System.Windows.Forms.Label(); 56 56 this.datasetView = new HeuristicLab.DataAnalysis.DatasetView(); … … 77 77 this.importButton.Click += new System.EventHandler(this.importButton_Click); 78 78 // 79 // textBox1 80 // 81 this.textBox1.Location = new System.Drawing.Point(119, 17); 82 this.textBox1.Name = "textBox1"; 83 this.textBox1.Size = new System.Drawing.Size(96, 20); 84 this.textBox1.TabIndex = 4; 79 // trainingSamplesStartTextBox 80 // 81 this.trainingSamplesStartTextBox.Location = new System.Drawing.Point(119, 17); 82 this.trainingSamplesStartTextBox.Name = "trainingSamplesStartTextBox"; 83 this.trainingSamplesStartTextBox.Size = new System.Drawing.Size(96, 20); 84 this.trainingSamplesStartTextBox.TabIndex = 4; 85 this.trainingSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 86 this.trainingSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 85 87 // 86 88 // trainingLabel … … 93 95 this.trainingLabel.Text = "Training samples:"; 94 96 // 95 // textBox4 96 // 97 this.textBox4.Location = new System.Drawing.Point(221, 17); 98 this.textBox4.Name = "textBox4"; 99 this.textBox4.Size = new System.Drawing.Size(96, 20); 100 this.textBox4.TabIndex = 10; 101 // 102 // textBox2 103 // 104 this.textBox2.Location = new System.Drawing.Point(221, 43); 105 this.textBox2.Name = "textBox2"; 106 this.textBox2.Size = new System.Drawing.Size(96, 20); 107 this.textBox2.TabIndex = 13; 108 // 109 // textBox3 110 // 111 this.textBox3.Location = new System.Drawing.Point(119, 43); 112 this.textBox3.Name = "textBox3"; 113 this.textBox3.Size = new System.Drawing.Size(96, 20); 114 this.textBox3.TabIndex = 12; 97 // trainingSamplesEndTextBox 98 // 99 this.trainingSamplesEndTextBox.Location = new System.Drawing.Point(221, 17); 100 this.trainingSamplesEndTextBox.Name = "trainingSamplesEndTextBox"; 101 this.trainingSamplesEndTextBox.Size = new System.Drawing.Size(96, 20); 102 this.trainingSamplesEndTextBox.TabIndex = 10; 103 this.trainingSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 104 this.trainingSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 105 // 106 // validationSamplesEndTextBox 107 // 108 this.validationSamplesEndTextBox.Location = new System.Drawing.Point(221, 43); 109 this.validationSamplesEndTextBox.Name = "validationSamplesEndTextBox"; 110 this.validationSamplesEndTextBox.Size = new System.Drawing.Size(96, 20); 111 this.validationSamplesEndTextBox.TabIndex = 13; 112 this.validationSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 113 this.validationSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 114 // 115 // validationSamplesStartTextBox 116 // 117 this.validationSamplesStartTextBox.Location = new System.Drawing.Point(119, 43); 118 this.validationSamplesStartTextBox.Name = "validationSamplesStartTextBox"; 119 this.validationSamplesStartTextBox.Size = new System.Drawing.Size(96, 20); 120 this.validationSamplesStartTextBox.TabIndex = 12; 121 this.validationSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 122 this.validationSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 115 123 // 116 124 // validationLabel … … 123 131 this.validationLabel.Text = "Validation samples:"; 124 132 // 125 // textBox5 126 // 127 this.textBox5.Location = new System.Drawing.Point(221, 68); 128 this.textBox5.Name = "textBox5"; 129 this.textBox5.Size = new System.Drawing.Size(96, 20); 130 this.textBox5.TabIndex = 16; 131 // 132 // textBox6 133 // 134 this.textBox6.Location = new System.Drawing.Point(119, 68); 135 this.textBox6.Name = "textBox6"; 136 this.textBox6.Size = new System.Drawing.Size(96, 20); 137 this.textBox6.TabIndex = 15; 133 // testSamplesEndTextBox 134 // 135 this.testSamplesEndTextBox.Location = new System.Drawing.Point(221, 68); 136 this.testSamplesEndTextBox.Name = "testSamplesEndTextBox"; 137 this.testSamplesEndTextBox.Size = new System.Drawing.Size(96, 20); 138 this.testSamplesEndTextBox.TabIndex = 16; 139 this.testSamplesEndTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 140 this.testSamplesEndTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 141 // 142 // testSamplesStartTextBox 143 // 144 this.testSamplesStartTextBox.Location = new System.Drawing.Point(119, 68); 145 this.testSamplesStartTextBox.Name = "testSamplesStartTextBox"; 146 this.testSamplesStartTextBox.Size = new System.Drawing.Size(96, 20); 147 this.testSamplesStartTextBox.TabIndex = 15; 148 this.testSamplesStartTextBox.Validated += new System.EventHandler(this.samplesTextBox_Validated); 149 this.testSamplesStartTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.samplesTextBox_Validating); 138 150 // 139 151 // testLabel … … 169 181 this.targetsListBox.Size = new System.Drawing.Size(153, 79); 170 182 this.targetsListBox.TabIndex = 19; 183 this.targetsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.targetsListBox_ItemCheck); 171 184 // 172 185 // inputsListBox … … 180 193 this.inputsListBox.Size = new System.Drawing.Size(141, 79); 181 194 this.inputsListBox.TabIndex = 21; 195 this.inputsListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.inputsListBox_ItemCheck); 182 196 // 183 197 // autoregressiveCheckBox … … 192 206 this.autoregressiveCheckBox.Text = "Auto regressive:"; 193 207 this.autoregressiveCheckBox.UseVisualStyleBackColor = true; 208 this.autoregressiveCheckBox.CheckedChanged += new System.EventHandler(this.autoregressiveCheckBox_CheckedChanged); 194 209 // 195 210 // targetsGroupBox … … 218 233 // 219 234 this.partitioningGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 220 this.partitioningGroupBox.Controls.Add(this. textBox2);235 this.partitioningGroupBox.Controls.Add(this.validationSamplesEndTextBox); 221 236 this.partitioningGroupBox.Controls.Add(this.trainingLabel); 222 this.partitioningGroupBox.Controls.Add(this.t extBox1);223 this.partitioningGroupBox.Controls.Add(this.t extBox4);237 this.partitioningGroupBox.Controls.Add(this.trainingSamplesStartTextBox); 238 this.partitioningGroupBox.Controls.Add(this.trainingSamplesEndTextBox); 224 239 this.partitioningGroupBox.Controls.Add(this.validationLabel); 225 this.partitioningGroupBox.Controls.Add(this.te xtBox5);226 this.partitioningGroupBox.Controls.Add(this. textBox3);227 this.partitioningGroupBox.Controls.Add(this.te xtBox6);240 this.partitioningGroupBox.Controls.Add(this.testSamplesEndTextBox); 241 this.partitioningGroupBox.Controls.Add(this.validationSamplesStartTextBox); 242 this.partitioningGroupBox.Controls.Add(this.testSamplesStartTextBox); 228 243 this.partitioningGroupBox.Controls.Add(this.testLabel); 229 244 this.partitioningGroupBox.Location = new System.Drawing.Point(3, 268); … … 265 280 266 281 private System.Windows.Forms.Button importButton; 267 private System.Windows.Forms.TextBox t extBox1;282 private System.Windows.Forms.TextBox trainingSamplesStartTextBox; 268 283 private System.Windows.Forms.Label trainingLabel; 269 private System.Windows.Forms.TextBox t extBox4;270 private System.Windows.Forms.TextBox textBox2;271 private System.Windows.Forms.TextBox textBox3;284 private System.Windows.Forms.TextBox trainingSamplesEndTextBox; 285 private System.Windows.Forms.TextBox validationSamplesEndTextBox; 286 private System.Windows.Forms.TextBox validationSamplesStartTextBox; 272 287 private System.Windows.Forms.Label validationLabel; 273 private System.Windows.Forms.TextBox te xtBox5;274 private System.Windows.Forms.TextBox te xtBox6;288 private System.Windows.Forms.TextBox testSamplesEndTextBox; 289 private System.Windows.Forms.TextBox testSamplesStartTextBox; 275 290 private System.Windows.Forms.Label testLabel; 276 291 private HeuristicLab.DataAnalysis.DatasetView datasetView; -
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.CEDMA.Core/ProblemView.cs
r1003 r1042 30 30 using HeuristicLab.Core; 31 31 using HeuristicLab.DataAnalysis; 32 using System.Diagnostics; 32 33 33 34 namespace HeuristicLab.CEDMA.Core { … … 42 43 protected override void UpdateControls() { 43 44 base.UpdateControls(); 44 // TASK update text-boxes and datasetview 45 trainingSamplesStartTextBox.Text = problem.TrainingSamplesStart.ToString(); 46 trainingSamplesEndTextBox.Text = problem.TrainingSamplesEnd.ToString(); 47 validationSamplesStartTextBox.Text = problem.ValidationSamplesStart.ToString(); 48 validationSamplesEndTextBox.Text = problem.ValidationSamplesEnd.ToString(); 49 testSamplesStartTextBox.Text = problem.TestSamplesStart.ToString(); 50 testSamplesEndTextBox.Text = problem.TestSamplesEnd.ToString(); 51 targetsListBox.Items.Clear(); 52 inputsListBox.Items.Clear(); 53 for (int i = 0; i < problem.DataSet.Columns; i++) { 54 targetsListBox.Items.Add(problem.DataSet.VariableNames[i], problem.AllowedTargetVariables.Contains(i)); 55 inputsListBox.Items.Add(problem.DataSet.VariableNames[i], problem.AllowedInputVariables.Contains(i)); 56 } 45 57 } 46 58 47 59 private void importButton_Click(object sender, EventArgs e) { 48 if (openFileDialog.ShowDialog(this) == DialogResult.OK) {60 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 49 61 DatasetParser parser = new DatasetParser(); 50 62 bool success = false; … … 53 65 parser.Import(openFileDialog.FileName, true); 54 66 success = true; 55 } catch(DataFormatException ex) { 67 } 68 catch (DataFormatException ex) { 56 69 ShowWarningMessageBox(ex); 57 70 // not possible to parse strictly => clear and try to parse non-strict … … 60 73 success = true; 61 74 } 62 } catch(DataFormatException ex) { 75 } 76 catch (DataFormatException ex) { 63 77 // if the non-strict parsing also failed then show the exception 64 78 ShowErrorMessageBox(ex); 65 79 } 66 if (success) {80 if (success) { 67 81 Dataset dataset = (Dataset)problem.DataSet; 68 82 dataset.Rows = parser.Rows; … … 72 86 dataset.Samples = new double[dataset.Rows * dataset.Columns]; 73 87 Array.Copy(parser.Samples, dataset.Samples, dataset.Columns * dataset.Rows); 88 datasetView.Dataset = problem.DataSet; 89 74 90 problem.TrainingSamplesStart = parser.TrainingSamplesStart; 75 91 problem.ValidationSamplesEnd = parser.TrainingSamplesStart; … … 82 98 83 99 List<int> nonInputVariables = parser.NonInputVariables; 84 for (int i = 0; i < dataset.Columns; i++) {85 if (!nonInputVariables.Contains(i)) problem.AllowedInputVariables.Add(i);100 for (int i = 0; i < dataset.Columns; i++) { 101 if (!nonInputVariables.Contains(i)) problem.AllowedInputVariables.Add(i); 86 102 } 87 103 Refresh(); … … 106 122 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); 107 123 108 while (ex.InnerException != null) {124 while (ex.InnerException != null) { 109 125 ex = ex.InnerException; 110 126 sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace); … … 112 128 return sb.ToString(); 113 129 } 130 131 private void targetsListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 132 if (e.NewValue == CheckState.Checked && !problem.AllowedTargetVariables.Contains(e.Index)) 133 problem.AllowedTargetVariables.Add(e.Index); 134 else if (e.NewValue == CheckState.Unchecked && problem.AllowedTargetVariables.Contains(e.Index)) 135 problem.AllowedTargetVariables.Remove(e.Index); 136 } 137 138 private void inputsListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 139 if (e.NewValue == CheckState.Checked && !problem.AllowedInputVariables.Contains(e.Index)) 140 problem.AllowedInputVariables.Add(e.Index); 141 else if (e.NewValue == CheckState.Unchecked && problem.AllowedInputVariables.Contains(e.Index)) 142 problem.AllowedInputVariables.Remove(e.Index); 143 } 144 145 private void autoregressiveCheckBox_CheckedChanged(object sender, EventArgs e) { 146 problem.AutoRegressive = autoregressiveCheckBox.Checked; 147 } 148 149 private void samplesTextBox_Validating(object sender, CancelEventArgs e) { 150 try { 151 int trainingStart = int.Parse(trainingSamplesStartTextBox.Text); 152 int trainingEnd = int.Parse(trainingSamplesEndTextBox.Text); 153 int validationStart = int.Parse(validationSamplesStartTextBox.Text); 154 int validationEnd = int.Parse(validationSamplesEndTextBox.Text); 155 int testStart = int.Parse(testSamplesStartTextBox.Text); 156 int testEnd = int.Parse(testSamplesEndTextBox.Text); 157 if (trainingStart < 0 || validationStart < 0 || testStart < 0 || 158 trainingEnd >= problem.DataSet.Rows || validationEnd >= problem.DataSet.Rows || testEnd >= problem.DataSet.Rows || 159 trainingStart >= trainingEnd || 160 validationStart >= validationEnd || 161 testStart >= testEnd || 162 IsOverlapping(trainingStart, trainingEnd, validationStart, validationEnd) || 163 IsOverlapping(trainingStart, trainingEnd, testStart, testEnd) || 164 IsOverlapping(validationStart, validationEnd, testStart, testEnd)) 165 ColorSamplesTextBoxes(Color.Red); 166 else 167 ColorSamplesTextBoxes(Color.White); 168 } 169 catch (FormatException ex) { 170 ColorSamplesTextBoxes(Color.Red); 171 } 172 } 173 174 private void samplesTextBox_Validated(object sender, EventArgs e) { 175 problem.TrainingSamplesStart = int.Parse(trainingSamplesStartTextBox.Text); 176 problem.TrainingSamplesEnd = int.Parse(trainingSamplesEndTextBox.Text); 177 problem.ValidationSamplesStart = int.Parse(validationSamplesStartTextBox.Text); 178 problem.ValidationSamplesEnd = int.Parse(validationSamplesEndTextBox.Text); 179 problem.TestSamplesStart = int.Parse(testSamplesStartTextBox.Text); 180 problem.TestSamplesEnd = int.Parse(testSamplesEndTextBox.Text); 181 } 182 183 private void ColorSamplesTextBoxes(Color color) { 184 trainingSamplesStartTextBox.BackColor = color; 185 trainingSamplesEndTextBox.BackColor = color; 186 validationSamplesStartTextBox.BackColor = color; 187 validationSamplesEndTextBox.BackColor = color; 188 testSamplesStartTextBox.BackColor = color; 189 testSamplesEndTextBox.BackColor = color; 190 } 191 192 private bool IsOverlapping(int x0, int y0, int x1, int y1) { 193 Trace.Assert(x0 <= y0 && x1 <= y1); 194 int tmp; 195 // make sure that x0,y0 is the left interval 196 if (x1 < x0) { 197 tmp = x1; 198 x1 = x0; 199 x0 = tmp; 200 tmp = y1; 201 y1 = y0; 202 y0 = tmp; 203 } 204 return y0 > x1; 205 } 114 206 } 115 207 }
Note: See TracChangeset
for help on using the changeset viewer.