Changeset 2728
- Timestamp:
- 02/01/10 08:52:32 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.Designer.cs
r2341 r2728 46 46 /// </summary> 47 47 private void InitializeComponent() { 48 this.components = new System.ComponentModel.Container(); 48 49 this.executeButton = new System.Windows.Forms.Button(); 49 50 this.tabControl = new System.Windows.Forms.TabControl(); … … 72 73 this.resetButton = new System.Windows.Forms.Button(); 73 74 this.cloneEngineButton = new System.Windows.Forms.Button(); 75 this.functionLibraryInjectorViewButton = new System.Windows.Forms.Button(); 76 this.functionLibraryInjectorSetButton = new System.Windows.Forms.Button(); 77 this.functionLibraryInjectorTextBox = new System.Windows.Forms.TextBox(); 78 this.label1 = new System.Windows.Forms.Label(); 79 this.comparisonFactorTextBox = new System.Windows.Forms.TextBox(); 80 this.label2 = new System.Windows.Forms.Label(); 81 this.successRatioLimitTextBox = new System.Windows.Forms.TextBox(); 82 this.label3 = new System.Windows.Forms.Label(); 83 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 74 84 this.tabControl.SuspendLayout(); 75 85 this.parametersTabPage.SuspendLayout(); 76 86 this.scopesTabPage.SuspendLayout(); 87 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 77 88 this.SuspendLayout(); 78 89 // … … 103 114 // parametersTabPage 104 115 // 116 this.parametersTabPage.Controls.Add(this.successRatioLimitTextBox); 117 this.parametersTabPage.Controls.Add(this.label3); 118 this.parametersTabPage.Controls.Add(this.comparisonFactorTextBox); 119 this.parametersTabPage.Controls.Add(this.label2); 120 this.parametersTabPage.Controls.Add(this.functionLibraryInjectorViewButton); 121 this.parametersTabPage.Controls.Add(this.functionLibraryInjectorSetButton); 122 this.parametersTabPage.Controls.Add(this.functionLibraryInjectorTextBox); 123 this.parametersTabPage.Controls.Add(this.label1); 105 124 this.parametersTabPage.Controls.Add(this.selectionPressureTextBox); 106 125 this.parametersTabPage.Controls.Add(this.selectionPressureLabel); … … 132 151 // 133 152 this.selectionPressureTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 134 this.selectionPressureTextBox.Location = new System.Drawing.Point(218, 130);153 this.selectionPressureTextBox.Location = new System.Drawing.Point(218, 234); 135 154 this.selectionPressureTextBox.Name = "selectionPressureTextBox"; 136 155 this.selectionPressureTextBox.Size = new System.Drawing.Size(186, 20); 137 156 this.selectionPressureTextBox.TabIndex = 17; 157 this.selectionPressureTextBox.TextChanged += new System.EventHandler(this.selectionPressureTextBox_TextChanged); 138 158 // 139 159 // selectionPressureLabel … … 141 161 this.selectionPressureLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 142 162 this.selectionPressureLabel.AutoSize = true; 143 this.selectionPressureLabel.Location = new System.Drawing.Point(65, 133);163 this.selectionPressureLabel.Location = new System.Drawing.Point(65, 237); 144 164 this.selectionPressureLabel.Name = "selectionPressureLabel"; 145 165 this.selectionPressureLabel.Size = new System.Drawing.Size(145, 13); … … 150 170 // 151 171 this.viewProblemInitializationButton.Anchor = System.Windows.Forms.AnchorStyles.None; 152 this.viewProblemInitializationButton.Location = new System.Drawing.Point(410, 2 41);172 this.viewProblemInitializationButton.Location = new System.Drawing.Point(410, 281); 153 173 this.viewProblemInitializationButton.Name = "viewProblemInitializationButton"; 154 174 this.viewProblemInitializationButton.Size = new System.Drawing.Size(53, 20); … … 161 181 // 162 182 this.setProblemInitializationButton.Anchor = System.Windows.Forms.AnchorStyles.None; 163 this.setProblemInitializationButton.Location = new System.Drawing.Point(469, 2 41);183 this.setProblemInitializationButton.Location = new System.Drawing.Point(469, 281); 164 184 this.setProblemInitializationButton.Name = "setProblemInitializationButton"; 165 185 this.setProblemInitializationButton.Size = new System.Drawing.Size(43, 20); … … 172 192 // 173 193 this.problemInitializationTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 174 this.problemInitializationTextBox.Location = new System.Drawing.Point(218, 2 41);194 this.problemInitializationTextBox.Location = new System.Drawing.Point(218, 281); 175 195 this.problemInitializationTextBox.Name = "problemInitializationTextBox"; 176 196 this.problemInitializationTextBox.ReadOnly = true; … … 192 212 // 193 213 this.elitesTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 194 this.elitesTextBox.Location = new System.Drawing.Point(218, 1 82);214 this.elitesTextBox.Location = new System.Drawing.Point(218, 104); 195 215 this.elitesTextBox.Name = "elitesTextBox"; 196 216 this.elitesTextBox.Size = new System.Drawing.Size(186, 20); 197 217 this.elitesTextBox.TabIndex = 11; 218 this.elitesTextBox.TextChanged += new System.EventHandler(this.elitesTextBox_TextChanged); 198 219 // 199 220 // problemInitializationLabel … … 201 222 this.problemInitializationLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 202 223 this.problemInitializationLabel.AutoSize = true; 203 this.problemInitializationLabel.Location = new System.Drawing.Point(65, 2 44);224 this.problemInitializationLabel.Location = new System.Drawing.Point(65, 284); 204 225 this.problemInitializationLabel.Name = "problemInitializationLabel"; 205 226 this.problemInitializationLabel.Size = new System.Drawing.Size(105, 13); … … 211 232 this.elitesLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 212 233 this.elitesLabel.AutoSize = true; 213 this.elitesLabel.Location = new System.Drawing.Point(66, 1 85);234 this.elitesLabel.Location = new System.Drawing.Point(66, 107); 214 235 this.elitesLabel.Name = "elitesLabel"; 215 236 this.elitesLabel.Size = new System.Drawing.Size(35, 13); … … 220 241 // 221 242 this.mutationRateTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 222 this.mutationRateTextBox.Location = new System.Drawing.Point(218, 1 56);243 this.mutationRateTextBox.Location = new System.Drawing.Point(218, 130); 223 244 this.mutationRateTextBox.Name = "mutationRateTextBox"; 224 245 this.mutationRateTextBox.Size = new System.Drawing.Size(186, 20); 225 246 this.mutationRateTextBox.TabIndex = 9; 247 this.mutationRateTextBox.TextChanged += new System.EventHandler(this.mutationRateTextBox_TextChanged); 226 248 // 227 249 // mutationRateLabel … … 229 251 this.mutationRateLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 230 252 this.mutationRateLabel.AutoSize = true; 231 this.mutationRateLabel.Location = new System.Drawing.Point(66, 1 59);253 this.mutationRateLabel.Location = new System.Drawing.Point(66, 133); 232 254 this.mutationRateLabel.Name = "mutationRateLabel"; 233 255 this.mutationRateLabel.Size = new System.Drawing.Size(77, 13); … … 238 260 // 239 261 this.maximumEvaluatedSolutionsTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 240 this.maximumEvaluatedSolutionsTextBox.Location = new System.Drawing.Point(218, 104);262 this.maximumEvaluatedSolutionsTextBox.Location = new System.Drawing.Point(218, 208); 241 263 this.maximumEvaluatedSolutionsTextBox.Name = "maximumEvaluatedSolutionsTextBox"; 242 264 this.maximumEvaluatedSolutionsTextBox.Size = new System.Drawing.Size(186, 20); 243 265 this.maximumEvaluatedSolutionsTextBox.TabIndex = 7; 266 this.maximumEvaluatedSolutionsTextBox.TextChanged += new System.EventHandler(this.maximumEvaluatedSolutionsTextBox_TextChanged); 244 267 // 245 268 // maxEvaluatedSolutionsLabel … … 247 270 this.maxEvaluatedSolutionsLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 248 271 this.maxEvaluatedSolutionsLabel.AutoSize = true; 249 this.maxEvaluatedSolutionsLabel.Location = new System.Drawing.Point(65, 107);272 this.maxEvaluatedSolutionsLabel.Location = new System.Drawing.Point(65, 211); 250 273 this.maxEvaluatedSolutionsLabel.Name = "maxEvaluatedSolutionsLabel"; 251 274 this.maxEvaluatedSolutionsLabel.Size = new System.Drawing.Size(130, 13); … … 260 283 this.randomSeedTextBox.Size = new System.Drawing.Size(186, 20); 261 284 this.randomSeedTextBox.TabIndex = 3; 285 this.randomSeedTextBox.TextChanged += new System.EventHandler(this.randomSeedTextBox_TextChanged); 262 286 // 263 287 // populationSizeTextBox … … 268 292 this.populationSizeTextBox.Size = new System.Drawing.Size(186, 20); 269 293 this.populationSizeTextBox.TabIndex = 5; 294 this.populationSizeTextBox.TextChanged += new System.EventHandler(this.populationSizeTextBox_TextChanged); 270 295 // 271 296 // setRandomSeedRandomlyLabel … … 353 378 this.cloneEngineButton.UseVisualStyleBackColor = true; 354 379 this.cloneEngineButton.Click += new System.EventHandler(this.cloneEngineButton_Click); 380 // 381 // functionLibraryInjectorViewButton 382 // 383 this.functionLibraryInjectorViewButton.Anchor = System.Windows.Forms.AnchorStyles.None; 384 this.functionLibraryInjectorViewButton.Location = new System.Drawing.Point(410, 307); 385 this.functionLibraryInjectorViewButton.Name = "functionLibraryInjectorViewButton"; 386 this.functionLibraryInjectorViewButton.Size = new System.Drawing.Size(53, 20); 387 this.functionLibraryInjectorViewButton.TabIndex = 20; 388 this.functionLibraryInjectorViewButton.Text = "View..."; 389 this.functionLibraryInjectorViewButton.UseVisualStyleBackColor = true; 390 this.functionLibraryInjectorViewButton.Click += new System.EventHandler(this.functionLibraryInjectorViewButton_Click); 391 // 392 // functionLibraryInjectorSetButton 393 // 394 this.functionLibraryInjectorSetButton.Anchor = System.Windows.Forms.AnchorStyles.None; 395 this.functionLibraryInjectorSetButton.Location = new System.Drawing.Point(469, 307); 396 this.functionLibraryInjectorSetButton.Name = "functionLibraryInjectorSetButton"; 397 this.functionLibraryInjectorSetButton.Size = new System.Drawing.Size(43, 20); 398 this.functionLibraryInjectorSetButton.TabIndex = 21; 399 this.functionLibraryInjectorSetButton.Text = "Set..."; 400 this.functionLibraryInjectorSetButton.UseVisualStyleBackColor = true; 401 this.functionLibraryInjectorSetButton.Click += new System.EventHandler(this.functionLibraryInjectorSetButton_Click); 402 // 403 // functionLibraryInjectorTextBox 404 // 405 this.functionLibraryInjectorTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 406 this.functionLibraryInjectorTextBox.Location = new System.Drawing.Point(218, 307); 407 this.functionLibraryInjectorTextBox.Name = "functionLibraryInjectorTextBox"; 408 this.functionLibraryInjectorTextBox.ReadOnly = true; 409 this.functionLibraryInjectorTextBox.Size = new System.Drawing.Size(186, 20); 410 this.functionLibraryInjectorTextBox.TabIndex = 19; 411 // 412 // label1 413 // 414 this.label1.Anchor = System.Windows.Forms.AnchorStyles.None; 415 this.label1.AutoSize = true; 416 this.label1.Location = new System.Drawing.Point(65, 310); 417 this.label1.Name = "label1"; 418 this.label1.Size = new System.Drawing.Size(81, 13); 419 this.label1.TabIndex = 18; 420 this.label1.Text = "&Function library:"; 421 // 422 // comparisonFactorTextBox 423 // 424 this.comparisonFactorTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 425 this.comparisonFactorTextBox.Location = new System.Drawing.Point(218, 156); 426 this.comparisonFactorTextBox.Name = "comparisonFactorTextBox"; 427 this.comparisonFactorTextBox.Size = new System.Drawing.Size(186, 20); 428 this.comparisonFactorTextBox.TabIndex = 23; 429 this.comparisonFactorTextBox.TextChanged += new System.EventHandler(this.comparisonFactorTextBox_TextChanged); 430 // 431 // label2 432 // 433 this.label2.Anchor = System.Windows.Forms.AnchorStyles.None; 434 this.label2.AutoSize = true; 435 this.label2.Location = new System.Drawing.Point(66, 159); 436 this.label2.Name = "label2"; 437 this.label2.Size = new System.Drawing.Size(95, 13); 438 this.label2.TabIndex = 22; 439 this.label2.Text = "Comparison factor:"; 440 // 441 // successRatioLimitTextBox 442 // 443 this.successRatioLimitTextBox.Anchor = System.Windows.Forms.AnchorStyles.None; 444 this.successRatioLimitTextBox.Location = new System.Drawing.Point(218, 182); 445 this.successRatioLimitTextBox.Name = "successRatioLimitTextBox"; 446 this.successRatioLimitTextBox.Size = new System.Drawing.Size(186, 20); 447 this.successRatioLimitTextBox.TabIndex = 25; 448 this.successRatioLimitTextBox.TextChanged += new System.EventHandler(this.successRatioLimitTextBox_TextChanged); 449 // 450 // label3 451 // 452 this.label3.Anchor = System.Windows.Forms.AnchorStyles.None; 453 this.label3.AutoSize = true; 454 this.label3.Location = new System.Drawing.Point(66, 185); 455 this.label3.Name = "label3"; 456 this.label3.Size = new System.Drawing.Size(94, 13); 457 this.label3.TabIndex = 24; 458 this.label3.Text = "Success ratio limit:"; 459 // 460 // errorProvider 461 // 462 this.errorProvider.ContainerControl = this; 355 463 // 356 464 // OffspringSelectionGpEditor … … 369 477 this.parametersTabPage.PerformLayout(); 370 478 this.scopesTabPage.ResumeLayout(false); 479 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 371 480 this.ResumeLayout(false); 372 481 … … 380 489 private System.Windows.Forms.Button abortButton; 381 490 private System.Windows.Forms.Button resetButton; 382 private System.Windows.Forms.TextBox mutationRateTextBox;383 private System.Windows.Forms.Label mutationRateLabel;384 private System.Windows.Forms.TextBox populationSizeTextBox;385 private System.Windows.Forms.Label populationSizeLabel;386 491 private System.Windows.Forms.TabPage scopesTabPage; 387 private System.Windows.Forms.TextBox maximumEvaluatedSolutionsTextBox;388 private System.Windows.Forms.Label maxEvaluatedSolutionsLabel;389 private System.Windows.Forms.TextBox elitesTextBox;390 private System.Windows.Forms.Label elitesLabel;391 private System.Windows.Forms.TextBox randomSeedTextBox;392 private System.Windows.Forms.Label setRandomSeedRandomlyLabel;393 private System.Windows.Forms.Label randomSeedLabel;394 private System.Windows.Forms.CheckBox setRandomSeedRandomlyCheckBox;395 private System.Windows.Forms.Label problemInitializationLabel;396 492 private System.Windows.Forms.Button cloneEngineButton; 397 private System.Windows.Forms.TextBox problemInitializationTextBox;398 private System.Windows.Forms.Button setProblemInitializationButton;399 493 private HeuristicLab.Core.ScopeView scopeView; 400 private System.Windows.Forms.Button viewProblemInitializationButton; 401 private System.Windows.Forms.TextBox selectionPressureTextBox; 402 private System.Windows.Forms.Label selectionPressureLabel; 494 protected System.Windows.Forms.Button functionLibraryInjectorViewButton; 495 protected System.Windows.Forms.Button functionLibraryInjectorSetButton; 496 protected System.Windows.Forms.TextBox functionLibraryInjectorTextBox; 497 protected System.Windows.Forms.Label label1; 498 protected System.Windows.Forms.TextBox comparisonFactorTextBox; 499 protected System.Windows.Forms.Label label2; 500 protected System.Windows.Forms.TextBox mutationRateTextBox; 501 protected System.Windows.Forms.Label mutationRateLabel; 502 protected System.Windows.Forms.TextBox populationSizeTextBox; 503 protected System.Windows.Forms.Label populationSizeLabel; 504 protected System.Windows.Forms.TextBox maximumEvaluatedSolutionsTextBox; 505 protected System.Windows.Forms.Label maxEvaluatedSolutionsLabel; 506 protected System.Windows.Forms.TextBox elitesTextBox; 507 protected System.Windows.Forms.Label elitesLabel; 508 protected System.Windows.Forms.TextBox randomSeedTextBox; 509 protected System.Windows.Forms.Label setRandomSeedRandomlyLabel; 510 protected System.Windows.Forms.Label randomSeedLabel; 511 protected System.Windows.Forms.CheckBox setRandomSeedRandomlyCheckBox; 512 protected System.Windows.Forms.Label problemInitializationLabel; 513 protected System.Windows.Forms.TextBox problemInitializationTextBox; 514 protected System.Windows.Forms.Button setProblemInitializationButton; 515 protected System.Windows.Forms.Button viewProblemInitializationButton; 516 protected System.Windows.Forms.TextBox selectionPressureTextBox; 517 protected System.Windows.Forms.Label selectionPressureLabel; 518 protected System.Windows.Forms.TextBox successRatioLimitTextBox; 519 protected System.Windows.Forms.Label label3; 520 private System.Windows.Forms.ErrorProvider errorProvider; 403 521 } 404 522 } -
trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.cs
r2591 r2728 64 64 } else { 65 65 tabControl.Enabled = true; 66 problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.GetType().Name; 66 problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.Name; 67 functionLibraryInjectorTextBox.Text = OffspringSelectionGP.FunctionLibraryInjector.Name; 67 68 } 68 69 } … … 76 77 mutationRateTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MutationRate"); 77 78 elitesTextBox.DataBindings.Add("Text", OffspringSelectionGP, "Elites"); 79 comparisonFactorTextBox.DataBindings.Add("Text", OffspringSelectionGP, "ComparisonFactor"); 80 successRatioLimitTextBox.DataBindings.Add("Text", OffspringSelectionGP, "SuccessRatioLimit"); 78 81 } 79 82 … … 81 84 private void viewProblemInjectorButton_Click(object sender, EventArgs e) { 82 85 IView view = OffspringSelectionGP.ProblemInjector.CreateView(); 83 if (view != null)86 if (view != null) 84 87 ControlManager.Manager.ShowControl(view); 85 88 } … … 89 92 if (chooseOperatorDialog.ShowDialog(this) == DialogResult.OK) { 90 93 OffspringSelectionGP.ProblemInjector = chooseOperatorDialog.Operator; 91 problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.GetType().Name; 92 } 93 } 94 problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.Name; 95 } 96 } 97 98 private void functionLibraryInjectorViewButton_Click(object sender, EventArgs e) { 99 IView view = OffspringSelectionGP.FunctionLibraryInjector.CreateView(); 100 if (view != null) 101 ControlManager.Manager.ShowControl(view); 102 } 103 104 private void functionLibraryInjectorSetButton_Click(object sender, EventArgs e) { 105 if (chooseOperatorDialog == null) chooseOperatorDialog = new ChooseOperatorDialog(); 106 if (chooseOperatorDialog.ShowDialog(this) == DialogResult.OK) { 107 OffspringSelectionGP.FunctionLibraryInjector = chooseOperatorDialog.Operator; 108 functionLibraryInjectorTextBox.Text = OffspringSelectionGP.FunctionLibraryInjector.Name; 109 } 110 } 111 94 112 private void executeButton_Click(object sender, EventArgs e) { 95 113 executeButton.Enabled = false; … … 120 138 } 121 139 private void Engine_Finished(object sender, EventArgs e) { 122 if (InvokeRequired)140 if (InvokeRequired) 123 141 Invoke((EventHandler)Engine_Finished, sender, e); 124 142 else { … … 135 153 randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked; 136 154 } 155 156 private void randomSeedTextBox_TextChanged(object sender, EventArgs e) { 157 int randomSeed; 158 if (int.TryParse(randomSeedTextBox.Text, out randomSeed)) { 159 //OffspringSelectionGP.RandomSeed = randomSeed; 160 errorProvider.SetError(randomSeedTextBox, string.Empty); 161 } else { 162 errorProvider.SetError(randomSeedTextBox, "Invalid value."); 163 } 164 } 165 166 private void populationSizeTextBox_TextChanged(object sender, EventArgs e) { 167 int popSize; 168 if (int.TryParse(populationSizeTextBox.Text, out popSize) && popSize > 1) { 169 //OffspringSelectionGP.PopulationSize = popSize; 170 errorProvider.SetError(populationSizeTextBox, string.Empty); 171 } else { 172 errorProvider.SetError(populationSizeTextBox, "Population size must be a positive integer > 0."); 173 } 174 } 175 176 private void elitesTextBox_TextChanged(object sender, EventArgs e) { 177 int elites; 178 if (int.TryParse(elitesTextBox.Text, out elites) && elites >= 0 && elites < OffspringSelectionGP.PopulationSize) { 179 //OffspringSelectionGP.Elites = elites; 180 errorProvider.SetError(elitesTextBox, string.Empty); 181 } else { 182 errorProvider.SetError(elitesTextBox, "Invalid value for number of elites. Allowed range [0.." + OffspringSelectionGP.PopulationSize + "[."); 183 } 184 } 185 186 private void mutationRateTextBox_TextChanged(object sender, EventArgs e) { 187 double mutationRate; 188 if (double.TryParse(mutationRateTextBox.Text, out mutationRate) && mutationRate >= 0.0 && mutationRate <= 1.0) { 189 //OffspringSelectionGP.MutationRate = mutationRate; 190 errorProvider.SetError(mutationRateTextBox, string.Empty); 191 } else { 192 errorProvider.SetError(mutationRateTextBox, "Invalid value for mutation rate. Allowed range = [0..1]."); 193 } 194 } 195 196 private void comparisonFactorTextBox_TextChanged(object sender, EventArgs e) { 197 double comparisonFactor; 198 if (double.TryParse(comparisonFactorTextBox.Text, out comparisonFactor) && comparisonFactor >= 0.0 && comparisonFactor <= 1.0) { 199 //OffspringSelectionGP.ComparisonFactor = comparisonFactor; 200 errorProvider.SetError(comparisonFactorTextBox, string.Empty); 201 } else { 202 errorProvider.SetError(comparisonFactorTextBox, "Invalid value for comparison factor. Allowed range = [0..1]."); 203 } 204 } 205 206 private void successRatioLimitTextBox_TextChanged(object sender, EventArgs e) { 207 double successRatioLimit; 208 if (double.TryParse(successRatioLimitTextBox.Text, out successRatioLimit) && successRatioLimit >= 0.0 && successRatioLimit <= 1.0) { 209 //OffspringSelectionGP.SuccessRatioLimit = successRatioLimit; 210 errorProvider.SetError(successRatioLimitTextBox, string.Empty); 211 } else { 212 errorProvider.SetError(successRatioLimitTextBox, "Invalid value for success ratio limit. Allowed range = [0..1]."); 213 } 214 } 215 216 private void maximumEvaluatedSolutionsTextBox_TextChanged(object sender, EventArgs e) { 217 int maxEvaluatedSolutions; 218 if (int.TryParse(maximumEvaluatedSolutionsTextBox.Text, out maxEvaluatedSolutions) && maxEvaluatedSolutions > 0) { 219 //OffspringSelectionGP.MaxEvaluatedSolutions = maxEvaluatedSolutions; 220 errorProvider.SetError(maximumEvaluatedSolutionsTextBox, string.Empty); 221 } else { 222 errorProvider.SetError(maximumEvaluatedSolutionsTextBox, "Max. evaluated solutions must be a positive integer > 0."); 223 } 224 } 225 226 private void selectionPressureTextBox_TextChanged(object sender, EventArgs e) { 227 double maxSelPres; 228 if (double.TryParse(selectionPressureTextBox.Text, out maxSelPres) && maxSelPres > 1.0) { 229 //OffspringSelectionGP.SelectionPressureLimit = maxSelPres; 230 errorProvider.SetError(selectionPressureTextBox, string.Empty); 231 } else { 232 errorProvider.SetError(selectionPressureTextBox, "Selection pressure limit must be > 1.0."); 233 } 234 } 137 235 } 138 236 } -
trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.resx
r2341 r2728 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 121 <value>17, 17</value> 122 </metadata> 120 123 </root> -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/ArithmeticFunctionLibraryInjector.cs
r2566 r2728 32 32 public const string MAXTIMEOFFSET = "MaxTimeOffset"; 33 33 34 public const string DIFFERENTIALS_ALLOWED = "Differentials";35 36 34 private int minTimeOffset; 37 35 private int maxTimeOffset; … … 45 43 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); 46 44 AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In)); 47 48 AddVariable(DIFFERENTIALS_ALLOWED, false);49 }50 51 private void AddVariable(string name, bool allowed) {52 AddVariableInfo(new VariableInfo(name, name + " allowed", typeof(BoolData), Core.VariableKind.New));53 GetVariableInfo(name).Local = true;54 AddVariable(new Core.Variable(name, new BoolData(allowed)));55 45 } 56 46 … … 77 67 Subtraction subtraction = new Subtraction(); 78 68 79 List<IFunction> doubleFunctions = new List<IFunction>(); 80 if (GetVariableValue<BoolData>(DIFFERENTIALS_ALLOWED, null, false).Data) 81 doubleFunctions.Add(differential); 82 doubleFunctions.Add(variable); 83 doubleFunctions.Add(constant); 84 doubleFunctions.Add(addition); 85 doubleFunctions.Add(division); 86 doubleFunctions.Add(multiplication); 87 doubleFunctions.Add(subtraction); 69 List<IFunction> doubleFunctions = new List<IFunction>() { 70 differential, variable, constant, addition, division, multiplication, subtraction 71 }; 88 72 89 73 SetAllowedSubOperators(addition, doubleFunctions); … … 92 76 SetAllowedSubOperators(subtraction, doubleFunctions); 93 77 94 if (GetVariableValue<BoolData>(DIFFERENTIALS_ALLOWED, null, false).Data) 95 functionLibrary.AddFunction(differential); 96 functionLibrary.AddFunction(variable); 97 functionLibrary.AddFunction(constant); 98 functionLibrary.AddFunction(addition); 99 functionLibrary.AddFunction(division); 100 functionLibrary.AddFunction(multiplication); 101 functionLibrary.AddFunction(subtraction); 78 doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 102 79 103 80 variable.SetConstraints(minTimeOffset, maxTimeOffset); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/DefaultFunctionLibraryInjector.cs
r2566 r2728 32 32 public const string MAXTIMEOFFSET = "MaxTimeOffset"; 33 33 34 public const string DIFFERENTIALS_ALLOWED = "Differentials";35 public const string VARIABLES_ALLOWED = "Variables";36 public const string CONSTANTS_ALLOWED = "Constants";37 public const string ADDITION_ALLOWED = "Addition";38 public const string AVERAGE_ALLOWED = "Average";39 public const string AND_ALLOWED = "And";40 public const string COSINUS_ALLOWED = "Cosinus";41 public const string DIVISION_ALLOWED = "Division";42 public const string EQUAL_ALLOWED = "Equal";43 public const string EXPONENTIAL_ALLOWED = "Exponential";44 public const string GREATERTHAN_ALLOWED = "GreaterThan";45 public const string IFTHENELSE_ALLOWED = "IfThenElse";46 public const string LESSTHAN_ALLOWED = "LessThan";47 public const string LOGARTIHM_ALLOWED = "Logarithm";48 public const string MULTIPLICATION_ALLOWED = "Multiplication";49 public const string NOT_ALLOWED = "Not";50 public const string POWER_ALLOWED = "Power";51 public const string OR_ALLOWED = "Or";52 public const string SIGNUM_ALLOWED = "Signum";53 public const string SINUS_ALLOWED = "Sinus";54 public const string SQRT_ALLOWED = "SquareRoot";55 public const string SUBTRACTION_ALLOWED = "Subtraction";56 public const string TANGENS_ALLOWED = "Tangens";57 public const string XOR_ALLOWED = "Xor";58 59 34 private int minTimeOffset; 60 35 private int maxTimeOffset; 61 36 62 37 public override string Description { 63 get { return @"Injects a configurablefunction library for regression and classification problems."; }38 get { return @"Injects a default function library for regression and classification problems."; } 64 39 } 65 40 … … 68 43 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); 69 44 AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In)); 70 71 AddVariable(DIFFERENTIALS_ALLOWED, false);72 AddVariable(VARIABLES_ALLOWED, true);73 AddVariable(CONSTANTS_ALLOWED, true);74 AddVariable(ADDITION_ALLOWED, true);75 AddVariable(AVERAGE_ALLOWED, false);76 AddVariable(AND_ALLOWED, true);77 AddVariable(COSINUS_ALLOWED, true);78 AddVariable(DIVISION_ALLOWED, true);79 AddVariable(EQUAL_ALLOWED, true);80 AddVariable(EXPONENTIAL_ALLOWED, true);81 AddVariable(GREATERTHAN_ALLOWED, true);82 AddVariable(IFTHENELSE_ALLOWED, true);83 AddVariable(LESSTHAN_ALLOWED, true);84 AddVariable(LOGARTIHM_ALLOWED, true);85 AddVariable(MULTIPLICATION_ALLOWED, true);86 AddVariable(NOT_ALLOWED, true);87 AddVariable(POWER_ALLOWED, true);88 AddVariable(OR_ALLOWED, true);89 AddVariable(SIGNUM_ALLOWED, true);90 AddVariable(SINUS_ALLOWED, true);91 AddVariable(SQRT_ALLOWED, true);92 AddVariable(SUBTRACTION_ALLOWED, true);93 AddVariable(TANGENS_ALLOWED, true);94 AddVariable(XOR_ALLOWED, false);95 }96 97 private void AddVariable(string name, bool allowed) {98 AddVariableInfo(new VariableInfo(name, name + " allowed", typeof(BoolData), Core.VariableKind.New));99 GetVariableInfo(name).Local = true;100 AddVariable(new Core.Variable(name, new BoolData(allowed)));101 45 } 102 46 … … 141 85 142 86 143 List<IFunction> booleanFunctions = new List<IFunction>(); 144 ConditionalAddFunction(AND_ALLOWED, and, booleanFunctions); 145 ConditionalAddFunction(EQUAL_ALLOWED, equal, booleanFunctions); 146 ConditionalAddFunction(GREATERTHAN_ALLOWED, greaterThan, booleanFunctions); 147 ConditionalAddFunction(LESSTHAN_ALLOWED, lessThan, booleanFunctions); 148 ConditionalAddFunction(NOT_ALLOWED, not, booleanFunctions); 149 ConditionalAddFunction(OR_ALLOWED, or, booleanFunctions); 150 ConditionalAddFunction(XOR_ALLOWED, xor, booleanFunctions); 87 List<IFunction> booleanFunctions = new List<IFunction>() { 88 and, equal, greaterThan, lessThan, not, or, xor 89 }; 151 90 152 List<IFunction> doubleFunctions = new List<IFunction>(); 153 ConditionalAddFunction(DIFFERENTIALS_ALLOWED, differential, doubleFunctions); 154 ConditionalAddFunction(VARIABLES_ALLOWED, variable, doubleFunctions); 155 ConditionalAddFunction(CONSTANTS_ALLOWED, constant, doubleFunctions); 156 ConditionalAddFunction(ADDITION_ALLOWED, addition, doubleFunctions); 157 ConditionalAddFunction(AVERAGE_ALLOWED, average, doubleFunctions); 158 ConditionalAddFunction(COSINUS_ALLOWED, cosinus, doubleFunctions); 159 ConditionalAddFunction(DIVISION_ALLOWED, division, doubleFunctions); 160 ConditionalAddFunction(EXPONENTIAL_ALLOWED, exponential, doubleFunctions); 161 ConditionalAddFunction(IFTHENELSE_ALLOWED, ifThenElse, doubleFunctions); 162 ConditionalAddFunction(LOGARTIHM_ALLOWED, logarithm, doubleFunctions); 163 ConditionalAddFunction(MULTIPLICATION_ALLOWED, multiplication, doubleFunctions); 164 ConditionalAddFunction(POWER_ALLOWED, power, doubleFunctions); 165 ConditionalAddFunction(SIGNUM_ALLOWED, signum, doubleFunctions); 166 ConditionalAddFunction(SINUS_ALLOWED, sinus, doubleFunctions); 167 ConditionalAddFunction(SQRT_ALLOWED, sqrt, doubleFunctions); 168 ConditionalAddFunction(SUBTRACTION_ALLOWED, subtraction, doubleFunctions); 169 ConditionalAddFunction(TANGENS_ALLOWED, tangens, doubleFunctions); 91 92 List<IFunction> doubleFunctions = new List<IFunction>() { 93 differential, variable, constant, addition, average, cosinus, division, exponential, 94 ifThenElse, logarithm, multiplication, power, signum, sinus, sqrt, subtraction, tangens}; 170 95 171 96 SetAllowedSubOperators(and, booleanFunctions); … … 193 118 SetAllowedSubOperators(tangens, doubleFunctions); 194 119 195 ConditionalAddOperator(DIFFERENTIALS_ALLOWED, functionLibrary, differential); 196 ConditionalAddOperator(VARIABLES_ALLOWED, functionLibrary, variable); 197 ConditionalAddOperator(CONSTANTS_ALLOWED, functionLibrary, constant); 198 ConditionalAddOperator(ADDITION_ALLOWED, functionLibrary, addition); 199 ConditionalAddOperator(AVERAGE_ALLOWED, functionLibrary, average); 200 ConditionalAddOperator(AND_ALLOWED, functionLibrary, and); 201 ConditionalAddOperator(COSINUS_ALLOWED, functionLibrary, cosinus); 202 ConditionalAddOperator(DIVISION_ALLOWED, functionLibrary, division); 203 ConditionalAddOperator(EQUAL_ALLOWED, functionLibrary, equal); 204 ConditionalAddOperator(EXPONENTIAL_ALLOWED, functionLibrary, exponential); 205 ConditionalAddOperator(GREATERTHAN_ALLOWED, functionLibrary, greaterThan); 206 ConditionalAddOperator(IFTHENELSE_ALLOWED, functionLibrary, ifThenElse); 207 ConditionalAddOperator(LESSTHAN_ALLOWED, functionLibrary, lessThan); 208 ConditionalAddOperator(LOGARTIHM_ALLOWED, functionLibrary, logarithm); 209 ConditionalAddOperator(MULTIPLICATION_ALLOWED, functionLibrary, multiplication); 210 ConditionalAddOperator(NOT_ALLOWED, functionLibrary, not); 211 ConditionalAddOperator(POWER_ALLOWED, functionLibrary, power); 212 ConditionalAddOperator(OR_ALLOWED, functionLibrary, or); 213 ConditionalAddOperator(SIGNUM_ALLOWED, functionLibrary, signum); 214 ConditionalAddOperator(SINUS_ALLOWED, functionLibrary, sinus); 215 ConditionalAddOperator(SQRT_ALLOWED, functionLibrary, sqrt); 216 ConditionalAddOperator(SUBTRACTION_ALLOWED, functionLibrary, subtraction); 217 ConditionalAddOperator(TANGENS_ALLOWED, functionLibrary, tangens); 218 ConditionalAddOperator(XOR_ALLOWED, functionLibrary, xor); 120 doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 121 booleanFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 219 122 220 123 variable.SetConstraints(minTimeOffset, maxTimeOffset); -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs
r2675 r2728 32 32 public const string MAXTIMEOFFSET = "MaxTimeOffset"; 33 33 34 public const string DIFFERENTIALS_ALLOWED = "Differentials";35 36 34 private int minTimeOffset; 37 35 private int maxTimeOffset; … … 45 43 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); 46 44 AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In)); 47 48 AddVariable(DIFFERENTIALS_ALLOWED, false);49 }50 51 private void AddVariable(string name, bool allowed) {52 AddVariableInfo(new VariableInfo(name, name + " allowed", typeof(BoolData), Core.VariableKind.New));53 GetVariableInfo(name).Local = true;54 AddVariable(new Core.Variable(name, new BoolData(allowed)));55 45 } 56 46 … … 68 58 protected override FunctionLibrary CreateFunctionLibrary() { 69 59 return Create( 70 GetVariableValue<BoolData>(DIFFERENTIALS_ALLOWED, null, false).Data,71 60 minTimeOffset, 72 61 maxTimeOffset); 73 62 } 74 63 75 public static FunctionLibrary Create( bool differentialAllowed,int minTimeOffset, int maxTimeOffset) {64 public static FunctionLibrary Create(int minTimeOffset, int maxTimeOffset) { 76 65 FunctionLibrary functionLibrary = new FunctionLibrary(); 77 66 … … 91 80 Tangens tangens = new Tangens(); 92 81 93 List<IFunction> valueNodes = new List<IFunction>(); 94 if (differentialAllowed) valueNodes.Add(differential); 95 valueNodes.Add(variable); 96 valueNodes.Add(constant); 82 List<IFunction> valueNodes = new List<IFunction>() { 83 differential, variable, constant 84 }; 85 List<IFunction> arithmeticFunctions = new List<IFunction>() { 86 addition, division, multiplication, subtraction, 87 }; 97 88 98 List<IFunction> arithmeticFunctions = new List<IFunction>(); 99 arithmeticFunctions.Add(addition); 100 arithmeticFunctions.Add(division); 101 arithmeticFunctions.Add(multiplication); 102 arithmeticFunctions.Add(subtraction); 103 104 List<IFunction> complexFunctions = new List<IFunction>(); 105 complexFunctions.Add(cosinus); 106 complexFunctions.Add(exponential); 107 complexFunctions.Add(logarithm); 108 complexFunctions.Add(power); 109 complexFunctions.Add(sinus); 110 complexFunctions.Add(sqrt); 111 complexFunctions.Add(tangens); 89 List<IFunction> complexFunctions = new List<IFunction>() { 90 cosinus, exponential, logarithm, power, sinus, sqrt, tangens 91 }; 112 92 113 93 List<IFunction> allFunctions = new List<IFunction>(); … … 129 109 SetAllowedSubOperators(tangens, valueNodes); 130 110 131 if (differentialAllowed) functionLibrary.AddFunction(differential);132 133 111 allFunctions.ForEach(x => functionLibrary.AddFunction(x)); 134 112 -
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/UnconstrainedFunctionLibraryInjector.cs
r2566 r2728 32 32 public const string MAXTIMEOFFSET = "MaxTimeOffset"; 33 33 34 public const string DIFFERENTIALS_ALLOWED = "Differentials"; 35 public const string VARIABLES_ALLOWED = "Variables"; 36 public const string CONSTANTS_ALLOWED = "Constants"; 37 public const string ADDITION_ALLOWED = "Addition"; 38 public const string AVERAGE_ALLOWED = "Average"; 39 public const string AND_ALLOWED = "And"; 40 public const string COSINUS_ALLOWED = "Cosinus"; 41 public const string DIVISION_ALLOWED = "Division"; 42 public const string EQUAL_ALLOWED = "Equal"; 43 public const string EXPONENTIAL_ALLOWED = "Exponential"; 44 public const string GREATERTHAN_ALLOWED = "GreaterThan"; 45 public const string IFTHENELSE_ALLOWED = "IfThenElse"; 46 public const string LESSTHAN_ALLOWED = "LessThan"; 47 public const string LOGARTIHM_ALLOWED = "Logarithm"; 48 public const string MULTIPLICATION_ALLOWED = "Multiplication"; 49 public const string NOT_ALLOWED = "Not"; 50 public const string POWER_ALLOWED = "Power"; 51 public const string OR_ALLOWED = "Or"; 52 public const string SIGNUM_ALLOWED = "Signum"; 53 public const string SINUS_ALLOWED = "Sinus"; 54 public const string SQRT_ALLOWED = "SquareRoot"; 55 public const string SUBTRACTION_ALLOWED = "Subtraction"; 56 public const string TANGENS_ALLOWED = "Tangens"; 57 public const string XOR_ALLOWED = "Xor"; private int minTimeOffset; 34 private int minTimeOffset; 58 35 private int maxTimeOffset; 59 36 … … 66 43 AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In)); 67 44 AddVariableInfo(new VariableInfo(MAXTIMEOFFSET, "Maximal time offset for all feature", typeof(IntData), VariableKind.In)); 68 69 AddVariable(DIFFERENTIALS_ALLOWED, false);70 AddVariable(VARIABLES_ALLOWED, true);71 AddVariable(CONSTANTS_ALLOWED, true);72 AddVariable(ADDITION_ALLOWED, true);73 AddVariable(AVERAGE_ALLOWED, false);74 AddVariable(AND_ALLOWED, true);75 AddVariable(COSINUS_ALLOWED, true);76 AddVariable(DIVISION_ALLOWED, true);77 AddVariable(EQUAL_ALLOWED, true);78 AddVariable(EXPONENTIAL_ALLOWED, true);79 AddVariable(GREATERTHAN_ALLOWED, true);80 AddVariable(IFTHENELSE_ALLOWED, true);81 AddVariable(LESSTHAN_ALLOWED, true);82 AddVariable(LOGARTIHM_ALLOWED, true);83 AddVariable(MULTIPLICATION_ALLOWED, true);84 AddVariable(NOT_ALLOWED, true);85 AddVariable(POWER_ALLOWED, true);86 AddVariable(OR_ALLOWED, true);87 AddVariable(SIGNUM_ALLOWED, true);88 AddVariable(SINUS_ALLOWED, true);89 AddVariable(SQRT_ALLOWED, true);90 AddVariable(SUBTRACTION_ALLOWED, true);91 AddVariable(TANGENS_ALLOWED, true);92 AddVariable(XOR_ALLOWED, false);93 }94 95 private void AddVariable(string name, bool allowed) {96 AddVariableInfo(new VariableInfo(name, name + " allowed", typeof(BoolData), Core.VariableKind.New));97 GetVariableInfo(name).Local = true;98 AddVariable(new Core.Variable(name, new BoolData(allowed)));99 45 } 100 46 … … 138 84 Xor xor = new Xor(); 139 85 140 List<IFunction> doubleFunctions = new List<IFunction>(); 141 ConditionalAddFunction(DIFFERENTIALS_ALLOWED, differential, doubleFunctions); 142 ConditionalAddFunction(VARIABLES_ALLOWED, variable, doubleFunctions); 143 ConditionalAddFunction(CONSTANTS_ALLOWED, constant, doubleFunctions); 144 ConditionalAddFunction(ADDITION_ALLOWED, addition, doubleFunctions); 145 ConditionalAddFunction(AVERAGE_ALLOWED, average, doubleFunctions); 146 ConditionalAddFunction(COSINUS_ALLOWED, cosinus, doubleFunctions); 147 ConditionalAddFunction(DIVISION_ALLOWED, division, doubleFunctions); 148 ConditionalAddFunction(EXPONENTIAL_ALLOWED, exponential, doubleFunctions); 149 ConditionalAddFunction(IFTHENELSE_ALLOWED, ifThenElse, doubleFunctions); 150 ConditionalAddFunction(LOGARTIHM_ALLOWED, logarithm, doubleFunctions); 151 ConditionalAddFunction(MULTIPLICATION_ALLOWED, multiplication, doubleFunctions); 152 ConditionalAddFunction(POWER_ALLOWED, power, doubleFunctions); 153 ConditionalAddFunction(SIGNUM_ALLOWED, signum, doubleFunctions); 154 ConditionalAddFunction(SINUS_ALLOWED, sinus, doubleFunctions); 155 ConditionalAddFunction(SQRT_ALLOWED, sqrt, doubleFunctions); 156 ConditionalAddFunction(SUBTRACTION_ALLOWED, subtraction, doubleFunctions); 157 ConditionalAddFunction(TANGENS_ALLOWED, tangens, doubleFunctions); 158 ConditionalAddFunction(AND_ALLOWED, and, doubleFunctions); 159 ConditionalAddFunction(EQUAL_ALLOWED, equal, doubleFunctions); 160 ConditionalAddFunction(GREATERTHAN_ALLOWED, greaterThan, doubleFunctions); 161 ConditionalAddFunction(LESSTHAN_ALLOWED, lessThan, doubleFunctions); 162 ConditionalAddFunction(NOT_ALLOWED, not, doubleFunctions); 163 ConditionalAddFunction(OR_ALLOWED, or, doubleFunctions); 164 ConditionalAddFunction(XOR_ALLOWED, xor, doubleFunctions); 165 86 List<IFunction> doubleFunctions = new List<IFunction>() { 87 differential, variable, constant, addition, average, cosinus, division, exponential, ifThenElse,logarithm, multiplication, 88 power, signum, sinus, sqrt, subtraction, tangens, and, equal, greaterThan, lessThan, not, or, xor 89 }; 166 90 167 91 SetAllowedSubOperators(and, doubleFunctions); … … 187 111 SetAllowedSubOperators(tangens, doubleFunctions); 188 112 189 ConditionalAddOperator(DIFFERENTIALS_ALLOWED, functionLibrary, differential); 190 ConditionalAddOperator(VARIABLES_ALLOWED, functionLibrary, variable); 191 ConditionalAddOperator(CONSTANTS_ALLOWED, functionLibrary, constant); 192 ConditionalAddOperator(ADDITION_ALLOWED, functionLibrary, addition); 193 ConditionalAddOperator(AVERAGE_ALLOWED, functionLibrary, average); 194 ConditionalAddOperator(AND_ALLOWED, functionLibrary, and); 195 ConditionalAddOperator(COSINUS_ALLOWED, functionLibrary, cosinus); 196 ConditionalAddOperator(DIVISION_ALLOWED, functionLibrary, division); 197 ConditionalAddOperator(EQUAL_ALLOWED, functionLibrary, equal); 198 ConditionalAddOperator(EXPONENTIAL_ALLOWED, functionLibrary, exponential); 199 ConditionalAddOperator(GREATERTHAN_ALLOWED, functionLibrary, greaterThan); 200 ConditionalAddOperator(IFTHENELSE_ALLOWED, functionLibrary, ifThenElse); 201 ConditionalAddOperator(LESSTHAN_ALLOWED, functionLibrary, lessThan); 202 ConditionalAddOperator(LOGARTIHM_ALLOWED, functionLibrary, logarithm); 203 ConditionalAddOperator(MULTIPLICATION_ALLOWED, functionLibrary, multiplication); 204 ConditionalAddOperator(NOT_ALLOWED, functionLibrary, not); 205 ConditionalAddOperator(POWER_ALLOWED, functionLibrary, power); 206 ConditionalAddOperator(OR_ALLOWED, functionLibrary, or); 207 ConditionalAddOperator(SIGNUM_ALLOWED, functionLibrary, signum); 208 ConditionalAddOperator(SINUS_ALLOWED, functionLibrary, sinus); 209 ConditionalAddOperator(SQRT_ALLOWED, functionLibrary, sqrt); 210 ConditionalAddOperator(SUBTRACTION_ALLOWED, functionLibrary, subtraction); 211 ConditionalAddOperator(TANGENS_ALLOWED, functionLibrary, tangens); 212 ConditionalAddOperator(XOR_ALLOWED, functionLibrary, xor); 113 doubleFunctions.ForEach(fun => functionLibrary.AddFunction(fun)); 213 114 214 115 variable.SetConstraints(minTimeOffset, maxTimeOffset); -
trunk/sources/HeuristicLab.GP.Tests/SimpleFunctionLibraryTest.cs
r2675 r2728 56 56 MersenneTwister twister = new MersenneTwister(); 57 57 Dataset ds = Util.CreateRandomDataset(twister, 1, 20); 58 randomTrees = Util.CreateRandomTrees(twister, ds, SimpleFunctionLibraryInjector.Create( true,-3, 0), N, 1, 100);58 randomTrees = Util.CreateRandomTrees(twister, ds, SimpleFunctionLibraryInjector.Create(-3, 0), N, 1, 100); 59 59 } 60 60 -
trunk/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionLibraryInjectorBase.cs
r2616 r2728 36 36 } 37 37 38 private FunctionLibrary functionLibrary; 39 public FunctionLibrary FunctionLibrary { 40 get { 41 return functionLibrary; 42 } 43 set { 44 this.functionLibrary = value; 45 FireChanged(); 46 } 47 } 48 38 49 public FunctionLibraryInjectorBase() 39 50 : base() { 40 51 AddVariableInfo(new VariableInfo(FUNCTIONLIBRARY, "Preconfigured default function library", typeof(FunctionLibrary), VariableKind.New)); 52 // create the default function library 53 functionLibrary = CreateFunctionLibrary(); 41 54 } 42 55 43 56 public override IOperation Apply(IScope scope) { 44 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(FUNCTIONLIBRARY), CreateFunctionLibrary()));57 scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName(FUNCTIONLIBRARY), functionLibrary)); 45 58 return null; 46 59 } … … 59 72 } 60 73 } 74 75 public override IView CreateView() { 76 return new FunctionLibraryInjectorView(this); 77 } 61 78 } 62 79 } -
trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.Designer.cs
r2701 r2728 63 63 this.mutationListView = new System.Windows.Forms.ListView(); 64 64 this.mutationVariableView = new HeuristicLab.Core.VariableView(); 65 this.testTabPage = new System.Windows.Forms.TabPage(); 66 this.outputTextBox = new System.Windows.Forms.TextBox(); 65 67 this.tabControl.SuspendLayout(); 66 68 this.functionsTabPage.SuspendLayout(); … … 78 80 this.mutationSplitContainer.Panel2.SuspendLayout(); 79 81 this.mutationSplitContainer.SuspendLayout(); 82 this.testTabPage.SuspendLayout(); 80 83 this.SuspendLayout(); 81 84 // … … 85 88 this.tabControl.Controls.Add(this.initializationTabPage); 86 89 this.tabControl.Controls.Add(this.mutationTabPage); 90 this.tabControl.Controls.Add(this.testTabPage); 87 91 this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; 88 92 this.tabControl.Location = new System.Drawing.Point(0, 0); … … 91 95 this.tabControl.Size = new System.Drawing.Size(677, 561); 92 96 this.tabControl.TabIndex = 1; 97 this.tabControl.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl_Selected); 93 98 // 94 99 // functionsTabPage … … 146 151 this.functionsListView.View = System.Windows.Forms.View.List; 147 152 this.functionsListView.SelectedIndexChanged += new System.EventHandler(this.functionsListView_SelectedIndexChanged); 153 this.functionsListView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.functionsListView_KeyUp); 148 154 this.functionsListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.functionsListView_ItemDrag); 149 155 // … … 299 305 this.mutationVariableView.TabIndex = 0; 300 306 this.mutationVariableView.Variable = null; 307 // 308 // testTabPage 309 // 310 this.testTabPage.Controls.Add(this.outputTextBox); 311 this.testTabPage.Location = new System.Drawing.Point(4, 22); 312 this.testTabPage.Name = "testTabPage"; 313 this.testTabPage.Padding = new System.Windows.Forms.Padding(3); 314 this.testTabPage.Size = new System.Drawing.Size(669, 535); 315 this.testTabPage.TabIndex = 3; 316 this.testTabPage.Text = "Test function library"; 317 this.testTabPage.UseVisualStyleBackColor = true; 318 // 319 // outputTextBox 320 // 321 this.outputTextBox.Dock = System.Windows.Forms.DockStyle.Fill; 322 this.outputTextBox.Location = new System.Drawing.Point(3, 3); 323 this.outputTextBox.Multiline = true; 324 this.outputTextBox.Name = "outputTextBox"; 325 this.outputTextBox.Size = new System.Drawing.Size(663, 529); 326 this.outputTextBox.TabIndex = 0; 301 327 // 302 328 // FunctionLibraryEditor … … 322 348 this.mutationSplitContainer.Panel2.ResumeLayout(false); 323 349 this.mutationSplitContainer.ResumeLayout(false); 350 this.testTabPage.ResumeLayout(false); 351 this.testTabPage.PerformLayout(); 324 352 this.ResumeLayout(false); 325 353 … … 346 374 private System.Windows.Forms.GroupBox availableFunctionsGroupBox; 347 375 private System.Windows.Forms.GroupBox functionDetailsGroupBox; 376 private System.Windows.Forms.TabPage testTabPage; 377 private System.Windows.Forms.TextBox outputTextBox; 348 378 } 349 379 } -
trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs
r2701 r2728 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.GP.Interfaces; 28 using System.Text; 29 using HeuristicLab.Random; 28 30 29 31 namespace HeuristicLab.GP { … … 35 37 } 36 38 37 public FunctionLibraryEditor( FunctionLibrary library)39 public FunctionLibraryEditor() 38 40 : base() { 39 41 InitializeComponent(); 42 } 43 44 public FunctionLibraryEditor(FunctionLibrary library) 45 : this() { 40 46 FunctionLibrary = library; 41 47 } … … 48 54 protected override void UpdateControls() { 49 55 base.UpdateControls(); 56 mutationListView.Items.Clear(); 57 initListView.Items.Clear(); 50 58 functionsListView.Clear(); 51 59 functionsComboBox.Items.Clear(); … … 92 100 // delete from the end of the list 93 101 List<int> removeIndices = functionsListView.SelectedIndices.OfType<int>().OrderBy(x => 1.0 / x).ToList(); 94 foreach (int selectedIndex in removeIndices) { 95 FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag); 102 try { 103 Cursor = Cursors.WaitCursor; 104 foreach (int selectedIndex in removeIndices) { 105 FunctionLibrary.RemoveFunction((IFunction)functionsListView.Items[selectedIndex].Tag); 106 } 107 } 108 finally { 109 Cursor = Cursors.Default; 96 110 } 97 111 } … … 131 145 } 132 146 } 147 148 private void functionsListView_KeyUp(object sender, KeyEventArgs e) { 149 if (e.KeyCode == Keys.Delete && functionsListView.SelectedItems.Count > 0) { 150 List<IFunction> removedFunctions = new List<IFunction>(from x in functionsListView.SelectedItems.OfType<ListViewItem>() 151 select (IFunction)x.Tag); 152 try { 153 Cursor = Cursors.WaitCursor; 154 foreach (var fun in removedFunctions) { 155 FunctionLibrary.RemoveFunction(fun); 156 } 157 } 158 finally { 159 Cursor = Cursors.Default; 160 } 161 } 162 } 163 164 private void tabControl_Selected(object sender, TabControlEventArgs e) { 165 if (e.TabPage == testTabPage) { 166 outputTextBox.Text = TestFunctionLibrary(); 167 } 168 } 169 170 private string TestFunctionLibrary() { 171 int n = 1000; 172 IFunctionTree[] randomTrees = CreateRandomTrees(n, 1, 100); 173 174 StringBuilder builder = new StringBuilder(); 175 builder.AppendLine(CalculateFunctionFrequencies(randomTrees)); 176 return builder.ToString(); 177 } 178 179 private string CalculateFunctionFrequencies(IFunctionTree[] randomTrees) { 180 Dictionary<IFunction, int> occurances = new Dictionary<IFunction, int>(); 181 double n = 0.0; 182 for (int i = 0; i < randomTrees.Length; i++) { 183 foreach (var node in FunctionTreeIterator.IteratePrefix(randomTrees[i])) { 184 if (node.SubTrees.Count > 0) { 185 if (!occurances.ContainsKey(node.Function)) 186 occurances[node.Function] = 0; 187 occurances[node.Function]++; 188 n++; 189 } 190 } 191 } 192 StringBuilder strBuilder = new StringBuilder(); 193 foreach (var function in occurances.Keys) { 194 strBuilder.Append(Environment.NewLine); 195 strBuilder.Append(function.Name); strBuilder.Append(": "); 196 strBuilder.AppendFormat("{0:#0.00%}", occurances[function] / n); 197 } 198 return strBuilder.ToString(); 199 } 200 201 private IFunctionTree[] CreateRandomTrees(int popSize, int minSize, int maxSize) { 202 int maxHeight = 10; 203 int maxTries = 100; 204 IFunctionTree[] randomTrees = new IFunctionTree[popSize]; 205 MersenneTwister twister = new MersenneTwister(); 206 for (int i = 0; i < randomTrees.Length; i++) { 207 int treeSize = twister.Next(minSize, maxSize); 208 IFunctionTree root; 209 int tries = 0; 210 TreeGardener gardener = new TreeGardener(twister, FunctionLibrary); 211 do { 212 root = gardener.PTC2(treeSize, maxSize); 213 if (tries++ >= maxTries) { 214 // try a different size 215 treeSize = twister.Next(minSize, maxSize); 216 tries = 0; 217 } 218 } while (root.GetSize() > maxSize || root.GetHeight() > maxHeight); 219 randomTrees[i] = root; 220 } 221 return randomTrees; 222 } 223 133 224 } 134 225 } -
trunk/sources/HeuristicLab.GP/3.3/FunctionView.cs
r2701 r2728 165 165 if (e.Data.GetDataPresent("IFunction")) { 166 166 IFunction fun = (IFunction)e.Data.GetData("IFunction"); 167 try { 168 Cursor = Cursors.WaitCursor; 169 if (selectedSlot == ALL_SLOTS) { 170 for (int slot = 0; slot < function.MaxSubTrees; slot++) 171 function.AddAllowedSubFunction(fun, slot); 172 } else { 173 int slot = int.Parse(selectedSlot); 174 function.AddAllowedSubFunction(fun, slot); 175 } 176 } 177 finally { 178 Cursor = Cursors.Default; 179 } 180 } 181 } 182 } 183 184 private void subFunctionsListBox_KeyUp(object sender, KeyEventArgs e) { 185 try { 186 Cursor = Cursors.WaitCursor; 187 if (subFunctionsListBox.SelectedItems.Count > 0 && e.KeyCode == Keys.Delete) { 167 188 if (selectedSlot == ALL_SLOTS) { 168 for (int slot = 0; slot < function.MaxSubTrees; slot++) 169 function.AddAllowedSubFunction(fun, slot); 189 for (int slot = 0; slot < function.MaxSubTrees; slot++) { 190 foreach (var subFun in subFunctionsListBox.SelectedItems) { 191 function.RemoveAllowedSubFunction((IFunction)subFun, slot); 192 } 193 } 170 194 } else { 171 195 int slot = int.Parse(selectedSlot); 172 function.AddAllowedSubFunction(fun, slot);173 }174 }175 }176 }177 178 private void subFunctionsListBox_KeyUp(object sender, KeyEventArgs e) {179 if (subFunctionsListBox.SelectedItems.Count > 0 && e.KeyCode == Keys.Delete) {180 181 if (selectedSlot == ALL_SLOTS) {182 for (int slot = 0; slot < function.MaxSubTrees; slot++) {183 196 foreach (var subFun in subFunctionsListBox.SelectedItems) { 184 197 function.RemoveAllowedSubFunction((IFunction)subFun, slot); 185 198 } 186 199 } 187 } else { 188 int slot = int.Parse(selectedSlot); 189 foreach (var subFun in subFunctionsListBox.SelectedItems) { 190 function.RemoveAllowedSubFunction((IFunction)subFun, slot); 191 } 200 192 201 } 193 202 } 203 finally { 204 Cursor = Cursors.Default; 194 205 } 195 206 } -
trunk/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj
r2701 r2728 89 89 <Compile Include="BaseClasses\Terminal.cs" /> 90 90 <Compile Include="BaseClasses\UnaryFunction.cs" /> 91 <Compile Include="FunctionLibraryInjectorView.cs"> 92 <SubType>UserControl</SubType> 93 </Compile> 94 <Compile Include="FunctionLibraryInjectorView.Designer.cs"> 95 <DependentUpon>FunctionLibraryInjectorView.cs</DependentUpon> 96 </Compile> 91 97 <Compile Include="FunctionView.cs"> 92 98 <SubType>UserControl</SubType> … … 138 144 </ItemGroup> 139 145 <ItemGroup> 146 <EmbeddedResource Include="FunctionLibraryInjectorView.resx"> 147 <DependentUpon>FunctionLibraryInjectorView.cs</DependentUpon> 148 </EmbeddedResource> 140 149 <EmbeddedResource Include="FunctionView.resx"> 141 150 <DependentUpon>FunctionView.cs</DependentUpon>
Note: See TracChangeset
for help on using the changeset viewer.