Changeset 8535 for branches/ParameterConfigurationEncoding
- Timestamp:
- 08/29/12 09:22:21 (13 years ago)
- Location:
- branches/ParameterConfigurationEncoding
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.Designer.cs ¶
r8524 r8535 57 57 this.okButton = new System.Windows.Forms.Button(); 58 58 this.cancelButton = new System.Windows.Forms.Button(); 59 this.calculateCombinationsButton = new System.Windows.Forms.Button();60 59 this.combinationsLabel = new System.Windows.Forms.Label(); 61 this.combinationsTextBox = new System.Windows.Forms.TextBox();62 60 this.configurationTabControl = new System.Windows.Forms.TabControl(); 63 61 this.parameterConfigurationTabPage = new System.Windows.Forms.TabPage(); 62 this.parameterConfigurationTreeView = new HeuristicLab.Encodings.ParameterConfigurationEncoding.Views.ParameterConfigurationTreeView(); 64 63 this.problemInstancesTabPage = new System.Windows.Forms.TabPage(); 65 64 this.instanceTreeView = new System.Windows.Forms.TreeView(); … … 67 66 this.libraryComboBox = new System.Windows.Forms.ComboBox(); 68 67 this.instanceDiscoveryBackgroundWorker = new System.ComponentModel.BackgroundWorker(); 69 this. parameterConfigurationTreeView = new HeuristicLab.Encodings.ParameterConfigurationEncoding.Views.ParameterConfigurationTreeView();68 this.combinationsCountLabel = new System.Windows.Forms.Label(); 70 69 ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit(); 71 70 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 188 187 this.cancelButton.UseVisualStyleBackColor = true; 189 188 // 190 // calculateCombinationsButton191 //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 //201 189 // combinationsLabel 202 190 // 203 191 this.combinationsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 204 192 this.combinationsLabel.AutoSize = true; 205 this.combinationsLabel.Location = new System.Drawing.Point(1 66, 562);193 this.combinationsLabel.Location = new System.Drawing.Point(12, 562); 206 194 this.combinationsLabel.Name = "combinationsLabel"; 207 195 this.combinationsLabel.Size = new System.Drawing.Size(73, 13); 208 196 this.combinationsLabel.TabIndex = 10; 209 197 this.combinationsLabel.Text = "Combinations:"; 210 //211 // combinationsTextBox212 //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;220 198 // 221 199 // configurationTabControl … … 243 221 this.parameterConfigurationTabPage.Text = "Parameter Configuration"; 244 222 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; 245 236 // 246 237 // problemInstancesTabPage … … 295 286 this.instanceDiscoveryBackgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.instanceDiscoveryBackgroundWorker_RunWorkerCompleted); 296 287 // 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"; 309 297 // 310 298 // CreateExperimentDialogV2 311 299 // 300 this.AcceptButton = this.okButton; 312 301 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 302 this.CancelButton = this.cancelButton; 313 303 this.ClientSize = new System.Drawing.Size(984, 592); 304 this.Controls.Add(this.combinationsCountLabel); 314 305 this.Controls.Add(this.configurationTabControl); 315 this.Controls.Add(this.combinationsTextBox);316 306 this.Controls.Add(this.combinationsLabel); 317 this.Controls.Add(this.calculateCombinationsButton);318 307 this.Controls.Add(this.cancelButton); 319 308 this.Controls.Add(this.okButton); … … 359 348 private System.Windows.Forms.ErrorProvider warningProvider; 360 349 private ParameterConfigurationTreeView parameterConfigurationTreeView; 361 private System.Windows.Forms.TextBox combinationsTextBox;362 350 private System.Windows.Forms.Label combinationsLabel; 363 private System.Windows.Forms.Button calculateCombinationsButton;364 351 private System.Windows.Forms.TabControl configurationTabControl; 365 352 private System.Windows.Forms.TabPage parameterConfigurationTabPage; … … 369 356 private System.Windows.Forms.ComboBox libraryComboBox; 370 357 private System.ComponentModel.BackgroundWorker instanceDiscoveryBackgroundWorker; 358 private System.Windows.Forms.Label combinationsCountLabel; 371 359 } 372 360 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/CreateExperimentDialogV2.cs ¶
r8524 r8535 36 36 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views { 37 37 public partial class CreateExperimentDialogV2 : Form { 38 private readonly IAlgorithm algorithm; 38 39 private readonly Progress progress; 39 private readonly IAlgorithm algorithm;40 40 private ParameterConfigurationTree parameterConfigurationTree; 41 41 private bool createBatchRun; 42 42 private int repetitions; 43 43 private IEngine engine; 44 private Task generation;44 private Task experimentGenerator; 45 45 private CancellationTokenSource cts; 46 46 private Dictionary<IProblemInstanceProvider, HashSet<IDataDescriptor>> problemInstanceProviders; … … 93 93 parameterConfigurationTreeView.Content = parameterConfigurationTree = new ParameterConfigurationTree(algorithm, algorithm.Problem); 94 94 parameterConfigurationTree.ExperimentGenerationProgressChanged += (o, args) => progress.ProgressValue = parameterConfigurationTree.ExperimentGenerationProgress; 95 parameterConfigurationTree.CombinationsCountChanged += (o, args) => UpdateCombinationsCount(); 95 96 new ProgressView(parameterConfigurationTreeView, progress) { CancelTimeoutMs = 10000 }; 96 97 } else { … … 101 102 102 103 private void CreateExperimentDialogV2_FormClosing(object sender, FormClosingEventArgs e) { 103 if ( generation!= null) e.Cancel = true;104 if (experimentGenerator != null) e.Cancel = true; 104 105 } 105 106 … … 160 161 } 161 162 } 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 } 169 165 } 170 166 171 167 private void okButton_Click(object sender, System.EventArgs e) { 172 168 configurationTabControl.SelectedTab = parameterConfigurationTabPage; 173 generation= Task.Factory.StartNew(() => {169 experimentGenerator = Task.Factory.StartNew(() => { 174 170 StartProgressView(); 175 171 var engineAlgorithm = algorithm as EngineAlgorithm; … … 181 177 finally { FinishProgressView(); } 182 178 }, cts.Token); 183 generation.ContinueWith(t => {184 generation= null;179 experimentGenerator.ContinueWith(t => { 180 experimentGenerator = null; 185 181 CloseDialog(); 186 182 }, TaskContinuationOptions.OnlyOnRanToCompletion); 187 generation.ContinueWith(t => {188 generation= null;183 experimentGenerator.ContinueWith(t => { 184 experimentGenerator = null; 189 185 if (t.IsCanceled) cts = new CancellationTokenSource(); 190 186 if (t.IsFaulted) { … … 201 197 repetitionsNumericUpDown.Enabled = state; 202 198 engineComboBox.Enabled = state; 203 calculateCombinationsButton.Enabled = state;204 199 okButton.Enabled = state; 205 200 cancelButton.Enabled = state; … … 222 217 } 223 218 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 224 225 private void StartProgressView() { 225 226 if (InvokeRequired) { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/MenuItems/CreateExperimentMenuItemV2.cs ¶
r8517 r8535 21 21 22 22 using System; 23 #region License Information24 /* HeuristicLab25 * 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 modify30 * it under the terms of the GNU General Public License as published by31 * the Free Software Foundation, either version 3 of the License, or32 * (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 of36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the37 * GNU General Public License for more details.38 *39 * You should have received a copy of the GNU General Public License40 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.41 */42 #endregion43 44 23 using System.Collections.Generic; 45 24 using System.Windows.Forms; -
TabularUnified 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 22 using HeuristicLab.Common; 2 23 using HeuristicLab.Core; 3 24 … … 11 32 private bool initialized = false; 12 33 13 public MessageItem() { 34 public MessageItem() 35 : base() { 14 36 this.Name = "MessageItem"; 15 37 } 16 38 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.") { 20 40 this.initialized = true; 21 41 } … … 25 45 26 46 public override IDeepCloneable Clone(Cloner cloner) { 27 return new MessageItem( );47 return new MessageItem(this, cloner); 28 48 } 29 49 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding.Views/3.3/ObjectSelectorDialog.Designer.cs ¶
r8524 r8535 122 122 this.Controls.Add(this.okButton); 123 123 this.Controls.Add(this.itemsListView); 124 this.MaximizeBox = false; 125 this.MinimizeBox = false; 124 126 this.Name = "ObjectSelectorDialog"; 127 this.ShowIcon = false; 128 this.ShowInTaskbar = false; 129 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 125 130 this.Text = "ObjectSelectorDialog"; 126 131 this.Load += new System.EventHandler(this.ObjectSelectorDialog_Load); -
TabularUnified 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 24 45 } 25 46 47 #region Events 26 48 private void ObjectSelectorDialog_Load(object sender, EventArgs e) { 27 49 if (!initialized) { … … 76 98 okButton.Enabled = itemsListView.SelectedItems.Count == 1; 77 99 } 78 79 100 #endregion 80 101 } 81 102 } -
TabularUnified 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 22 using System; 2 23 using System.Linq; 3 24 using HeuristicLab.Core.Views; … … 68 89 this.viewHost.Content = pvc.ParameterConfigurations; 69 90 } 70 71 //var symbolicVc = Content as SymbolicExpressionGrammarValueConfiguration;72 //if (symbolicVc != null) {73 // this.viewHost.ViewsLabelVisible = false;74 // this.viewHost.Content = symbolicVc.ParameterConfigurations;75 //}76 91 } else { 77 92 throw new NotSupportedException("Only IParameterConfiguration and IValueConfiguration types are allowed."); -
TabularUnified 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 2 22 using HeuristicLab.Core.Views; 3 23 using HeuristicLab.MainForm; … … 33 53 SetEnabledStateOfControls(); 34 54 } 35 36 protected override void SetEnabledStateOfControls() {37 base.SetEnabledStateOfControls();38 }39 55 } 40 56 } -
TabularUnified 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 2 22 using HeuristicLab.Core.Views; 3 23 using HeuristicLab.Data; … … 23 43 } 24 44 25 protected override void RegisterContentEvents() {26 base.RegisterContentEvents();27 }28 29 protected override void DeregisterContentEvents() {30 base.DeregisterContentEvents();31 }32 33 45 protected override void OnContentChanged() { 34 46 base.OnContentChanged(); … … 43 55 } 44 56 } 45 46 protected override void SetEnabledStateOfControls() {47 base.SetEnabledStateOfControls();48 }49 57 } 50 58 } -
TabularUnified 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 22 using System; 2 23 using System.Linq; 3 24 using System.Windows.Forms; … … 8 29 9 30 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding.Views { 31 /// <summary> 32 /// The visual representation of a <see cref="ConstrainedValue"/>. 33 /// </summary> 10 34 [View("Value View")] 11 35 [Content(typeof(ConstrainedValue), true)] 12 36 public partial class ValueView : ItemView { 13 37 /// <summary> 38 /// Gets or sets the variable to represent visually. 39 /// </summary> 14 40 public new ConstrainedValue Content { 15 41 get { return (ConstrainedValue)base.Content; } … … 34 60 base.SetEnabledStateOfControls(); 35 61 if (Content != null) { 36 clearValueButton.Enabled = Content.Value != null && Content.IsNullable; // IsNullable ist in diesem fall nicht richtig gesetzt62 clearValueButton.Enabled = Content.Value != null && Content.IsNullable; // in this case IsNullable is not set correctly 37 63 setValueButton.Enabled = Content.ValueDataType != null; 38 64 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/AlgorithmProblemItem.cs ¶
r8517 r8535 41 41 [StorableConstructor] 42 42 protected AlgorithmProblemItem(bool deserializing) : base(deserializing) { } 43 public AlgorithmProblemItem() { 43 protected AlgorithmProblemItem(AlgorithmProblemItem original, Cloner cloner) : base(original, cloner) { } 44 public AlgorithmProblemItem() 45 : base() { 44 46 this.Parameters.Add(new ValueParameter<IAlgorithm>("Algorithm")); 45 47 this.Parameters.Add(new ValueParameter<IProblem>("Problem")); 46 }47 protected AlgorithmProblemItem(AlgorithmProblemItem original, Cloner cloner)48 : base(original, cloner) {49 48 } 50 49 public override IDeepCloneable Clone(Cloner cloner) { -
TabularUnified 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 22 using System; 2 23 using HeuristicLab.Common; 3 24 using HeuristicLab.Core; … … 19 40 } 20 41 21 public ConstrainedItemList() { 22 Type = typeof(T); 23 } 42 #region Constructors and Cloning 24 43 [StorableConstructor] 25 44 protected ConstrainedItemList(bool deserializing) : base(deserializing) { } … … 28 47 this.Type = original.Type; 29 48 } 49 public ConstrainedItemList() 50 : base() { 51 Type = typeof(T); 52 } 30 53 public override IDeepCloneable Clone(Cloner cloner) { 31 54 return new ConstrainedItemList<T>(this, cloner); 32 55 } 56 #endregion 33 57 } 34 58 } -
TabularUnified 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 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 11 32 [StorableClass] 12 33 public class ConstrainedTypeValue : TypeValue { 13 14 34 private IEnumerable<Type> validTypes; 15 35 public IEnumerable<Type> ValidTypes { … … 25 45 } 26 46 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 } 27 55 public ConstrainedTypeValue() 28 56 : base() { … … 33 61 this.Value = value; 34 62 } 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 }43 63 public override IDeepCloneable Clone(Cloner cloner) { 44 64 return new ConstrainedTypeValue(this, cloner); 45 65 } 66 #endregion 46 67 } 47 68 … … 49 70 [StorableClass] 50 71 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) { } 52 80 public ConstrainedTypeValue() 53 81 : base() { … … 60 88 this.Value = value; 61 89 } 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) { }72 90 public override IDeepCloneable Clone(Cloner cloner) { 73 91 return new ConstrainedTypeValue<T>(this, cloner); -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Interfaces/IOptimizable.cs ¶
r8517 r8535 42 42 event EventHandler IsOptimizableChanged; 43 43 event EventHandler OptimizeChanged; 44 event EventHandler CombinationsCountChanged; 44 45 45 46 /// <summary> -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/Interfaces/IValueConfiguration.cs ¶
r8517 r8535 28 28 29 29 event EventHandler ValueChanged; 30 31 //void Parameterize(IParameterizedItem item);32 30 } 33 31 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/NullValue.cs ¶
r8517 r8535 27 27 [StorableClass] 28 28 public class NullValue : ValueTypeValue<int> { 29 30 public NullValue() { }31 29 [StorableConstructor] 32 30 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() { } 36 33 public override IDeepCloneable Clone(Cloner cloner) { 37 34 return new NullValue(this, cloner); -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurationTree.cs ¶
r8524 r8535 37 37 [StorableClass] 38 38 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 39 51 [Storable] 40 52 private DoubleValue quality; … … 213 225 this.Name = algorithm.ItemName; 214 226 215 var alg problemitem = new AlgorithmProblemItem();216 alg problemitem.AlgorithmParameter.Value = algorithm;217 alg problemitem.ProblemParameter.Value = problem;227 var algProblemItem = new AlgorithmProblemItem(); 228 algProblemItem.AlgorithmParameter.Value = algorithm; 229 algProblemItem.ProblemParameter.Value = problem; 218 230 this.discoverValidValues = false; 219 231 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); 222 240 223 241 // problems can be modified in the list of problem instances, so the parameters which are not Optimize=true, 224 242 // must not be modifiable in the parameter configuration tree. otherwise the parameter values would be ambiguous 225 243 ProblemConfiguration.ValuesReadOnly = true; 244 245 CombinationsCount = GetCombinationCount(0); 226 246 } 227 247 … … 233 253 private void AfterDeserialization() { 234 254 if (ProblemConfiguration != null) ProblemConfiguration.ValuesReadOnly = true; 255 CombinationsCount = GetCombinationCount(0); 235 256 } 236 257 #endregion … … 265 286 private void Quality_ValueChanged(object sender, EventArgs e) { 266 287 OnQualityChanged(); 288 } 289 290 private void UpdateConfigurationsCount(object sender, EventArgs e) { 291 CombinationsCount = GetCombinationCount(0); 267 292 } 268 293 -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/ParameterConfiguration.cs ¶
r8517 r8535 57 57 } 58 58 OnOptimizeChanged(); 59 OnCombinationsCountChanged(); 59 60 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(); 60 73 } 61 74 } … … 179 192 180 193 #region Constructors and Cloning 181 public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues) { 194 public ParameterConfiguration(string parameterName, IValueParameter valueParameter, bool discoverValidValues) 195 : base() { 182 196 this.AutoPopulateValueConfigurations = true; 183 197 this.ParameterName = parameterName; … … 202 216 } 203 217 } 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() { 205 220 this.AutoPopulateValueConfigurations = false; 206 221 this.ParameterName = parameterName; … … 211 226 this.validTypes = new Type[] { type }; 212 227 this.IsNullable = false; 213 this.itemImage = valueConfigurations. Count() > 0 ? valueConfigurations.FirstOrDefault().ItemImage : null;228 this.itemImage = valueConfigurations.Any() ? valueConfigurations.First().ItemImage : null; 214 229 this.ValueConfigurations = new CheckedValueConfigurationList(valueConfigurations); 215 230 this.ActualValue = new ConstrainedValue(actualValue, type, CreateValidValues(), this.IsNullable); 216 231 } 217 public ParameterConfiguration(string parameterName, Type type, IItem actualValue) { 232 public ParameterConfiguration(string parameterName, Type type, IItem actualValue) 233 : base() { 218 234 this.AutoPopulateValueConfigurations = true; 219 235 this.ParameterName = parameterName; … … 231 247 } 232 248 } 233 protected ParameterConfiguration() { }249 protected ParameterConfiguration() : base() { } 234 250 [StorableConstructor] 235 251 protected ParameterConfiguration(bool deserializing) { } 236 237 252 protected ParameterConfiguration(ParameterConfiguration original, Cloner cloner) 238 253 : base(original, cloner) { … … 316 331 } 317 332 } 333 valueConfiguration.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged(); 318 334 this.ValueConfigurations.Add(valueConfiguration, true); 319 335 } … … 357 373 return new List<Type> { parameter }; 358 374 359 // TODO: not sure if this ifmakes sense; maybe only leave else branch here375 // TODO: check if this makes sense; maybe only leave else branch here 360 376 if (IsSubclassOfRawGeneric(typeof(OptionalConstrainedValueParameter<>), parameter.GetType())) { 361 377 // use existing validvalues if known … … 391 407 392 408 // 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); 394 410 if (value != null) 395 411 return value; … … 425 441 private void ValueConfigurations_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 426 442 OnToStringChanged(); 443 OnCombinationsCountChanged(); 427 444 KeepActualValueConfigurationIndexConsistent(); 428 445 } … … 430 447 private void ValueConfigurations_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 431 448 OnToStringChanged(); 449 OnCombinationsCountChanged(); 432 450 KeepActualValueConfigurationIndexConsistent(); 433 451 } 434 452 private void ValueConfigurations_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 435 453 OnToStringChanged(); 454 OnCombinationsCountChanged(); 436 455 KeepActualValueConfigurationIndexConsistent(); 437 456 } … … 451 470 public virtual bool CanChangeName { 452 471 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; }459 472 } 460 473 #endregion … … 494 507 protected virtual void OnOptimizeChanged() { 495 508 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; 496 515 if (handler != null) handler(this, EventArgs.Empty); 497 516 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ParameterConfigurations/SingleValuedParameterConfiguration.cs ¶
r8517 r8535 29 29 [StorableClass] 30 30 public class SingleValuedParameterConfiguration : ParameterConfiguration { 31 32 31 #region Constructors and Cloning 33 32 [StorableConstructor] 34 33 protected SingleValuedParameterConfiguration(bool deserializing) : base(deserializing) { } 34 protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner) : base(original, cloner) { } 35 35 public SingleValuedParameterConfiguration(string parameterName, IValueParameter valueParameter) 36 36 : base(parameterName, valueParameter, false) { … … 57 57 this.validValues, 58 58 this.IsNullable); 59 }60 protected SingleValuedParameterConfiguration(SingleValuedParameterConfiguration original, Cloner cloner)61 : base(original, cloner) {62 59 } 63 60 public override IDeepCloneable Clone(Cloner cloner) { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/ConstrainedValue.cs ¶
r8517 r8535 86 86 } 87 87 88 #region constructors and cloning 89 public ConstrainedValue() { } 88 #region Constructors and Cloning 90 89 [StorableConstructor] 91 90 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 }98 91 protected ConstrainedValue(ConstrainedValue original, Cloner cloner) 99 92 : base(original, cloner) { … … 103 96 this.isNullable = original.isNullable; 104 97 } 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; 107 105 } 108 106 [StorableHook(HookType.AfterDeserialization)] 109 107 private void AfterDeserialization() { 110 108 if (this.value != null) RegisterEvents(); 109 } 110 public override IDeepCloneable Clone(Cloner cloner) { 111 return new ConstrainedValue(this, cloner); 111 112 } 112 113 #endregion -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/DoubleValueRange.cs ¶
r8517 r8535 30 30 [StorableClass] 31 31 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 43 33 [StorableConstructor] 44 34 protected DoubleValueRange(bool deserializing) : base(deserializing) { } 45 35 protected DoubleValueRange(DoubleValueRange original, Cloner cloner) : base(original, cloner) { } 36 public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { } 46 37 public override IDeepCloneable Clone(Cloner cloner) { 47 38 return new DoubleValueRange(this, cloner); 48 39 } 40 #endregion 49 41 50 42 protected override DoubleValue GetRandomSample(IRandom random) { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/IntValueRange.cs ¶
r8517 r8535 30 30 [StorableClass] 31 31 public class IntValueRange : Range<IntValue> { 32 33 public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { } 32 #region Constructors and Cloning 34 33 [StorableConstructor] 35 34 protected IntValueRange(bool deserializing) : base(deserializing) { } 36 35 protected IntValueRange(IntValueRange original, Cloner cloner) : base(original, cloner) { } 36 public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { } 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 38 return new IntValueRange(this, cloner); 39 39 } 40 #endregion 40 41 41 42 protected override IntValue GetRandomSample(IRandom random) { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/PercentValueRange.cs ¶
r8517 r8535 30 30 [StorableClass] 31 31 public class PercentValueRange : Range<PercentValue> { 32 33 public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { } 32 #region Constructors and Cloning 34 33 [StorableConstructor] 35 34 protected PercentValueRange(bool deserializing) : base(deserializing) { } 36 35 protected PercentValueRange(PercentValueRange original, Cloner cloner) : base(original, cloner) { } 36 public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { } 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 38 return new PercentValueRange(this, cloner); 39 39 } 40 #endregion 40 41 41 42 protected override PercentValue GetRandomSample(IRandom random) { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/Range.cs ¶
r8517 r8535 38 38 if (lowerBound != value) { 39 39 if (lowerBound != null) { 40 lowerBound.ValueChanged -= new EventHandler(lowerBound_ValueChanged); 40 41 lowerBound.ValueChanged -= new EventHandler(lowerBound_ToStringChanged); 41 42 } 42 43 lowerBound = value; 43 44 if (lowerBound != null) { 45 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 44 46 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 45 47 } … … 56 58 if (upperBound != value) { 57 59 if (upperBound != null) { 60 upperBound.ValueChanged -= new EventHandler(upperBound_ValueChanged); 58 61 upperBound.ValueChanged -= new EventHandler(upperBound_ToStringChanged); 59 62 } 60 63 upperBound = value; 61 64 if (upperBound != null) { 65 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 62 66 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 63 67 } … … 74 78 if (stepSize != value) { 75 79 if (stepSize != null) { 80 stepSize.ValueChanged -= new EventHandler(stepSize_ValueChanged); 76 81 stepSize.ValueChanged -= new EventHandler(stepSize_ToStringChanged); 77 82 } 78 83 stepSize = value; 79 84 if (stepSize != null) { 85 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 80 86 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 81 87 } … … 101 107 102 108 #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 109 109 [StorableConstructor] 110 110 protected Range(bool deserializing) : base(deserializing) { } … … 115 115 this.StepSize = cloner.Clone(original.StepSize); 116 116 } 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 } 118 123 [StorableHook(HookType.AfterDeserialization)] 119 124 private void AfterDeserialization() { 120 125 if (lowerBound != null) { 126 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 121 127 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 122 128 } 123 129 if (upperBound != null) { 130 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 124 131 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 125 132 } 126 133 if (stepSize != null) { 134 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 127 135 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 128 136 } … … 131 139 132 140 #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 } 133 150 private void lowerBound_ToStringChanged(object sender, EventArgs e) { 134 151 OnToStringChanged(); … … 189 206 } 190 207 public bool Validate(string value, out string errorMessage) { 191 // TODO: check that upper is larger than lower and that stepsize < upper-lower208 // TODO: check that stepsize < upper - lower 192 209 T lower = (T)lowerBound.Clone(); 193 210 T upper = (T)upperBound.Clone(); … … 206 223 upperBound.SetValue(parts2[1]) && 207 224 stepSize.SetValue(parts1[1])) { 225 if (Comparer<T>.Default.Compare(lowerBound, upperBound) >= 0) { 226 errorMessage = "Invalid bounds. (Lower >= Upper)"; return false; 227 } 208 228 errorMessage = string.Empty; return true; 209 229 } else { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/SymbolicExpressionGrammar/SymbolValueConfiguration.cs ¶
r8517 r8535 43 43 [StorableConstructor] 44 44 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 } 45 50 public SymbolValueConfiguration(Symbol symbol) 46 51 : base() { … … 50 55 this.ActualValue = new ConstrainedValue(symbol, symbol.GetType(), new ItemSet<IItem> { symbol }, false); 51 56 } 52 protected SymbolValueConfiguration(SymbolValueConfiguration original, Cloner cloner)53 : base(original, cloner) {57 [StorableHook(HookType.AfterDeserialization)] 58 private void AfterDeserialization() { 54 59 RegisterInitialFrequencyEvents(); 55 this.parentOptimizable = cloner.Clone(original.parentOptimizable);56 60 } 57 61 public override IDeepCloneable Clone(Cloner cloner) { 58 62 return new SymbolValueConfiguration(this, cloner); 59 }60 [StorableHook(HookType.AfterDeserialization)]61 private void AfterDeserialization() {62 RegisterInitialFrequencyEvents();63 63 } 64 64 #endregion -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/SymbolicExpressionGrammar/SymbolicExpressionGrammarValueConfiguration.cs ¶
r8517 r8535 29 29 [StorableClass] 30 30 public class SymbolicExpressionGrammarValueConfiguration : ParameterizedValueConfiguration { 31 32 31 #region Constructors and Cloning 33 32 [StorableConstructor] 34 33 protected SymbolicExpressionGrammarValueConfiguration(bool deserializing) : base(deserializing) { } 34 protected SymbolicExpressionGrammarValueConfiguration(SymbolicExpressionGrammarValueConfiguration original, Cloner cloner) : base(original, cloner) { } 35 35 public SymbolicExpressionGrammarValueConfiguration() : base() { } 36 public SymbolicExpressionGrammarValueConfiguration(ISymbolicExpressionGrammar grammar) { 36 public SymbolicExpressionGrammarValueConfiguration(ISymbolicExpressionGrammar grammar) 37 : base() { 37 38 this.IsOptimizable = true; 38 39 this.ActualValue = new ConstrainedValue(grammar, grammar.GetType(), new ItemSet<IItem> { grammar }, false); 39 }40 protected SymbolicExpressionGrammarValueConfiguration(SymbolicExpressionGrammarValueConfiguration original, Cloner cloner)41 : base(original, cloner) {42 40 } 43 41 public override IDeepCloneable Clone(Cloner cloner) { -
TabularUnified 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 22 using System; 2 23 using System.Drawing; 3 24 using HeuristicLab.Common; … … 32 53 } 33 54 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 } 34 63 public TypeValue() 35 64 : base() { … … 41 70 this.readOnly = false; 42 71 } 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 }50 72 public override IDeepCloneable Clone(Cloner cloner) { 51 73 return new TypeValue(this, cloner); 52 74 } 75 #endregion 53 76 54 77 public virtual TypeValue AsReadOnly() { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/CheckedValueConfigurationCollection.cs ¶
r8517 r8535 28 28 29 29 namespace HeuristicLab.Encodings.ParameterConfigurationEncoding { 30 // todo: check that at least 1 elementsneeds to be selected31 // todo: control creatable item types30 // TODO: check that at least 1 element needs to be selected 31 // TODO: control creatable item types 32 32 [StorableClass] 33 33 public class CheckedValueConfigurationList : CheckedItemList<IValueConfiguration>, ICheckedValueConfigurationList { … … 44 44 } 45 45 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 58 47 [StorableConstructor] 59 48 protected CheckedValueConfigurationList(bool deserializing) … … 67 56 RegisterEvents(); 68 57 } 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 } 70 72 public override IDeepCloneable Clone(Cloner cloner) { 71 73 return new CheckedValueConfigurationList(this, cloner); … … 75 77 RegisterEvents(); 76 78 } 79 #endregion 77 80 78 81 private void RegisterEvents() { 79 82 this.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 80 this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);81 83 } 82 84 83 85 private void DeregisterEvents() { 84 this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved);85 86 this.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 86 87 } … … 95 96 } 96 97 } 97 98 private void CheckedValueConfigurationList_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) {99 // auch collectionreset gehört berücksichtigt100 // funktioniert so nicht ganz, weil die view das hinzufügen nicht mitkriegt101 //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 110 98 } 111 99 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/NullValueConfiguration.cs ¶
r8517 r8535 28 28 [StorableClass] 29 29 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 35 31 [StorableConstructor] 36 32 protected NullValueConfiguration(bool deserializing) : base(deserializing) { } … … 38 34 : base(original, cloner) { 39 35 } 36 public NullValueConfiguration() 37 : base() { 38 this.ActualValue = new ConstrainedValue(null, null, null, true); 39 this.IsOptimizable = false; 40 } 40 41 public override IDeepCloneable Clone(Cloner cloner) { 41 42 return new NullValueConfiguration(this, cloner); 42 43 } 44 #endregion 43 45 44 46 public override string ToString() { -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ParameterizedValueConfiguration.cs ¶
r8517 r8535 83 83 [StorableConstructor] 84 84 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() { 86 92 this.ParameterConfigurations = new ItemList<IParameterConfiguration>(); 87 93 } … … 89 95 : base(value, valueDataType) { 90 96 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);96 97 } 97 98 public override IDeepCloneable Clone(Cloner cloner) { … … 107 108 if (valueParameter != null) { 108 109 var pc = new ParameterConfiguration(valueParameter.Name, valueParameter, discoverValidValues); 110 pc.CombinationsCountChanged += (sender, args) => OnCombinationsCountChanged(); 109 111 this.parameterConfigurations.Add(pc); 110 112 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/RangeValueConfiguration.cs ¶
r8517 r8535 46 46 [StorableConstructor] 47 47 protected RangeValueConfiguration(bool deserializing) : base(deserializing) { } 48 public RangeValueConfiguration() {49 50 }51 48 protected RangeValueConfiguration(RangeValueConfiguration original, Cloner cloner) 52 49 : base(original, cloner) { … … 54 51 RegisterRangeConstraintEvents(); 55 52 } 53 public RangeValueConfiguration() : base() { } 56 54 public RangeValueConfiguration(IItem value, Type valueDataType) 57 55 : base(value, valueDataType) { … … 68 66 } 69 67 } 70 public override IDeepCloneable Clone(Cloner cloner) {71 return new RangeValueConfiguration(this, cloner);72 }73 68 [StorableHook(HookType.AfterDeserialization)] 74 69 private void AfterDeserialization() { 75 70 RegisterRangeConstraintEvents(); 76 71 } 72 public override IDeepCloneable Clone(Cloner cloner) { 73 return new RangeValueConfiguration(this, cloner); 74 } 77 75 #endregion 78 76 79 77 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 } 81 84 } 85 82 86 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 } 84 93 } 85 94 … … 119 128 OnToStringChanged(); 120 129 } 130 private void RangeConstraintParametersChanged(object sender, EventArgs e) { 131 OnCombinationsCountChanged(); 132 } 121 133 #endregion 122 134 } -
TabularUnified branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/ValueConfigurations/ValueConfiguration.cs ¶
r8524 r8535 61 61 optimize = value; 62 62 OnOptimizeChanged(); 63 OnCombinationsCountChanged(); 63 64 OnToStringChanged(); 64 65 } … … 117 118 } 118 119 protected ValueConfiguration() : base() { } 119 protected ValueConfiguration(IItem value, Type valueDataType) { 120 protected ValueConfiguration(IItem value, Type valueDataType) 121 : base() { 120 122 this.ActualValue = new ConstrainedValue(value, valueDataType, new ItemSet<IItem> { value }, false); 121 123 this.IsOptimizable = true; … … 168 170 if (handler != null) handler(this, EventArgs.Empty); 169 171 } 172 173 public event EventHandler CombinationsCountChanged; 174 protected void OnCombinationsCountChanged() { 175 var handler = CombinationsCountChanged; 176 if (handler != null) handler(this, EventArgs.Empty); 177 } 170 178 #endregion 171 179
Note: See TracChangeset
for help on using the changeset viewer.