Changeset 11952
- Timestamp:
- 02/06/15 15:22:27 (10 years ago)
- Location:
- branches/ProgrammableProblem
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs
r11949 r11952 118 118 ConfigureOperators(newOperators); 119 119 foreach (var @operator in newOperators) 120 encodingOperators.Add(@operator);120 AddOperator(@operator); 121 121 } 122 122 #endregion -
branches/ProgrammableProblem/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs
r11949 r11952 181 181 ConfigureOperators(newOperators); 182 182 foreach (var @operator in newOperators) 183 encodingOperators.Add(@operator);183 AddOperator(@operator); 184 184 } 185 185 #endregion -
branches/ProgrammableProblem/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs
r11949 r11952 156 156 ConfigureOperators(newOperators); 157 157 foreach (var @operator in newOperators) 158 encodingOperators.Add(@operator);158 AddOperator(@operator); 159 159 } 160 160 #endregion -
branches/ProgrammableProblem/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs
r11949 r11952 180 180 ConfigureOperators(newOperators); 181 181 foreach (var @operator in newOperators) 182 encodingOperators.Add(@operator);182 AddOperator(@operator); 183 183 184 184 foreach (var strategyVectorCreator in Operators.OfType<IRealVectorStdDevStrategyParameterCreator>()) -
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r11949 r11952 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 … … 37 38 } 38 39 39 pr otected HashSet<IOperator> encodingOperators = new HashSet<IOperator>(new TypeEqualityComparer<IOperator>());40 private ItemSet<IOperator> encodingOperators = new ItemSet<IOperator>(new TypeEqualityComparer<IOperator>()); 40 41 41 42 [Storable(Name = "Operators")] 42 43 private IEnumerable<IOperator> StorableOperators { 43 44 get { return encodingOperators; } 44 set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; }45 set { encodingOperators = new ItemSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; } 45 46 } 46 47 … … 50 51 if (!value.OfType<T>().Any()) 51 52 throw new ArgumentException("The provided operators contain no suitable solution creator"); 52 encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); 53 encodingOperators.Clear(); 54 foreach (var op in value) encodingOperators.Add(op); 53 55 54 56 T newSolutionCreator = (T)encodingOperators.FirstOrDefault(o => o.GetType() == solutionCreator.GetType()) ?? … … 85 87 protected Encoding(Encoding<T> original, Cloner cloner) 86 88 : base(original, cloner) { 87 encodingOperators = new HashSet<IOperator>(original.Operators.Select(cloner.Clone), new TypeEqualityComparer<IOperator>());89 encodingOperators = cloner.Clone(original.encodingOperators); 88 90 solutionCreator = cloner.Clone(original.solutionCreator); 89 91 } 90 protected Encoding(string name) : base(name) { } 92 protected Encoding(string name) 93 : base(name) { 94 Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly())); 95 } 91 96 92 97 public virtual Individual GetIndividual(IScope scope) { 93 98 return new SingleEncodingIndividual(this, scope); 99 } 100 101 protected bool AddOperator(IOperator @operator) { 102 return encodingOperators.Add(@operator); 103 } 104 105 protected bool RemoveOperator(IOperator @operator) { 106 return encodingOperators.Remove(@operator); 94 107 } 95 108 -
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/MultiEncoding.cs
r11949 r11952 56 56 57 57 foreach (var @operator in ApplicationManager.Manager.GetInstances<IMultiEncodingOperator>()) 58 encodingOperators.Add(@operator);58 AddOperator(@operator); 59 59 } 60 60 -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable.Views/3.3/MultiEncodingView.Designer.cs
r11892 r11952 46 46 private void InitializeComponent() { 47 47 this.encodingsListView = new System.Windows.Forms.ListView(); 48 this.encodingNameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 49 this.encodingTypeColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 48 50 this.addEncodingButton = new System.Windows.Forms.Button(); 49 51 this.removeEncodingButton = new System.Windows.Forms.Button(); 50 52 this.splitContainer = new System.Windows.Forms.SplitContainer(); 51 this.encodingsGroupBox = new System.Windows.Forms.GroupBox();52 53 this.encodingDetailsGroupBox = new System.Windows.Forms.GroupBox(); 53 54 this.encodingDetailViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 54 this.encodingNameColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 55 this.encodingTypeColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 55 this.encodingsGroupBox = new System.Windows.Forms.GroupBox(); 56 this.tabControl = new System.Windows.Forms.TabControl(); 57 this.encodingsTabPage = new System.Windows.Forms.TabPage(); 58 this.parametersTabPage = new System.Windows.Forms.TabPage(); 56 59 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 57 60 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); … … 59 62 this.splitContainer.Panel2.SuspendLayout(); 60 63 this.splitContainer.SuspendLayout(); 64 this.encodingDetailsGroupBox.SuspendLayout(); 61 65 this.encodingsGroupBox.SuspendLayout(); 62 this.encodingDetailsGroupBox.SuspendLayout(); 66 this.tabControl.SuspendLayout(); 67 this.encodingsTabPage.SuspendLayout(); 63 68 this.SuspendLayout(); 64 69 // … … 87 92 this.encodingsListView.Name = "encodingsListView"; 88 93 this.encodingsListView.ShowGroups = false; 89 this.encodingsListView.Size = new System.Drawing.Size(2 14, 416);94 this.encodingsListView.Size = new System.Drawing.Size(241, 384); 90 95 this.encodingsListView.TabIndex = 3; 91 96 this.encodingsListView.UseCompatibleStateImageBehavior = false; 92 97 this.encodingsListView.View = System.Windows.Forms.View.Details; 93 98 this.encodingsListView.SelectedIndexChanged += new System.EventHandler(this.encodingsListView_SelectedIndexChanged); 99 // 100 // encodingNameColumnHeader 101 // 102 this.encodingNameColumnHeader.Text = "Name"; 103 this.encodingNameColumnHeader.Width = 100; 104 // 105 // encodingTypeColumnHeader 106 // 107 this.encodingTypeColumnHeader.Text = "Type"; 108 this.encodingTypeColumnHeader.Width = 136; 94 109 // 95 110 // addEncodingButton … … 116 131 // 117 132 this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 133 this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; 118 134 this.splitContainer.Location = new System.Drawing.Point(3, 16); 119 135 this.splitContainer.Name = "splitContainer"; … … 128 144 // 129 145 this.splitContainer.Panel2.Controls.Add(this.encodingDetailsGroupBox); 130 this.splitContainer.Size = new System.Drawing.Size(6 60, 452);131 this.splitContainer.SplitterDistance = 2 20;146 this.splitContainer.Size = new System.Drawing.Size(643, 420); 147 this.splitContainer.SplitterDistance = 247; 132 148 this.splitContainer.TabIndex = 5; 133 //134 // encodingsGroupBox135 //136 this.encodingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)137 | System.Windows.Forms.AnchorStyles.Left)138 | System.Windows.Forms.AnchorStyles.Right)));139 this.encodingsGroupBox.Controls.Add(this.splitContainer);140 this.encodingsGroupBox.Location = new System.Drawing.Point(0, 26);141 this.encodingsGroupBox.Name = "encodingsGroupBox";142 this.encodingsGroupBox.Size = new System.Drawing.Size(666, 471);143 this.encodingsGroupBox.TabIndex = 6;144 this.encodingsGroupBox.TabStop = false;145 this.encodingsGroupBox.Text = "Encodings";146 149 // 147 150 // encodingDetailsGroupBox … … 153 156 this.encodingDetailsGroupBox.Location = new System.Drawing.Point(3, 27); 154 157 this.encodingDetailsGroupBox.Name = "encodingDetailsGroupBox"; 155 this.encodingDetailsGroupBox.Size = new System.Drawing.Size( 430, 422);158 this.encodingDetailsGroupBox.Size = new System.Drawing.Size(386, 390); 156 159 this.encodingDetailsGroupBox.TabIndex = 1; 157 160 this.encodingDetailsGroupBox.TabStop = false; … … 167 170 this.encodingDetailViewHost.Name = "encodingDetailViewHost"; 168 171 this.encodingDetailViewHost.ReadOnly = false; 169 this.encodingDetailViewHost.Size = new System.Drawing.Size( 424, 403);172 this.encodingDetailViewHost.Size = new System.Drawing.Size(380, 371); 170 173 this.encodingDetailViewHost.TabIndex = 0; 171 174 this.encodingDetailViewHost.ViewsLabelVisible = true; 172 175 this.encodingDetailViewHost.ViewType = null; 173 176 // 174 // encodingNameColumnHeader 175 // 176 this.encodingNameColumnHeader.Text = "Name"; 177 this.encodingNameColumnHeader.Width = 80; 178 // 179 // encodingTypeColumnHeader 180 // 181 this.encodingTypeColumnHeader.Text = "Type"; 182 this.encodingTypeColumnHeader.Width = 120; 177 // encodingsGroupBox 178 // 179 this.encodingsGroupBox.Controls.Add(this.splitContainer); 180 this.encodingsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 181 this.encodingsGroupBox.Location = new System.Drawing.Point(3, 3); 182 this.encodingsGroupBox.Name = "encodingsGroupBox"; 183 this.encodingsGroupBox.Size = new System.Drawing.Size(649, 439); 184 this.encodingsGroupBox.TabIndex = 6; 185 this.encodingsGroupBox.TabStop = false; 186 this.encodingsGroupBox.Text = "Encodings"; 187 // 188 // tabControl 189 // 190 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 191 | System.Windows.Forms.AnchorStyles.Left) 192 | System.Windows.Forms.AnchorStyles.Right))); 193 this.tabControl.Controls.Add(this.encodingsTabPage); 194 this.tabControl.Controls.Add(this.parametersTabPage); 195 this.tabControl.Location = new System.Drawing.Point(0, 26); 196 this.tabControl.Name = "tabControl"; 197 this.tabControl.SelectedIndex = 0; 198 this.tabControl.Size = new System.Drawing.Size(663, 471); 199 this.tabControl.TabIndex = 7; 200 // 201 // encodingsTabPage 202 // 203 this.encodingsTabPage.Controls.Add(this.encodingsGroupBox); 204 this.encodingsTabPage.Location = new System.Drawing.Point(4, 22); 205 this.encodingsTabPage.Name = "encodingsTabPage"; 206 this.encodingsTabPage.Padding = new System.Windows.Forms.Padding(3); 207 this.encodingsTabPage.Size = new System.Drawing.Size(655, 445); 208 this.encodingsTabPage.TabIndex = 0; 209 this.encodingsTabPage.Text = "Encodings"; 210 this.encodingsTabPage.UseVisualStyleBackColor = true; 211 // 212 // parametersTabPage 213 // 214 this.parametersTabPage.Location = new System.Drawing.Point(4, 22); 215 this.parametersTabPage.Name = "parametersTabPage"; 216 this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3); 217 this.parametersTabPage.Size = new System.Drawing.Size(655, 445); 218 this.parametersTabPage.TabIndex = 1; 219 this.parametersTabPage.Text = "Parameters"; 220 this.parametersTabPage.UseVisualStyleBackColor = true; 183 221 // 184 222 // MultiEncodingView 185 223 // 186 224 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 187 this.Controls.Add(this. encodingsGroupBox);225 this.Controls.Add(this.tabControl); 188 226 this.Name = "MultiEncodingView"; 189 227 this.Size = new System.Drawing.Size(666, 497); 228 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 190 229 this.Controls.SetChildIndex(this.nameLabel, 0); 191 230 this.Controls.SetChildIndex(this.nameTextBox, 0); 192 231 this.Controls.SetChildIndex(this.infoLabel, 0); 193 this.Controls.SetChildIndex(this. encodingsGroupBox, 0);232 this.Controls.SetChildIndex(this.tabControl, 0); 194 233 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 195 234 this.splitContainer.Panel1.ResumeLayout(false); … … 197 236 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 198 237 this.splitContainer.ResumeLayout(false); 238 this.encodingDetailsGroupBox.ResumeLayout(false); 199 239 this.encodingsGroupBox.ResumeLayout(false); 200 this.encodingDetailsGroupBox.ResumeLayout(false); 240 this.tabControl.ResumeLayout(false); 241 this.encodingsTabPage.ResumeLayout(false); 201 242 this.ResumeLayout(false); 202 243 this.PerformLayout(); … … 215 256 private MainForm.WindowsForms.ViewHost encodingDetailViewHost; 216 257 private System.Windows.Forms.GroupBox encodingsGroupBox; 258 private System.Windows.Forms.TabControl tabControl; 259 private System.Windows.Forms.TabPage encodingsTabPage; 260 private System.Windows.Forms.TabPage parametersTabPage; 217 261 } 218 262 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable.Views/3.3/MultiEncodingView.cs
r11949 r11952 33 33 [View("MultiEncoding View")] 34 34 [Content(typeof(MultiEncoding), IsDefaultView = true)] 35 public sealed partial class MultiEncodingView : NamedItemView {35 public sealed partial class MultiEncodingView : ParameterizedNamedItemView { 36 36 37 37 public new MultiEncoding Content { … … 42 42 public MultiEncodingView() { 43 43 InitializeComponent(); 44 Controls.Remove(parameterCollectionView); 45 parameterCollectionView.Dock = DockStyle.Fill; 46 parametersTabPage.Controls.Add(parameterCollectionView); 44 47 addEncodingButton.Text = string.Empty; 45 48 addEncodingButton.Image = VSImageLibrary.Add; … … 77 80 private void addEncodingButton_Click(object sender, EventArgs e) { 78 81 using (var dialog = new CreateNewSingleEncodingDialog()) { 79 dialog.ForbiddenNames = Content.Encodings.Select(x => x.Name) ;82 dialog.ForbiddenNames = Content.Encodings.Select(x => x.Name).Concat(new[] { Content.Name }); 80 83 if (dialog.ShowDialog() == DialogResult.OK) { 81 84 IEncoding encoding; 82 85 try { 83 86 encoding = (IEncoding)Activator.CreateInstance(dialog.EncodingType, dialog.EncodingName); 84 } 85 catch (MissingMethodException mmex) { 86 PluginInfrastructure.ErrorHandling.ShowErrorDialog( 87 "The encoding must have a constructor that takes the name as a single string argument", mmex); 87 } catch (MissingMethodException mmex) { 88 PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding must have a constructor that takes the name as a single string argument", mmex); 88 89 return; 89 } 90 catch (TargetInvocationException tiex) { 90 } catch (TargetInvocationException tiex) { 91 91 PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding could not be created due to an error in the constructor.", tiex); 92 92 return; 93 } 94 catch (MethodAccessException maex) { 93 } catch (MethodAccessException maex) { 95 94 PluginInfrastructure.ErrorHandling.ShowErrorDialog("The encoding's string constructor is not public.", maex); 96 95 return;
Note: See TracChangeset
for help on using the changeset viewer.