Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2728


Ignore:
Timestamp:
02/01/10 08:52:32 (14 years ago)
Author:
gkronber
Message:

Created a specialized view for function library injectors which allows full configuration of the function library. #748 (FunctionLibraryView is empty)

Location:
trunk/sources
Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.Designer.cs

    r2341 r2728  
    4646    /// </summary>
    4747    private void InitializeComponent() {
     48      this.components = new System.ComponentModel.Container();
    4849      this.executeButton = new System.Windows.Forms.Button();
    4950      this.tabControl = new System.Windows.Forms.TabControl();
     
    7273      this.resetButton = new System.Windows.Forms.Button();
    7374      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);
    7484      this.tabControl.SuspendLayout();
    7585      this.parametersTabPage.SuspendLayout();
    7686      this.scopesTabPage.SuspendLayout();
     87      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    7788      this.SuspendLayout();
    7889      //
     
    103114      // parametersTabPage
    104115      //
     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);
    105124      this.parametersTabPage.Controls.Add(this.selectionPressureTextBox);
    106125      this.parametersTabPage.Controls.Add(this.selectionPressureLabel);
     
    132151      //
    133152      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);
    135154      this.selectionPressureTextBox.Name = "selectionPressureTextBox";
    136155      this.selectionPressureTextBox.Size = new System.Drawing.Size(186, 20);
    137156      this.selectionPressureTextBox.TabIndex = 17;
     157      this.selectionPressureTextBox.TextChanged += new System.EventHandler(this.selectionPressureTextBox_TextChanged);
    138158      //
    139159      // selectionPressureLabel
     
    141161      this.selectionPressureLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    142162      this.selectionPressureLabel.AutoSize = true;
    143       this.selectionPressureLabel.Location = new System.Drawing.Point(65, 133);
     163      this.selectionPressureLabel.Location = new System.Drawing.Point(65, 237);
    144164      this.selectionPressureLabel.Name = "selectionPressureLabel";
    145165      this.selectionPressureLabel.Size = new System.Drawing.Size(145, 13);
     
    150170      //
    151171      this.viewProblemInitializationButton.Anchor = System.Windows.Forms.AnchorStyles.None;
    152       this.viewProblemInitializationButton.Location = new System.Drawing.Point(410, 241);
     172      this.viewProblemInitializationButton.Location = new System.Drawing.Point(410, 281);
    153173      this.viewProblemInitializationButton.Name = "viewProblemInitializationButton";
    154174      this.viewProblemInitializationButton.Size = new System.Drawing.Size(53, 20);
     
    161181      //
    162182      this.setProblemInitializationButton.Anchor = System.Windows.Forms.AnchorStyles.None;
    163       this.setProblemInitializationButton.Location = new System.Drawing.Point(469, 241);
     183      this.setProblemInitializationButton.Location = new System.Drawing.Point(469, 281);
    164184      this.setProblemInitializationButton.Name = "setProblemInitializationButton";
    165185      this.setProblemInitializationButton.Size = new System.Drawing.Size(43, 20);
     
    172192      //
    173193      this.problemInitializationTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;
    174       this.problemInitializationTextBox.Location = new System.Drawing.Point(218, 241);
     194      this.problemInitializationTextBox.Location = new System.Drawing.Point(218, 281);
    175195      this.problemInitializationTextBox.Name = "problemInitializationTextBox";
    176196      this.problemInitializationTextBox.ReadOnly = true;
     
    192212      //
    193213      this.elitesTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;
    194       this.elitesTextBox.Location = new System.Drawing.Point(218, 182);
     214      this.elitesTextBox.Location = new System.Drawing.Point(218, 104);
    195215      this.elitesTextBox.Name = "elitesTextBox";
    196216      this.elitesTextBox.Size = new System.Drawing.Size(186, 20);
    197217      this.elitesTextBox.TabIndex = 11;
     218      this.elitesTextBox.TextChanged += new System.EventHandler(this.elitesTextBox_TextChanged);
    198219      //
    199220      // problemInitializationLabel
     
    201222      this.problemInitializationLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    202223      this.problemInitializationLabel.AutoSize = true;
    203       this.problemInitializationLabel.Location = new System.Drawing.Point(65, 244);
     224      this.problemInitializationLabel.Location = new System.Drawing.Point(65, 284);
    204225      this.problemInitializationLabel.Name = "problemInitializationLabel";
    205226      this.problemInitializationLabel.Size = new System.Drawing.Size(105, 13);
     
    211232      this.elitesLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    212233      this.elitesLabel.AutoSize = true;
    213       this.elitesLabel.Location = new System.Drawing.Point(66, 185);
     234      this.elitesLabel.Location = new System.Drawing.Point(66, 107);
    214235      this.elitesLabel.Name = "elitesLabel";
    215236      this.elitesLabel.Size = new System.Drawing.Size(35, 13);
     
    220241      //
    221242      this.mutationRateTextBox.Anchor = System.Windows.Forms.AnchorStyles.None;
    222       this.mutationRateTextBox.Location = new System.Drawing.Point(218, 156);
     243      this.mutationRateTextBox.Location = new System.Drawing.Point(218, 130);
    223244      this.mutationRateTextBox.Name = "mutationRateTextBox";
    224245      this.mutationRateTextBox.Size = new System.Drawing.Size(186, 20);
    225246      this.mutationRateTextBox.TabIndex = 9;
     247      this.mutationRateTextBox.TextChanged += new System.EventHandler(this.mutationRateTextBox_TextChanged);
    226248      //
    227249      // mutationRateLabel
     
    229251      this.mutationRateLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    230252      this.mutationRateLabel.AutoSize = true;
    231       this.mutationRateLabel.Location = new System.Drawing.Point(66, 159);
     253      this.mutationRateLabel.Location = new System.Drawing.Point(66, 133);
    232254      this.mutationRateLabel.Name = "mutationRateLabel";
    233255      this.mutationRateLabel.Size = new System.Drawing.Size(77, 13);
     
    238260      //
    239261      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);
    241263      this.maximumEvaluatedSolutionsTextBox.Name = "maximumEvaluatedSolutionsTextBox";
    242264      this.maximumEvaluatedSolutionsTextBox.Size = new System.Drawing.Size(186, 20);
    243265      this.maximumEvaluatedSolutionsTextBox.TabIndex = 7;
     266      this.maximumEvaluatedSolutionsTextBox.TextChanged += new System.EventHandler(this.maximumEvaluatedSolutionsTextBox_TextChanged);
    244267      //
    245268      // maxEvaluatedSolutionsLabel
     
    247270      this.maxEvaluatedSolutionsLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    248271      this.maxEvaluatedSolutionsLabel.AutoSize = true;
    249       this.maxEvaluatedSolutionsLabel.Location = new System.Drawing.Point(65, 107);
     272      this.maxEvaluatedSolutionsLabel.Location = new System.Drawing.Point(65, 211);
    250273      this.maxEvaluatedSolutionsLabel.Name = "maxEvaluatedSolutionsLabel";
    251274      this.maxEvaluatedSolutionsLabel.Size = new System.Drawing.Size(130, 13);
     
    260283      this.randomSeedTextBox.Size = new System.Drawing.Size(186, 20);
    261284      this.randomSeedTextBox.TabIndex = 3;
     285      this.randomSeedTextBox.TextChanged += new System.EventHandler(this.randomSeedTextBox_TextChanged);
    262286      //
    263287      // populationSizeTextBox
     
    268292      this.populationSizeTextBox.Size = new System.Drawing.Size(186, 20);
    269293      this.populationSizeTextBox.TabIndex = 5;
     294      this.populationSizeTextBox.TextChanged += new System.EventHandler(this.populationSizeTextBox_TextChanged);
    270295      //
    271296      // setRandomSeedRandomlyLabel
     
    353378      this.cloneEngineButton.UseVisualStyleBackColor = true;
    354379      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;
    355463      //
    356464      // OffspringSelectionGpEditor
     
    369477      this.parametersTabPage.PerformLayout();
    370478      this.scopesTabPage.ResumeLayout(false);
     479      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    371480      this.ResumeLayout(false);
    372481
     
    380489    private System.Windows.Forms.Button abortButton;
    381490    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;
    386491    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;
    396492    private System.Windows.Forms.Button cloneEngineButton;
    397     private System.Windows.Forms.TextBox problemInitializationTextBox;
    398     private System.Windows.Forms.Button setProblemInitializationButton;
    399493    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;
    403521  }
    404522}
  • trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.cs

    r2591 r2728  
    6464      } else {
    6565        tabControl.Enabled = true;
    66         problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.GetType().Name;
     66        problemInitializationTextBox.Text = OffspringSelectionGP.ProblemInjector.Name;
     67        functionLibraryInjectorTextBox.Text = OffspringSelectionGP.FunctionLibraryInjector.Name;
    6768      }
    6869    }
     
    7677      mutationRateTextBox.DataBindings.Add("Text", OffspringSelectionGP, "MutationRate");
    7778      elitesTextBox.DataBindings.Add("Text", OffspringSelectionGP, "Elites");
     79      comparisonFactorTextBox.DataBindings.Add("Text", OffspringSelectionGP, "ComparisonFactor");
     80      successRatioLimitTextBox.DataBindings.Add("Text", OffspringSelectionGP, "SuccessRatioLimit");
    7881    }
    7982
     
    8184    private void viewProblemInjectorButton_Click(object sender, EventArgs e) {
    8285      IView view = OffspringSelectionGP.ProblemInjector.CreateView();
    83       if(view != null)
     86      if (view != null)
    8487        ControlManager.Manager.ShowControl(view);
    8588    }
     
    8992      if (chooseOperatorDialog.ShowDialog(this) == DialogResult.OK) {
    9093        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
    94112    private void executeButton_Click(object sender, EventArgs e) {
    95113      executeButton.Enabled = false;
     
    120138    }
    121139    private void Engine_Finished(object sender, EventArgs e) {
    122       if(InvokeRequired)
     140      if (InvokeRequired)
    123141        Invoke((EventHandler)Engine_Finished, sender, e);
    124142      else {
     
    135153      randomSeedLabel.Enabled = !setRandomSeedRandomlyCheckBox.Checked;
    136154    }
     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    }
    137235  }
    138236}
  • trunk/sources/HeuristicLab.GP.Algorithms/3.2/OffSpringSelectionGpEditor.resx

    r2341 r2728  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </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>
    120123</root>
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/ArithmeticFunctionLibraryInjector.cs

    r2566 r2728  
    3232    public const string MAXTIMEOFFSET = "MaxTimeOffset";
    3333
    34     public const string DIFFERENTIALS_ALLOWED = "Differentials";
    35 
    3634    private int minTimeOffset;
    3735    private int maxTimeOffset;
     
    4543      AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    4644      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)));
    5545    }
    5646
     
    7767      Subtraction subtraction = new Subtraction();
    7868
    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      };
    8872
    8973      SetAllowedSubOperators(addition, doubleFunctions);
     
    9276      SetAllowedSubOperators(subtraction, doubleFunctions);
    9377
    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));
    10279
    10380      variable.SetConstraints(minTimeOffset, maxTimeOffset);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/DefaultFunctionLibraryInjector.cs

    r2566 r2728  
    3232    public const string MAXTIMEOFFSET = "MaxTimeOffset";
    3333
    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 
    5934    private int minTimeOffset;
    6035    private int maxTimeOffset;
    6136
    6237    public override string Description {
    63       get { return @"Injects a configurable function library for regression and classification problems."; }
     38      get { return @"Injects a default function library for regression and classification problems."; }
    6439    }
    6540
     
    6843      AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    6944      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)));
    10145    }
    10246
     
    14185
    14286
    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      };
    15190
    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};
    17095
    17196      SetAllowedSubOperators(and, booleanFunctions);
     
    193118      SetAllowedSubOperators(tangens, doubleFunctions);
    194119
    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));
    219122
    220123      variable.SetConstraints(minTimeOffset, maxTimeOffset);
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/SimpleFunctionLibraryInjector.cs

    r2675 r2728  
    3232    public const string MAXTIMEOFFSET = "MaxTimeOffset";
    3333
    34     public const string DIFFERENTIALS_ALLOWED = "Differentials";
    35 
    3634    private int minTimeOffset;
    3735    private int maxTimeOffset;
     
    4543      AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    4644      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)));
    5545    }
    5646
     
    6858    protected override FunctionLibrary CreateFunctionLibrary() {
    6959      return Create(
    70         GetVariableValue<BoolData>(DIFFERENTIALS_ALLOWED, null, false).Data,
    7160        minTimeOffset,
    7261        maxTimeOffset);
    7362    }
    7463
    75     public static FunctionLibrary Create(bool differentialAllowed, int minTimeOffset, int maxTimeOffset) {
     64    public static FunctionLibrary Create(int minTimeOffset, int maxTimeOffset) {
    7665      FunctionLibrary functionLibrary = new FunctionLibrary();
    7766
     
    9180      Tangens tangens = new Tangens();
    9281
    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      };
    9788
    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      };
    11292
    11393      List<IFunction> allFunctions = new List<IFunction>();
     
    129109      SetAllowedSubOperators(tangens, valueNodes);
    130110
    131       if (differentialAllowed) functionLibrary.AddFunction(differential);
    132 
    133111      allFunctions.ForEach(x => functionLibrary.AddFunction(x));
    134112
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/FunctionLibraryInjectors/UnconstrainedFunctionLibraryInjector.cs

    r2566 r2728  
    3232    public const string MAXTIMEOFFSET = "MaxTimeOffset";
    3333
    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;
    5835    private int maxTimeOffset;
    5936
     
    6643      AddVariableInfo(new VariableInfo(MINTIMEOFFSET, "Minimal time offset for all features", typeof(IntData), VariableKind.In));
    6744      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)));
    9945    }
    10046
     
    13884      Xor xor = new Xor();
    13985
    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      };
    16690
    16791      SetAllowedSubOperators(and, doubleFunctions);
     
    187111      SetAllowedSubOperators(tangens, doubleFunctions);
    188112
    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));
    213114
    214115      variable.SetConstraints(minTimeOffset, maxTimeOffset);
  • trunk/sources/HeuristicLab.GP.Tests/SimpleFunctionLibraryTest.cs

    r2675 r2728  
    5656      MersenneTwister twister = new MersenneTwister();
    5757      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);
    5959    }
    6060
  • trunk/sources/HeuristicLab.GP/3.3/BaseClasses/FunctionLibraryInjectorBase.cs

    r2616 r2728  
    3636    }
    3737
     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
    3849    public FunctionLibraryInjectorBase()
    3950      : base() {
    4051      AddVariableInfo(new VariableInfo(FUNCTIONLIBRARY, "Preconfigured default function library", typeof(FunctionLibrary), VariableKind.New));
     52      // create the default function library
     53      functionLibrary = CreateFunctionLibrary();
    4154    }
    4255
    4356    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));
    4558      return null;
    4659    }
     
    5972      }
    6073    }
     74
     75    public override IView CreateView() {
     76      return new FunctionLibraryInjectorView(this);
     77    }
    6178  }
    6279}
  • trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.Designer.cs

    r2701 r2728  
    6363      this.mutationListView = new System.Windows.Forms.ListView();
    6464      this.mutationVariableView = new HeuristicLab.Core.VariableView();
     65      this.testTabPage = new System.Windows.Forms.TabPage();
     66      this.outputTextBox = new System.Windows.Forms.TextBox();
    6567      this.tabControl.SuspendLayout();
    6668      this.functionsTabPage.SuspendLayout();
     
    7880      this.mutationSplitContainer.Panel2.SuspendLayout();
    7981      this.mutationSplitContainer.SuspendLayout();
     82      this.testTabPage.SuspendLayout();
    8083      this.SuspendLayout();
    8184      //
     
    8588      this.tabControl.Controls.Add(this.initializationTabPage);
    8689      this.tabControl.Controls.Add(this.mutationTabPage);
     90      this.tabControl.Controls.Add(this.testTabPage);
    8791      this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
    8892      this.tabControl.Location = new System.Drawing.Point(0, 0);
     
    9195      this.tabControl.Size = new System.Drawing.Size(677, 561);
    9296      this.tabControl.TabIndex = 1;
     97      this.tabControl.Selected += new System.Windows.Forms.TabControlEventHandler(this.tabControl_Selected);
    9398      //
    9499      // functionsTabPage
     
    146151      this.functionsListView.View = System.Windows.Forms.View.List;
    147152      this.functionsListView.SelectedIndexChanged += new System.EventHandler(this.functionsListView_SelectedIndexChanged);
     153      this.functionsListView.KeyUp += new System.Windows.Forms.KeyEventHandler(this.functionsListView_KeyUp);
    148154      this.functionsListView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.functionsListView_ItemDrag);
    149155      //
     
    299305      this.mutationVariableView.TabIndex = 0;
    300306      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;
    301327      //
    302328      // FunctionLibraryEditor
     
    322348      this.mutationSplitContainer.Panel2.ResumeLayout(false);
    323349      this.mutationSplitContainer.ResumeLayout(false);
     350      this.testTabPage.ResumeLayout(false);
     351      this.testTabPage.PerformLayout();
    324352      this.ResumeLayout(false);
    325353
     
    346374    private System.Windows.Forms.GroupBox availableFunctionsGroupBox;
    347375    private System.Windows.Forms.GroupBox functionDetailsGroupBox;
     376    private System.Windows.Forms.TabPage testTabPage;
     377    private System.Windows.Forms.TextBox outputTextBox;
    348378  }
    349379}
  • trunk/sources/HeuristicLab.GP/3.3/FunctionLibraryEditor.cs

    r2701 r2728  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.GP.Interfaces;
     28using System.Text;
     29using HeuristicLab.Random;
    2830
    2931namespace HeuristicLab.GP {
     
    3537    }
    3638
    37     public FunctionLibraryEditor(FunctionLibrary library)
     39    public FunctionLibraryEditor()
    3840      : base() {
    3941      InitializeComponent();
     42    }
     43
     44    public FunctionLibraryEditor(FunctionLibrary library)
     45      : this() {
    4046      FunctionLibrary = library;
    4147    }
     
    4854    protected override void UpdateControls() {
    4955      base.UpdateControls();
     56      mutationListView.Items.Clear();
     57      initListView.Items.Clear();
    5058      functionsListView.Clear();
    5159      functionsComboBox.Items.Clear();
     
    92100      // delete from the end of the list
    93101      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;
    96110      }
    97111    }
     
    131145      }
    132146    }
     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
    133224  }
    134225}
  • trunk/sources/HeuristicLab.GP/3.3/FunctionView.cs

    r2701 r2728  
    165165        if (e.Data.GetDataPresent("IFunction")) {
    166166          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) {
    167188          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            }
    170194          } else {
    171195            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++) {
    183196            foreach (var subFun in subFunctionsListBox.SelectedItems) {
    184197              function.RemoveAllowedSubFunction((IFunction)subFun, slot);
    185198            }
    186199          }
    187         } else {
    188           int slot = int.Parse(selectedSlot);
    189           foreach (var subFun in subFunctionsListBox.SelectedItems) {
    190             function.RemoveAllowedSubFunction((IFunction)subFun, slot);
    191           }
     200
    192201        }
    193 
     202      }
     203      finally {
     204        Cursor = Cursors.Default;
    194205      }
    195206    }
  • trunk/sources/HeuristicLab.GP/3.3/HeuristicLab.GP-3.3.csproj

    r2701 r2728  
    8989    <Compile Include="BaseClasses\Terminal.cs" />
    9090    <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>
    9197    <Compile Include="FunctionView.cs">
    9298      <SubType>UserControl</SubType>
     
    138144  </ItemGroup>
    139145  <ItemGroup>
     146    <EmbeddedResource Include="FunctionLibraryInjectorView.resx">
     147      <DependentUpon>FunctionLibraryInjectorView.cs</DependentUpon>
     148    </EmbeddedResource>
    140149    <EmbeddedResource Include="FunctionView.resx">
    141150      <DependentUpon>FunctionView.cs</DependentUpon>
Note: See TracChangeset for help on using the changeset viewer.