Changeset 8535


Ignore:
Timestamp:
08/29/12 09:22:21 (7 years ago)
Author:
jkarder
Message:

#1853:

  • enhanced combinations count calculation
  • restructured code
  • minor code improvements
  • added license information
Location:
branches/ParameterConfigurationEncoding
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.Designer.cs

    r8524 r8535  
    5757      this.okButton = new System.Windows.Forms.Button();
    5858      this.cancelButton = new System.Windows.Forms.Button();
    59       this.calculateCombinationsButton = new System.Windows.Forms.Button();
    6059      this.combinationsLabel = new System.Windows.Forms.Label();
    61       this.combinationsTextBox = new System.Windows.Forms.TextBox();
    6260      this.configurationTabControl = new System.Windows.Forms.TabControl();
    6361      this.parameterConfigurationTabPage = new System.Windows.Forms.TabPage();
     62      this.parameterConfigurationTreeView = new HeuristicLab.Encodings.ParameterConfigurationEncoding.Views.ParameterConfigurationTreeView();
    6463      this.problemInstancesTabPage = new System.Windows.Forms.TabPage();
    6564      this.instanceTreeView = new System.Windows.Forms.TreeView();
     
    6766      this.libraryComboBox = new System.Windows.Forms.ComboBox();
    6867      this.instanceDiscoveryBackgroundWorker = new System.ComponentModel.BackgroundWorker();
    69       this.parameterConfigurationTreeView = new HeuristicLab.Encodings.ParameterConfigurationEncoding.Views.ParameterConfigurationTreeView();
     68      this.combinationsCountLabel = new System.Windows.Forms.Label();
    7069      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    7170      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    188187      this.cancelButton.UseVisualStyleBackColor = true;
    189188      //
    190       // calculateCombinationsButton
    191       //
    192       this.calculateCombinationsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    193       this.calculateCombinationsButton.Location = new System.Drawing.Point(12, 557);
    194       this.calculateCombinationsButton.Name = "calculateCombinationsButton";
    195       this.calculateCombinationsButton.Size = new System.Drawing.Size(148, 23);
    196       this.calculateCombinationsButton.TabIndex = 9;
    197       this.calculateCombinationsButton.Text = "Calculate Combinations";
    198       this.calculateCombinationsButton.UseVisualStyleBackColor = true;
    199       this.calculateCombinationsButton.Click += new System.EventHandler(this.calculateCombinationsButton_Click);
    200       //
    201189      // combinationsLabel
    202190      //
    203191      this.combinationsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    204192      this.combinationsLabel.AutoSize = true;
    205       this.combinationsLabel.Location = new System.Drawing.Point(166, 562);
     193      this.combinationsLabel.Location = new System.Drawing.Point(12, 562);
    206194      this.combinationsLabel.Name = "combinationsLabel";
    207195      this.combinationsLabel.Size = new System.Drawing.Size(73, 13);
    208196      this.combinationsLabel.TabIndex = 10;
    209197      this.combinationsLabel.Text = "Combinations:";
    210       //
    211       // combinationsTextBox
    212       //
    213       this.combinationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    214                   | System.Windows.Forms.AnchorStyles.Right)));
    215       this.combinationsTextBox.Location = new System.Drawing.Point(245, 559);
    216       this.combinationsTextBox.Name = "combinationsTextBox";
    217       this.combinationsTextBox.ReadOnly = true;
    218       this.combinationsTextBox.Size = new System.Drawing.Size(565, 20);
    219       this.combinationsTextBox.TabIndex = 11;
    220198      //
    221199      // configurationTabControl
     
    243221      this.parameterConfigurationTabPage.Text = "Parameter Configuration";
    244222      this.parameterConfigurationTabPage.UseVisualStyleBackColor = true;
     223      //
     224      // parameterConfigurationTreeView
     225      //
     226      this.parameterConfigurationTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     227                  | System.Windows.Forms.AnchorStyles.Left)
     228                  | System.Windows.Forms.AnchorStyles.Right)));
     229      this.parameterConfigurationTreeView.Caption = "ParameterConfiguration View";
     230      this.parameterConfigurationTreeView.Content = null;
     231      this.parameterConfigurationTreeView.Location = new System.Drawing.Point(6, 6);
     232      this.parameterConfigurationTreeView.Name = "parameterConfigurationTreeView";
     233      this.parameterConfigurationTreeView.ReadOnly = false;
     234      this.parameterConfigurationTreeView.Size = new System.Drawing.Size(940, 432);
     235      this.parameterConfigurationTreeView.TabIndex = 6;
    245236      //
    246237      // problemInstancesTabPage
     
    295286      this.instanceDiscoveryBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.instanceDiscoveryBackgroundWorker_RunWorkerCompleted);
    296287      //
    297       // parameterConfigurationTreeView
    298       //
    299       this.parameterConfigurationTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    300                   | System.Windows.Forms.AnchorStyles.Left)
    301                   | System.Windows.Forms.AnchorStyles.Right)));
    302       this.parameterConfigurationTreeView.Caption = "ParameterConfiguration View";
    303       this.parameterConfigurationTreeView.Content = null;
    304       this.parameterConfigurationTreeView.Location = new System.Drawing.Point(6, 6);
    305       this.parameterConfigurationTreeView.Name = "parameterConfigurationTreeView";
    306       this.parameterConfigurationTreeView.ReadOnly = false;
    307       this.parameterConfigurationTreeView.Size = new System.Drawing.Size(940, 432);
    308       this.parameterConfigurationTreeView.TabIndex = 6;
     288      // combinationsCountLabel
     289      //
     290      this.combinationsCountLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     291      this.combinationsCountLabel.AutoSize = true;
     292      this.combinationsCountLabel.Location = new System.Drawing.Point(91, 562);
     293      this.combinationsCountLabel.Name = "combinationsCountLabel";
     294      this.combinationsCountLabel.Size = new System.Drawing.Size(13, 13);
     295      this.combinationsCountLabel.TabIndex = 13;
     296      this.combinationsCountLabel.Text = "1";
    309297      //
    310298      // CreateExperimentDialogV2
    311299      //
     300      this.AcceptButton = this.okButton;
    312301      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     302      this.CancelButton = this.cancelButton;
    313303      this.ClientSize = new System.Drawing.Size(984, 592);
     304      this.Controls.Add(this.combinationsCountLabel);
    314305      this.Controls.Add(this.configurationTabControl);
    315       this.Controls.Add(this.combinationsTextBox);
    316306      this.Controls.Add(this.combinationsLabel);
    317       this.Controls.Add(this.calculateCombinationsButton);
    318307      this.Controls.Add(this.cancelButton);
    319308      this.Controls.Add(this.okButton);
     
    359348    private System.Windows.Forms.ErrorProvider warningProvider;
    360349    private ParameterConfigurationTreeView parameterConfigurationTreeView;
    361     private System.Windows.Forms.TextBox combinationsTextBox;
    362350    private System.Windows.Forms.Label combinationsLabel;
    363     private System.Windows.Forms.Button calculateCombinationsButton;
    364351    private System.Windows.Forms.TabControl configurationTabControl;
    365352    private System.Windows.Forms.TabPage parameterConfigurationTabPage;
     
    369356    private System.Windows.Forms.ComboBox libraryComboBox;
    370357    private System.ComponentModel.BackgroundWorker instanceDiscoveryBackgroundWorker;
     358    private System.Windows.Forms.Label combinationsCountLabel;
    371359  }
    372360}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs

    r8524 r8535  
    3636namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
    3737  public partial class CreateExperimentDialogV2 : Form {
     38    private readonly IAlgorithm algorithm;
    3839    private readonly Progress progress;
    39     private readonly IAlgorithm algorithm;
    4040    private ParameterConfigurationTree parameterConfigurationTree;
    4141    private bool createBatchRun;
    4242    private int repetitions;
    4343    private IEngine engine;
    44     private Task generation;
     44    private Task experimentGenerator;
    4545    private CancellationTokenSource cts;
    4646    private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstanceProviders;
     
    9393        parameterConfigurationTreeView.Content = parameterConfigurationTree = new ParameterConfigurationTree(algorithm, algorithm.Problem);
    9494        parameterConfigurationTree.ExperimentGenerationProgressChanged += (o, args) => progress.ProgressValue = parameterConfigurationTree.ExperimentGenerationProgress;
     95        parameterConfigurationTree.CombinationsCountChanged += (o, args) => UpdateCombinationsCount();
    9596        new ProgressView(parameterConfigurationTreeView, progress) { CancelTimeoutMs = 10000 };
    9697      } else {
     
    101102
    102103    private void CreateExperimentDialogV2_FormClosing(object sender, FormClosingEventArgs e) {
    103       if (generation != null) e.Cancel = true;
     104      if (experimentGenerator != null) e.Cancel = true;
    104105    }
    105106
     
    160161          }
    161162        }
    162       }
    163     }
    164 
    165     private void calculateCombinationsButton_Click(object sender, EventArgs e) {
    166       long parameterConfigurationsCnt = parameterConfigurationTree.GetCombinationCount(0);
    167       int problemInstanceCnt = 1 + selectedProblemInstanceProviders.Values.Sum(x => x.Count);
    168       combinationsTextBox.Text = (parameterConfigurationsCnt * problemInstanceCnt).ToString();
     163        UpdateCombinationsCount();
     164      }
    169165    }
    170166
    171167    private void okButton_Click(object sender, System.EventArgs e) {
    172168      configurationTabControl.SelectedTab = parameterConfigurationTabPage;
    173       generation = Task.Factory.StartNew(() => {
     169      experimentGenerator = Task.Factory.StartNew(() => {
    174170        StartProgressView();
    175171        var engineAlgorithm = algorithm as EngineAlgorithm;
     
    181177        finally { FinishProgressView(); }
    182178      }, cts.Token);
    183       generation.ContinueWith(t => {
    184         generation = null;
     179      experimentGenerator.ContinueWith(t => {
     180        experimentGenerator = null;
    185181        CloseDialog();
    186182      }, TaskContinuationOptions.OnlyOnRanToCompletion);
    187       generation.ContinueWith(t => {
    188         generation = null;
     183      experimentGenerator.ContinueWith(t => {
     184        experimentGenerator = null;
    189185        if (t.IsCanceled) cts = new CancellationTokenSource();
    190186        if (t.IsFaulted) {
     
    201197      repetitionsNumericUpDown.Enabled = state;
    202198      engineComboBox.Enabled = state;
    203       calculateCombinationsButton.Enabled = state;
    204199      okButton.Enabled = state;
    205200      cancelButton.Enabled = state;
     
    222217    }
    223218
     219    private void UpdateCombinationsCount() {
     220      var combinationsCount = parameterConfigurationTree.CombinationsCount;
     221      var instanceCount = 1 + selectedProblemInstanceProviders.Values.Sum(x => x.Count);
     222      combinationsCountLabel.Text = (combinationsCount * instanceCount).ToString();
     223    }
     224
    224225    private void StartProgressView() {
    225226      if (InvokeRequired) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/MenuItems/CreateExperimentMenuItemV2.cs

    r8517 r8535  
    2121
    2222using System;
    23 #region License Information
    24 /* HeuristicLab
    25  * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    26  *
    27  * This file is part of HeuristicLab.
    28  *
    29  * HeuristicLab is free software: you can redistribute it and/or modify
    30  * it under the terms of the GNU General Public License as published by
    31  * the Free Software Foundation, either version 3 of the License, or
    32  * (at your option) any later version.
    33  *
    34  * HeuristicLab is distributed in the hope that it will be useful,
    35  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    36  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    37  * GNU General Public License for more details.
    38  *
    39  * You should have received a copy of the GNU General Public License
    40  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    41  */
    42 #endregion
    43 
    4423using System.Collections.Generic;
    4524using System.Windows.Forms;
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/MessageItem.cs

    r8517 r8535  
    1 using HeuristicLab.Common;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Common;
    223using HeuristicLab.Core;
    324
     
    1132    private bool initialized = false;
    1233
    13     public MessageItem() {
     34    public MessageItem()
     35      : base() {
    1436      this.Name = "MessageItem";
    1537    }
    1638    public MessageItem(string message)
    17       : this() {
    18       this.Name = message;
    19       this.Description = "This item represents a message to the user.";
     39      : base(message, "This item represents a message to the user.") {
    2040      this.initialized = true;
    2141    }
     
    2545
    2646    public override IDeepCloneable Clone(Cloner cloner) {
    27       return new MessageItem();
     47      return new MessageItem(this, cloner);
    2848    }
    2949  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ObjectSelectorDialog.Designer.cs

    r8524 r8535  
    122122      this.Controls.Add(this.okButton);
    123123      this.Controls.Add(this.itemsListView);
     124      this.MaximizeBox = false;
     125      this.MinimizeBox = false;
    124126      this.Name = "ObjectSelectorDialog";
     127      this.ShowIcon = false;
     128      this.ShowInTaskbar = false;
     129      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    125130      this.Text = "ObjectSelectorDialog";
    126131      this.Load += new System.EventHandler(this.ObjectSelectorDialog_Load);
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ObjectSelectorDialog.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    2445    }
    2546
     47    #region Events
    2648    private void ObjectSelectorDialog_Load(object sender, EventArgs e) {
    2749      if (!initialized) {
     
    7698      okButton.Enabled = itemsListView.SelectedItems.Count == 1;
    7799    }
    78 
    79 
     100    #endregion
    80101  }
    81102}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/OptimizableView.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Linq;
    324using HeuristicLab.Core.Views;
     
    6889              this.viewHost.Content = pvc.ParameterConfigurations;
    6990            }
    70 
    71             //var symbolicVc = Content as SymbolicExpressionGrammarValueConfiguration;
    72             //if (symbolicVc != null) {
    73             //  this.viewHost.ViewsLabelVisible = false;
    74             //  this.viewHost.Content = symbolicVc.ParameterConfigurations;
    75             //}
    7691          } else {
    7792            throw new NotSupportedException("Only IParameterConfiguration and IValueConfiguration types are allowed.");
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ParameterConfigurationTreeView.cs

    r8517 r8535  
    1 using System.Windows.Forms;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222using HeuristicLab.Core.Views;
    323using HeuristicLab.MainForm;
     
    3353      SetEnabledStateOfControls();
    3454    }
    35 
    36     protected override void SetEnabledStateOfControls() {
    37       base.SetEnabledStateOfControls();
    38     }
    3955  }
    4056}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ValueConfigurationViews/RangeView.cs

    r8517 r8535  
    1 using System.Windows.Forms;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
    222using HeuristicLab.Core.Views;
    323using HeuristicLab.Data;
     
    2343    }
    2444
    25     protected override void RegisterContentEvents() {
    26       base.RegisterContentEvents();
    27     }
    28 
    29     protected override void DeregisterContentEvents() {
    30       base.DeregisterContentEvents();
    31     }
    32 
    3345    protected override void OnContentChanged() {
    3446      base.OnContentChanged();
     
    4355      }
    4456    }
    45 
    46     protected override void SetEnabledStateOfControls() {
    47       base.SetEnabledStateOfControls();
    48     }
    4957  }
    5058}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ValueConfigurationViews/ValueView.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Linq;
    324using System.Windows.Forms;
     
    829
    930namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views {
     31  /// <summary>
     32  /// The visual representation of a <see cref="ConstrainedValue"/>.
     33  /// </summary>
    1034  [View("Value View")]
    1135  [Content(typeof(ConstrainedValue), true)]
    1236  public partial class ValueView : ItemView {
    13 
     37    /// <summary>
     38    /// Gets or sets the variable to represent visually.
     39    /// </summary>
    1440    public new ConstrainedValue Content {
    1541      get { return (ConstrainedValue)base.Content; }
     
    3460      base.SetEnabledStateOfControls();
    3561      if (Content != null) {
    36         clearValueButton.Enabled = Content.Value != null && Content.IsNullable; // IsNullable ist in diesem fall nicht richtig gesetzt
     62        clearValueButton.Enabled = Content.Value != null && Content.IsNullable; // in this case IsNullable is not set correctly
    3763        setValueButton.Enabled = Content.ValueDataType != null;
    3864      }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/AlgorithmProblemItem.cs

    r8517 r8535  
    4141    [StorableConstructor]
    4242    protected AlgorithmProblemItem(bool deserializing) : base(deserializing) { }
    43     public AlgorithmProblemItem() {
     43    protected AlgorithmProblemItem(AlgorithmProblemItem original, Cloner cloner) : base(original, cloner) { }
     44    public AlgorithmProblemItem()
     45      : base() {
    4446      this.Parameters.Add(new ValueParameter<IAlgorithm>("Algorithm"));
    4547      this.Parameters.Add(new ValueParameter<IProblem>("Problem"));
    46     }
    47     protected AlgorithmProblemItem(AlgorithmProblemItem original, Cloner cloner)
    48       : base(original, cloner) {
    4948    }
    5049    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ConstrainedItemList.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using HeuristicLab.Common;
    324using HeuristicLab.Core;
     
    1940    }
    2041
    21     public ConstrainedItemList() {
    22       Type = typeof(T);
    23     }
     42    #region Constructors and Cloning
    2443    [StorableConstructor]
    2544    protected ConstrainedItemList(bool deserializing) : base(deserializing) { }
     
    2847      this.Type = original.Type;
    2948    }
     49    public ConstrainedItemList()
     50      : base() {
     51      Type = typeof(T);
     52    }
    3053    public override IDeepCloneable Clone(Cloner cloner) {
    3154      return new ConstrainedItemList<T>(this, cloner);
    3255    }
     56    #endregion
    3357  }
    3458}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ConstrainedTypeValue.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Collections.Generic;
    324using System.Linq;
     
    1132  [StorableClass]
    1233  public class ConstrainedTypeValue : TypeValue {
    13 
    1434    private IEnumerable<Type> validTypes;
    1535    public IEnumerable<Type> ValidTypes {
     
    2545    }
    2646
     47    #region Constructors and Cloning
     48    [StorableConstructor]
     49    protected ConstrainedTypeValue(bool deserializing) : base(deserializing) { }
     50    protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner)
     51      : base(original, cloner) {
     52      if (original.validTypes != null)
     53        this.validTypes = new List<Type>(original.validTypes);
     54    }
    2755    public ConstrainedTypeValue()
    2856      : base() {
     
    3361      this.Value = value;
    3462    }
    35 
    36     [StorableConstructor]
    37     protected ConstrainedTypeValue(bool deserializing) : base(deserializing) { }
    38     protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner)
    39       : base(original, cloner) {
    40       if (original.validTypes != null)
    41         this.validTypes = new List<Type>(original.validTypes);
    42     }
    4363    public override IDeepCloneable Clone(Cloner cloner) {
    4464      return new ConstrainedTypeValue(this, cloner);
    4565    }
     66    #endregion
    4667  }
    4768
     
    4970  [StorableClass]
    5071  public class ConstrainedTypeValue<T> : ConstrainedTypeValue where T : class, IItem {
    51 
     72    [StorableConstructor]
     73    protected ConstrainedTypeValue(bool deserializing)
     74      : base(deserializing) {
     75      if (deserializing) {
     76        this.ValidTypes = ApplicationManager.Manager.GetTypes(typeof(T), true).ToList();
     77      }
     78    }
     79    protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner) : base(original, cloner) { }
    5280    public ConstrainedTypeValue()
    5381      : base() {
     
    6088      this.Value = value;
    6189    }
    62 
    63     [StorableConstructor]
    64     protected ConstrainedTypeValue(bool deserializing)
    65       : base(deserializing) {
    66       if (deserializing) {
    67         this.ValidTypes = ApplicationManager.Manager.GetTypes(typeof(T), true).ToList();
    68       }
    69     }
    70 
    71     protected ConstrainedTypeValue(ConstrainedTypeValue original, Cloner cloner) : base(original, cloner) { }
    7290    public override IDeepCloneable Clone(Cloner cloner) {
    7391      return new ConstrainedTypeValue<T>(this, cloner);
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Interfaces/IOptimizable.cs

    r8517 r8535  
    4242    event EventHandler IsOptimizableChanged;
    4343    event EventHandler OptimizeChanged;
     44    event EventHandler CombinationsCountChanged;
    4445
    4546    /// <summary>
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Interfaces/IValueConfiguration.cs

    r8517 r8535  
    2828
    2929    event EventHandler ValueChanged;
    30 
    31     //void Parameterize(IParameterizedItem item);
    3230  }
    3331}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/NullValue.cs

    r8517 r8535  
    2727  [StorableClass]
    2828  public class NullValue : ValueTypeValue<int> {
    29 
    30     public NullValue() { }
    3129    [StorableConstructor]
    3230    protected NullValue(bool deserializing) : base(deserializing) { }
    33     protected NullValue(NullValue original, Cloner cloner)
    34       : base(original, cloner) {
    35     }
     31    protected NullValue(NullValue original, Cloner cloner) : base(original, cloner) { }
     32    public NullValue() : base() { }
    3633    public override IDeepCloneable Clone(Cloner cloner) {
    3734      return new NullValue(this, cloner);
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurationTree.cs

    r8524 r8535  
    3737  [StorableClass]
    3838  public class ParameterConfigurationTree : ParameterizedValueConfiguration, IEnumerable {
     39    [Storable]
     40    private long combinationsCount;
     41    public long CombinationsCount {
     42      get { return combinationsCount; }
     43      private set {
     44        if (combinationsCount != value) {
     45          combinationsCount = value;
     46          OnCombinationsCountChanged();
     47        }
     48      }
     49    }
     50
    3951    [Storable]
    4052    private DoubleValue quality;
     
    213225      this.Name = algorithm.ItemName;
    214226
    215       var algproblemitem = new AlgorithmProblemItem();
    216       algproblemitem.AlgorithmParameter.Value = algorithm;
    217       algproblemitem.ProblemParameter.Value = problem;
     227      var algProblemItem = new AlgorithmProblemItem();
     228      algProblemItem.AlgorithmParameter.Value = algorithm;
     229      algProblemItem.ProblemParameter.Value = problem;
    218230      this.discoverValidValues = false;
    219231
    220       this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Algorithm", algproblemitem.AlgorithmParameter));
    221       this.parameterConfigurations.Add(new SingleValuedParameterConfiguration("Problem", algproblemitem.ProblemParameter));
     232      var algConfig = new SingleValuedParameterConfiguration("Algorithm", algProblemItem.AlgorithmParameter);
     233      var problemConfig = new SingleValuedParameterConfiguration("Problem", algProblemItem.ProblemParameter);
     234
     235      algConfig.CombinationsCountChanged += new EventHandler(UpdateConfigurationsCount);
     236      problemConfig.CombinationsCountChanged += new EventHandler(UpdateConfigurationsCount);
     237
     238      this.parameterConfigurations.Add(algConfig);
     239      this.parameterConfigurations.Add(problemConfig);
    222240
    223241      // problems can be modified in the list of problem instances, so the parameters which are not Optimize=true,
    224242      // must not be modifiable in the parameter configuration tree. otherwise the parameter values would be ambiguous
    225243      ProblemConfiguration.ValuesReadOnly = true;
     244
     245      CombinationsCount = GetCombinationCount(0);
    226246    }
    227247
     
    233253    private void AfterDeserialization() {
    234254      if (ProblemConfiguration != null) ProblemConfiguration.ValuesReadOnly = true;
     255      CombinationsCount = GetCombinationCount(0);
    235256    }
    236257    #endregion
     
    265286    private void Quality_ValueChanged(object sender, EventArgs e) {
    266287      OnQualityChanged();
     288    }
     289
     290    private void UpdateConfigurationsCount(object sender, EventArgs e) {
     291      CombinationsCount = GetCombinationCount(0);
    267292    }
    268293
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/ParameterConfiguration.cs

    r8517 r8535  
    5757          }
    5858          OnOptimizeChanged();
     59          OnCombinationsCountChanged();
    5960          OnToStringChanged();
     61        }
     62      }
     63    }
     64
     65    [Storable]
     66    protected long combinationsCount;
     67    public virtual long CombinationsCount {
     68      get { return combinationsCount; }
     69      set {
     70        if (combinationsCount != value) {
     71          combinationsCount = value;
     72          OnCombinationsCountChanged();
    6073        }
    6174      }
     
    179192
    180193    #region Constructors and Cloning
    181     public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues) {
     194    public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues)
     195      : base() {
    182196      this.AutoPopulateValueConfigurations = true;
    183197      this.ParameterName = parameterName;
     
    202216      }
    203217    }
    204     public ParameterConfiguration(string parameterName, Type type, IItem actualValue, IEnumerable<IValueConfiguration> valueConfigurations) {
     218    public ParameterConfiguration(string parameterName, Type type, IItem actualValue, IEnumerable<IValueConfiguration> valueConfigurations)
     219      : base() {
    205220      this.AutoPopulateValueConfigurations = false;
    206221      this.ParameterName = parameterName;
     
    211226      this.validTypes = new Type[] { type };
    212227      this.IsNullable = false;
    213       this.itemImage = valueConfigurations.Count() > 0 ? valueConfigurations.FirstOrDefault().ItemImage : null;
     228      this.itemImage = valueConfigurations.Any() ? valueConfigurations.First().ItemImage : null;
    214229      this.ValueConfigurations = new CheckedValueConfigurationList(valueConfigurations);
    215230      this.ActualValue = new ConstrainedValue(actualValue, type, CreateValidValues(), this.IsNullable);
    216231    }
    217     public ParameterConfiguration(string parameterName, Type type, IItem actualValue) {
     232    public ParameterConfiguration(string parameterName, Type type, IItem actualValue)
     233      : base() {
    218234      this.AutoPopulateValueConfigurations = true;
    219235      this.ParameterName = parameterName;
     
    231247      }
    232248    }
    233     protected ParameterConfiguration() { }
     249    protected ParameterConfiguration() : base() { }
    234250    [StorableConstructor]
    235251    protected ParameterConfiguration(bool deserializing) { }
    236 
    237252    protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner)
    238253      : base(original, cloner) {
     
    316331              }
    317332            }
     333            valueConfiguration.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged();
    318334            this.ValueConfigurations.Add(valueConfiguration, true);
    319335          }
     
    357373        return new List<Type> { parameter };
    358374
    359       //TODO: not sure if this if makes sense; maybe only leave else branch here
     375      // TODO: check if this makes sense; maybe only leave else branch here
    360376      if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) {
    361377        // use existing validvalues if known
     
    391407
    392408      // copy value from ValidValues; this ensures that previously set ActualNames for a type are kept
    393       IItem value = this.validValues.Where(v => v.GetType() == type).SingleOrDefault();
     409      IItem value = this.validValues.SingleOrDefault(v => v.GetType() == type);
    394410      if (value != null)
    395411        return value;
     
    425441    private void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    426442      OnToStringChanged();
     443      OnCombinationsCountChanged();
    427444      KeepActualValueConfigurationIndexConsistent();
    428445    }
     
    430447    private void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    431448      OnToStringChanged();
     449      OnCombinationsCountChanged();
    432450      KeepActualValueConfigurationIndexConsistent();
    433451    }
    434452    private void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    435453      OnToStringChanged();
     454      OnCombinationsCountChanged();
    436455      KeepActualValueConfigurationIndexConsistent();
    437456    }
     
    451470    public virtual bool CanChangeName {
    452471      get { return false; }
    453     }
    454     public override string ItemDescription {
    455       get { return base.ItemDescription; }
    456     }
    457     public override string ItemName {
    458       get { return base.ItemName; }
    459472    }
    460473    #endregion
     
    494507    protected virtual void OnOptimizeChanged() {
    495508      var handler = OptimizeChanged;
     509      if (handler != null) handler(this, EventArgs.Empty);
     510    }
     511
     512    public event EventHandler CombinationsCountChanged;
     513    protected void OnCombinationsCountChanged() {
     514      var handler = CombinationsCountChanged;
    496515      if (handler != null) handler(this, EventArgs.Empty);
    497516    }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/SingleValuedParameterConfiguration.cs

    r8517 r8535  
    2929  [StorableClass]
    3030  public class SingleValuedParameterConfiguration : ParameterConfiguration {
    31 
    3231    #region Constructors and Cloning
    3332    [StorableConstructor]
    3433    protected SingleValuedParameterConfiguration(bool deserializing) : base(deserializing) { }
     34    protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner) : base(original, cloner) { }
    3535    public SingleValuedParameterConfiguration(string parameterName, IValueParameter valueParameter)
    3636      : base(parameterName, valueParameter, false) {
     
    5757        this.validValues,
    5858        this.IsNullable);
    59     }
    60     protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner)
    61       : base(original, cloner) {
    6259    }
    6360    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/ConstrainedValue.cs

    r8517 r8535  
    8686    }
    8787
    88     #region constructors and cloning
    89     public ConstrainedValue() { }
     88    #region Constructors and Cloning
    9089    [StorableConstructor]
    9190    protected ConstrainedValue(bool deserializing) : base(deserializing) { }
    92     public ConstrainedValue(IItem value, Type valueDataType, IItemSet<IItem> validValues, bool isNullable) {
    93       this.Value = value;
    94       this.ValueDataType = valueDataType;
    95       this.ValidValues = validValues;
    96       this.isNullable = isNullable;
    97     }
    9891    protected ConstrainedValue(ConstrainedValue original, Cloner cloner)
    9992      : base(original, cloner) {
     
    10396      this.isNullable = original.isNullable;
    10497    }
    105     public override IDeepCloneable Clone(Cloner cloner) {
    106       return new ConstrainedValue(this, cloner);
     98    public ConstrainedValue() : base() { }
     99    public ConstrainedValue(IItem value, Type valueDataType, IItemSet<IItem> validValues, bool isNullable)
     100      : base() {
     101      this.Value = value;
     102      this.ValueDataType = valueDataType;
     103      this.ValidValues = validValues;
     104      this.isNullable = isNullable;
    107105    }
    108106    [StorableHook(HookType.AfterDeserialization)]
    109107    private void AfterDeserialization() {
    110108      if (this.value != null) RegisterEvents();
     109    }
     110    public override IDeepCloneable Clone(Cloner cloner) {
     111      return new ConstrainedValue(this, cloner);
    111112    }
    112113    #endregion
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/DoubleValueRange.cs

    r8517 r8535  
    3030  [StorableClass]
    3131  public class DoubleValueRange : Range<DoubleValue> {
    32 
    33     public override DoubleValue LowerBound {
    34       get {
    35         return base.LowerBound;
    36       }
    37       set {
    38         base.LowerBound = value;
    39       }
    40     }
    41 
    42     public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { }
     32    #region Constructors and Cloning
    4333    [StorableConstructor]
    4434    protected DoubleValueRange(bool deserializing) : base(deserializing) { }
    4535    protected DoubleValueRange(DoubleValueRange original, Cloner cloner) : base(original, cloner) { }
     36    public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { }
    4637    public override IDeepCloneable Clone(Cloner cloner) {
    4738      return new DoubleValueRange(this, cloner);
    4839    }
     40    #endregion
    4941
    5042    protected override DoubleValue GetRandomSample(IRandom random) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/IntValueRange.cs

    r8517 r8535  
    3030  [StorableClass]
    3131  public class IntValueRange : Range<IntValue> {
    32 
    33     public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { }
     32    #region Constructors and Cloning
    3433    [StorableConstructor]
    3534    protected IntValueRange(bool deserializing) : base(deserializing) { }
    3635    protected IntValueRange(IntValueRange original, Cloner cloner) : base(original, cloner) { }
     36    public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { }
    3737    public override IDeepCloneable Clone(Cloner cloner) {
    3838      return new IntValueRange(this, cloner);
    3939    }
     40    #endregion
    4041
    4142    protected override IntValue GetRandomSample(IRandom random) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/PercentValueRange.cs

    r8517 r8535  
    3030  [StorableClass]
    3131  public class PercentValueRange : Range<PercentValue> {
    32 
    33     public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { }
     32    #region Constructors and Cloning
    3433    [StorableConstructor]
    3534    protected PercentValueRange(bool deserializing) : base(deserializing) { }
    3635    protected PercentValueRange(PercentValueRange original, Cloner cloner) : base(original, cloner) { }
     36    public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { }
    3737    public override IDeepCloneable Clone(Cloner cloner) {
    3838      return new PercentValueRange(this, cloner);
    3939    }
     40    #endregion
    4041
    4142    protected override PercentValue GetRandomSample(IRandom random) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/Range.cs

    r8517 r8535  
    3838        if (lowerBound != value) {
    3939          if (lowerBound != null) {
     40            lowerBound.ValueChanged -= new EventHandler(lowerBound_ValueChanged);
    4041            lowerBound.ValueChanged -= new EventHandler(lowerBound_ToStringChanged);
    4142          }
    4243          lowerBound = value;
    4344          if (lowerBound != null) {
     45            lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged);
    4446            lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged);
    4547          }
     
    5658        if (upperBound != value) {
    5759          if (upperBound != null) {
     60            upperBound.ValueChanged -= new EventHandler(upperBound_ValueChanged);
    5861            upperBound.ValueChanged -= new EventHandler(upperBound_ToStringChanged);
    5962          }
    6063          upperBound = value;
    6164          if (upperBound != null) {
     65            upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged);
    6266            upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged);
    6367          }
     
    7478        if (stepSize != value) {
    7579          if (stepSize != null) {
     80            stepSize.ValueChanged -= new EventHandler(stepSize_ValueChanged);
    7681            stepSize.ValueChanged -= new EventHandler(stepSize_ToStringChanged);
    7782          }
    7883          stepSize = value;
    7984          if (stepSize != null) {
     85            stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged);
    8086            stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged);
    8187          }
     
    101107
    102108    #region Constructors and Cloning
    103     public Range(T lowerBound, T upperBound, T stepSize) {
    104       this.LowerBound = lowerBound;
    105       this.UpperBound = upperBound;
    106       this.StepSize = stepSize;
    107     }
    108 
    109109    [StorableConstructor]
    110110    protected Range(bool deserializing) : base(deserializing) { }
     
    115115      this.StepSize = cloner.Clone(original.StepSize);
    116116    }
    117 
     117    public Range(T lowerBound, T upperBound, T stepSize)
     118      : base() {
     119      this.LowerBound = lowerBound;
     120      this.UpperBound = upperBound;
     121      this.StepSize = stepSize;
     122    }
    118123    [StorableHook(HookType.AfterDeserialization)]
    119124    private void AfterDeserialization() {
    120125      if (lowerBound != null) {
     126        lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged);
    121127        lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged);
    122128      }
    123129      if (upperBound != null) {
     130        upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged);
    124131        upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged);
    125132      }
    126133      if (stepSize != null) {
     134        stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged);
    127135        stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged);
    128136      }
     
    131139
    132140    #region Events
     141    private void lowerBound_ValueChanged(object sender, EventArgs e) {
     142      OnLowerBoundChanged();
     143    }
     144    private void upperBound_ValueChanged(object sender, EventArgs e) {
     145      OnUpperBoundChanged();
     146    }
     147    private void stepSize_ValueChanged(object sender, EventArgs e) {
     148      OnStepSizeChanged();
     149    }
    133150    private void lowerBound_ToStringChanged(object sender, EventArgs e) {
    134151      OnToStringChanged();
     
    189206    }
    190207    public bool Validate(string value, out string errorMessage) {
    191       // TODO: check that upper is larger than lower and that stepsize < upper-lower
     208      // TODO: check that stepsize < upper - lower
    192209      T lower = (T)lowerBound.Clone();
    193210      T upper = (T)upperBound.Clone();
     
    206223          upperBound.SetValue(parts2[1]) &&
    207224          stepSize.SetValue(parts1[1])) {
     225        if (Comparer<T>.Default.Compare(lowerBound, upperBound) >= 0) {
     226          errorMessage = "Invalid bounds. (Lower >= Upper)"; return false;
     227        }
    208228        errorMessage = string.Empty; return true;
    209229      } else {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/SymbolicExpressionGrammar/SymbolValueConfiguration.cs

    r8517 r8535  
    4343    [StorableConstructor]
    4444    protected SymbolValueConfiguration(bool deserializing) : base(deserializing) { }
     45    protected SymbolValueConfiguration(SymbolValueConfiguration original, Cloner cloner)
     46      : base(original, cloner) {
     47      RegisterInitialFrequencyEvents();
     48      this.parentOptimizable = cloner.Clone(original.parentOptimizable);
     49    }
    4550    public SymbolValueConfiguration(Symbol symbol)
    4651      : base() {
     
    5055      this.ActualValue = new ConstrainedValue(symbol, symbol.GetType(), new ItemSet<IItem> { symbol }, false);
    5156    }
    52     protected SymbolValueConfiguration(SymbolValueConfiguration original, Cloner cloner)
    53       : base(original, cloner) {
     57    [StorableHook(HookType.AfterDeserialization)]
     58    private void AfterDeserialization() {
    5459      RegisterInitialFrequencyEvents();
    55       this.parentOptimizable = cloner.Clone(original.parentOptimizable);
    5660    }
    5761    public override IDeepCloneable Clone(Cloner cloner) {
    5862      return new SymbolValueConfiguration(this, cloner);
    59     }
    60     [StorableHook(HookType.AfterDeserialization)]
    61     private void AfterDeserialization() {
    62       RegisterInitialFrequencyEvents();
    6363    }
    6464    #endregion
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/SymbolicExpressionGrammar/SymbolicExpressionGrammarValueConfiguration.cs

    r8517 r8535  
    2929  [StorableClass]
    3030  public class SymbolicExpressionGrammarValueConfiguration : ParameterizedValueConfiguration {
    31 
    3231    #region Constructors and Cloning
    3332    [StorableConstructor]
    3433    protected SymbolicExpressionGrammarValueConfiguration(bool deserializing) : base(deserializing) { }
     34    protected SymbolicExpressionGrammarValueConfiguration(SymbolicExpressionGrammarValueConfiguration original, Cloner cloner) : base(original, cloner) { }
    3535    public SymbolicExpressionGrammarValueConfiguration() : base() { }
    36     public SymbolicExpressionGrammarValueConfiguration(ISymbolicExpressionGrammar grammar) {
     36    public SymbolicExpressionGrammarValueConfiguration(ISymbolicExpressionGrammar grammar)
     37      : base() {
    3738      this.IsOptimizable = true;
    3839      this.ActualValue = new ConstrainedValue(grammar, grammar.GetType(), new ItemSet<IItem> { grammar }, false);
    39     }
    40     protected SymbolicExpressionGrammarValueConfiguration(SymbolicExpressionGrammarValueConfiguration original, Cloner cloner)
    41       : base(original, cloner) {
    4240    }
    4341    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/TypeValue.cs

    r8517 r8535  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Drawing;
    324using HeuristicLab.Common;
     
    3253    }
    3354
     55    #region Constructors and Cloning
     56    [StorableConstructor]
     57    protected TypeValue(bool deserializing) : base(deserializing) { }
     58    protected TypeValue(TypeValue original, Cloner cloner)
     59      : base(original, cloner) {
     60      this.value = original.value;
     61      this.readOnly = original.readOnly;
     62    }
    3463    public TypeValue()
    3564      : base() {
     
    4170      this.readOnly = false;
    4271    }
    43     [StorableConstructor]
    44     protected TypeValue(bool deserializing) : base(deserializing) { }
    45     protected TypeValue(TypeValue original, Cloner cloner)
    46       : base(original, cloner) {
    47       this.value = original.value;
    48       this.readOnly = original.readOnly;
    49     }
    5072    public override IDeepCloneable Clone(Cloner cloner) {
    5173      return new TypeValue(this, cloner);
    5274    }
     75    #endregion
    5376
    5477    public virtual TypeValue AsReadOnly() {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/CheckedValueConfigurationCollection.cs

    r8517 r8535  
    2828
    2929namespace HeuristicLab.Encodings.ParameterConfigurationEncoding {
    30   // todo: check that at least 1 elements needs to be selected
    31   // todo: control creatable item types
     30  // TODO: check that at least 1 element needs to be selected
     31  // TODO: control creatable item types
    3232  [StorableClass]
    3333  public class CheckedValueConfigurationList : CheckedItemList<IValueConfiguration>, ICheckedValueConfigurationList {
     
    4444    }
    4545
    46     public CheckedValueConfigurationList(IItemSet<IItem> validValues) {
    47       this.validValues = validValues;
    48       RegisterEvents();
    49     }
    50     public CheckedValueConfigurationList(IEnumerable<IValueConfiguration> collection)
    51       : base(collection) {
    52       validValues = null;
    53       // event wiring not needed
    54     }
    55     public CheckedValueConfigurationList() {
    56       RegisterEvents();
    57     }
     46    #region Constructors and Cloning
    5847    [StorableConstructor]
    5948    protected CheckedValueConfigurationList(bool deserializing)
     
    6756      RegisterEvents();
    6857    }
    69 
     58    public CheckedValueConfigurationList(IItemSet<IItem> validValues)
     59      : base() {
     60      this.validValues = validValues;
     61      RegisterEvents();
     62    }
     63    public CheckedValueConfigurationList(IEnumerable<IValueConfiguration> collection)
     64      : base(collection) {
     65      validValues = null;
     66      // event wiring not needed
     67    }
     68    public CheckedValueConfigurationList()
     69      : base() {
     70      RegisterEvents();
     71    }
    7072    public override IDeepCloneable Clone(Cloner cloner) {
    7173      return new CheckedValueConfigurationList(this, cloner);
     
    7577      RegisterEvents();
    7678    }
     79    #endregion
    7780
    7881    private void RegisterEvents() {
    7982      this.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded);
    80       this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
    8183    }
    8284
    8385    private void DeregisterEvents() {
    84       this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);
    8586      this.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded);
    8687    }
     
    9596      }
    9697    }
    97 
    98     private void CheckedValueConfigurationList_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {
    99       // auch collectionreset gehört berücksichtigt
    100       // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt
    101       //if (this.Count < minItemCount) {
    102       //  foreach (var item in e.Items) {
    103       //    if (this.Count >= minItemCount)
    104       //      break;
    105       //    this.Add(item);
    106       //  }
    107       //}
    108     }
    109 
    11098  }
    11199}
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/NullValueConfiguration.cs

    r8517 r8535  
    2828  [StorableClass]
    2929  public class NullValueConfiguration : ValueConfiguration {
    30 
    31     public NullValueConfiguration() {
    32       this.ActualValue = new ConstrainedValue(null, null, null, true);
    33       this.IsOptimizable = false;
    34     }
     30    #region Constructors and Cloning
    3531    [StorableConstructor]
    3632    protected NullValueConfiguration(bool deserializing) : base(deserializing) { }
     
    3834      : base(original, cloner) {
    3935    }
     36    public NullValueConfiguration()
     37      : base() {
     38      this.ActualValue = new ConstrainedValue(null, null, null, true);
     39      this.IsOptimizable = false;
     40    }
    4041    public override IDeepCloneable Clone(Cloner cloner) {
    4142      return new NullValueConfiguration(this, cloner);
    4243    }
     44    #endregion
    4345
    4446    public override string ToString() {
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ParameterizedValueConfiguration.cs

    r8517 r8535  
    8383    [StorableConstructor]
    8484    protected ParameterizedValueConfiguration(bool deserializing) : base(deserializing) { }
    85     public ParameterizedValueConfiguration() {
     85    protected ParameterizedValueConfiguration(ParameterizedValueConfiguration original, Cloner cloner)
     86      : base(original, cloner) {
     87      this.discoverValidValues = original.discoverValidValues;
     88      this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);
     89    }
     90    public ParameterizedValueConfiguration()
     91      : base() {
    8692      this.ParameterConfigurations = new ItemList<IParameterConfiguration>();
    8793    }
     
    8995      : base(value, valueDataType) {
    9096      this.discoverValidValues = discoverValidValues;
    91     }
    92     protected ParameterizedValueConfiguration(ParameterizedValueConfiguration original, Cloner cloner)
    93       : base(original, cloner) {
    94       this.discoverValidValues = original.discoverValidValues;
    95       this.ParameterConfigurations = cloner.Clone(original.parameterConfigurations);
    9697    }
    9798    public override IDeepCloneable Clone(Cloner cloner) {
     
    107108          if (valueParameter != null) {
    108109            var pc = new ParameterConfiguration(valueParameter.Name, valueParameter, discoverValidValues);
     110            pc.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged();
    109111            this.parameterConfigurations.Add(pc);
    110112          }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/RangeValueConfiguration.cs

    r8517 r8535  
    4646    [StorableConstructor]
    4747    protected RangeValueConfiguration(bool deserializing) : base(deserializing) { }
    48     public RangeValueConfiguration() {
    49 
    50     }
    5148    protected RangeValueConfiguration(RangeValueConfiguration original, Cloner cloner)
    5249      : base(original, cloner) {
     
    5451      RegisterRangeConstraintEvents();
    5552    }
     53    public RangeValueConfiguration() : base() { }
    5654    public RangeValueConfiguration(IItem value, Type valueDataType)
    5755      : base(value, valueDataType) {
     
    6866      }
    6967    }
    70     public override IDeepCloneable Clone(Cloner cloner) {
    71       return new RangeValueConfiguration(this, cloner);
    72     }
    7368    [StorableHook(HookType.AfterDeserialization)]
    7469    private void AfterDeserialization() {
    7570      RegisterRangeConstraintEvents();
    7671    }
     72    public override IDeepCloneable Clone(Cloner cloner) {
     73      return new RangeValueConfiguration(this, cloner);
     74    }
    7775    #endregion
    7876
    7977    private void RegisterRangeConstraintEvents() {
    80       if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged);
     78      if (this.RangeConstraint != null) {
     79        this.RangeConstraint.ToStringChanged += new EventHandler(RangeConstraint_ToStringChanged);
     80        this.RangeConstraint.LowerBoundChanged += new EventHandler(RangeConstraintParametersChanged);
     81        this.RangeConstraint.UpperBoundChanged += new EventHandler(RangeConstraintParametersChanged);
     82        this.RangeConstraint.StepSizeChanged += new EventHandler(RangeConstraintParametersChanged);
     83      }
    8184    }
     85
    8286    private void DeregisterRangeConstraintEvents() {
    83       if (this.RangeConstraint != null) this.RangeConstraint.ToStringChanged -= new EventHandler(RangeConstraint_ToStringChanged);
     87      if (this.RangeConstraint != null) {
     88        this.RangeConstraint.ToStringChanged -= new EventHandler(RangeConstraint_ToStringChanged);
     89        this.RangeConstraint.LowerBoundChanged -= new EventHandler(RangeConstraintParametersChanged);
     90        this.RangeConstraint.UpperBoundChanged -= new EventHandler(RangeConstraintParametersChanged);
     91        this.RangeConstraint.StepSizeChanged -= new EventHandler(RangeConstraintParametersChanged);
     92      }
    8493    }
    8594
     
    119128      OnToStringChanged();
    120129    }
     130    private void RangeConstraintParametersChanged(object sender, EventArgs e) {
     131      OnCombinationsCountChanged();
     132    }
    121133    #endregion
    122134  }
  • branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ValueConfiguration.cs

    r8524 r8535  
    6161          optimize = value;
    6262          OnOptimizeChanged();
     63          OnCombinationsCountChanged();
    6364          OnToStringChanged();
    6465        }
     
    117118    }
    118119    protected ValueConfiguration() : base() { }
    119     protected ValueConfiguration(IItem value, Type valueDataType) {
     120    protected ValueConfiguration(IItem value, Type valueDataType)
     121      : base() {
    120122      this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false);
    121123      this.IsOptimizable = true;
     
    168170      if (handler != null) handler(this, EventArgs.Empty);
    169171    }
     172
     173    public event EventHandler CombinationsCountChanged;
     174    protected void OnCombinationsCountChanged() {
     175      var handler = CombinationsCountChanged;
     176      if (handler != null) handler(this, EventArgs.Empty);
     177    }
    170178    #endregion
    171179
Note: See TracChangeset for help on using the changeset viewer.