- Timestamp:
- 11/17/11 11:51:09 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarSampleExpressionTreeView.Designer.cs
r6803 r7012 52 52 this.maxTreeDepthTextBox = new System.Windows.Forms.TextBox(); 53 53 this.generateSampleTreeButton = new System.Windows.Forms.Button(); 54 this.treeCreatorComboBox = new System.Windows.Forms.ComboBox(); 55 this.treeCreatorLabel = new System.Windows.Forms.Label(); 54 56 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 55 57 this.sampleTreeGroupBox.SuspendLayout(); … … 69 71 // sampleTreeGroupBox 70 72 // 71 this.sampleTreeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 72 | System.Windows.Forms.AnchorStyles.Left)73 | System.Windows.Forms.AnchorStyles.Right)));73 this.sampleTreeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 74 | System.Windows.Forms.AnchorStyles.Left) 75 | System.Windows.Forms.AnchorStyles.Right))); 74 76 this.sampleTreeGroupBox.Controls.Add(this.sampleTreeView); 75 this.sampleTreeGroupBox.Location = new System.Drawing.Point(3, 1 07);77 this.sampleTreeGroupBox.Location = new System.Drawing.Point(3, 134); 76 78 this.sampleTreeGroupBox.Name = "sampleTreeGroupBox"; 77 this.sampleTreeGroupBox.Size = new System.Drawing.Size(431, 2 92);79 this.sampleTreeGroupBox.Size = new System.Drawing.Size(431, 265); 78 80 this.sampleTreeGroupBox.TabIndex = 3; 79 81 this.sampleTreeGroupBox.TabStop = false; … … 89 91 this.sampleTreeView.Name = "sampleTreeView"; 90 92 this.sampleTreeView.ReadOnly = false; 91 this.sampleTreeView.Size = new System.Drawing.Size(425, 2 73);93 this.sampleTreeView.Size = new System.Drawing.Size(425, 246); 92 94 this.sampleTreeView.TabIndex = 0; 93 95 // … … 112 114 // maxTreeLengthTextBox 113 115 // 114 this.maxTreeLengthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 115 | System.Windows.Forms.AnchorStyles.Right)));116 this.maxTreeLengthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 117 | System.Windows.Forms.AnchorStyles.Right))); 116 118 this.maxTreeLengthTextBox.Location = new System.Drawing.Point(93, 26); 117 119 this.maxTreeLengthTextBox.Name = "maxTreeLengthTextBox"; … … 124 126 // maxTreeDepthTextBox 125 127 // 126 this.maxTreeDepthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 127 | System.Windows.Forms.AnchorStyles.Right)));128 this.maxTreeDepthTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 129 | System.Windows.Forms.AnchorStyles.Right))); 128 130 this.maxTreeDepthTextBox.Location = new System.Drawing.Point(93, 52); 129 131 this.maxTreeDepthTextBox.Name = "maxTreeDepthTextBox"; … … 136 138 // generateSampleTreeButton 137 139 // 138 this.generateSampleTreeButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 139 | System.Windows.Forms.AnchorStyles.Right)));140 this.generateSampleTreeButton.Location = new System.Drawing.Point( 3, 78);140 this.generateSampleTreeButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 141 | System.Windows.Forms.AnchorStyles.Right))); 142 this.generateSampleTreeButton.Location = new System.Drawing.Point(6, 105); 141 143 this.generateSampleTreeButton.Name = "generateSampleTreeButton"; 142 144 this.generateSampleTreeButton.Size = new System.Drawing.Size(431, 23); … … 146 148 this.generateSampleTreeButton.Click += new System.EventHandler(this.generateSampleTreeButton_Click); 147 149 // 150 // treeCreatorComboBox 151 // 152 this.treeCreatorComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 153 | System.Windows.Forms.AnchorStyles.Right))); 154 this.treeCreatorComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 155 this.treeCreatorComboBox.FormattingEnabled = true; 156 this.treeCreatorComboBox.Location = new System.Drawing.Point(93, 78); 157 this.treeCreatorComboBox.Name = "treeCreatorComboBox"; 158 this.treeCreatorComboBox.Size = new System.Drawing.Size(341, 21); 159 this.treeCreatorComboBox.TabIndex = 9; 160 this.treeCreatorComboBox.SelectedIndexChanged += new System.EventHandler(this.treeCreatorComboBox_SelectedIndexChanged); 161 // 162 // treeCreatorLabel 163 // 164 this.treeCreatorLabel.AutoSize = true; 165 this.treeCreatorLabel.Location = new System.Drawing.Point(3, 81); 166 this.treeCreatorLabel.Name = "treeCreatorLabel"; 167 this.treeCreatorLabel.Size = new System.Drawing.Size(69, 13); 168 this.treeCreatorLabel.TabIndex = 10; 169 this.treeCreatorLabel.Text = "Tree Creator:"; 170 // 148 171 // SymbolicExpressionGrammarSampleExpressionTreeView 149 172 // 150 173 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 151 174 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 175 this.Controls.Add(this.treeCreatorLabel); 152 176 this.Controls.Add(this.sampleTreeGroupBox); 153 177 this.Controls.Add(this.maxTreeDepthLabel); 154 178 this.Controls.Add(this.maxTreeLengthTextBox); 179 this.Controls.Add(this.treeCreatorComboBox); 155 180 this.Controls.Add(this.maxTreeLengthLabel); 156 181 this.Controls.Add(this.maxTreeDepthTextBox); … … 161 186 this.Controls.SetChildIndex(this.maxTreeDepthTextBox, 0); 162 187 this.Controls.SetChildIndex(this.maxTreeLengthLabel, 0); 188 this.Controls.SetChildIndex(this.treeCreatorComboBox, 0); 163 189 this.Controls.SetChildIndex(this.maxTreeLengthTextBox, 0); 164 190 this.Controls.SetChildIndex(this.maxTreeDepthLabel, 0); 165 191 this.Controls.SetChildIndex(this.sampleTreeGroupBox, 0); 192 this.Controls.SetChildIndex(this.treeCreatorLabel, 0); 166 193 this.Controls.SetChildIndex(this.nameTextBox, 0); 167 194 this.Controls.SetChildIndex(this.infoLabel, 0); … … 183 210 private System.Windows.Forms.Button generateSampleTreeButton; 184 211 private GraphicalSymbolicExpressionTreeView sampleTreeView; 212 private System.Windows.Forms.ComboBox treeCreatorComboBox; 213 private System.Windows.Forms.Label treeCreatorLabel; 185 214 } 186 215 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarSampleExpressionTreeView.cs
r6803 r7012 36 36 public SymbolicExpressionGrammarSampleExpressionTreeView() { 37 37 InitializeComponent(); 38 random = new MersenneTwister(); 38 random = new MersenneTwister(); 39 39 maxSampleTreeLength = int.Parse(maxTreeLengthTextBox.Text); 40 40 maxSampleTreeDepth = int.Parse(maxTreeDepthTextBox.Text); 41 foreach (var treeCreator in ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeCreator>()) { 42 treeCreatorComboBox.Items.Add(treeCreator); 43 } 44 treeCreatorComboBox.SelectedIndex = 0; 41 45 } 42 46 … … 97 101 private void UpdateSampleTreeView() { 98 102 try { 99 ISymbolicExpressionTree tree = ProbabilisticTreeCreator.Create(random, Content, MaxSampleTreeLength, MaxSampleTreeDepth); 103 ISymbolicExpressionTreeCreator creator = (SymbolicExpressionTreeCreator)treeCreatorComboBox.SelectedItem; 104 ISymbolicExpressionTree tree = creator.CreateTree(random, Content, MaxSampleTreeLength, MaxSampleTreeDepth); 100 105 foreach (var node in tree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTopLevelNode>()) 101 106 node.SetGrammar(null); … … 147 152 } 148 153 #endregion 154 155 private void treeCreatorComboBox_SelectedIndexChanged(object sender, EventArgs e) { 156 } 149 157 } 150 158 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
r6944 r7012 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 [NonDiscoverableType] 31 33 [StorableClass] 32 34 [Item("FullTreeCreator", "An operator that creates new symbolic expression trees using the 'Full' method")] … … 60 62 public IntValue MaximumSymbolicExpressionTreeDepth { 61 63 get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; } 64 } 65 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 62 68 } 63 69 … … 97 103 98 104 protected override ISymbolicExpressionTree Create(IRandom random) { 99 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value); 105 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 106 } 107 108 public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 109 return Create(random, grammar, maxTreeLength, maxTreeDepth); 100 110 } 101 111 … … 108 118 /// <param name="grammar">Available tree grammar</param> 109 119 /// <param name="maxTreeDepth">Maximum tree depth</param> 120 /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param> 110 121 /// <returns></returns> 111 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {122 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 112 123 var tree = new SymbolicExpressionTree(); 113 124 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r6944 r7012 27 27 using HeuristicLab.Parameters; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.PluginInfrastructure; 29 30 30 31 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 32 [NonDiscoverableType] 31 33 [StorableClass] 32 34 [Item("GrowTreeCreator", "An operator that creates new symbolic expression trees using the 'Grow' method")] … … 60 62 public IntValue MaximumSymbolicExpressionTreeDepth { 61 63 get { return MaximumSymbolicExpressionTreeDepthParameter.ActualValue; } 64 } 65 66 public IntValue MaximumSymbolicExpressionTreeLength { 67 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 62 68 } 63 69 … … 97 103 98 104 protected override ISymbolicExpressionTree Create(IRandom random) { 99 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value); 105 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeLength.Value, MaximumSymbolicExpressionTreeDepth.Value); 106 } 107 108 public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 109 return Create(random, grammar, maxTreeLength, maxTreeDepth); 100 110 } 101 111 … … 107 117 /// <param name="grammar">Available tree grammar</param> 108 118 /// <param name="maxTreeDepth">Maximum tree depth</param> 119 /// <param name="maxTreeLength">Maximum tree length. This parameter is not used.</param> 109 120 /// <returns></returns> 110 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {121 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 111 122 var tree = new SymbolicExpressionTree(); 112 123 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/ProbabilisticTreeCreator.cs
r6911 r7012 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.PluginInfrastructure; 30 31 31 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 33 [NonDiscoverableType] 32 34 [StorableClass] 33 35 [Item("ProbabilisticTreeCreator", "An operator that creates new symbolic expression trees with uniformly distributed length")] … … 101 103 } 102 104 103 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, 104 int maxTreeLength, int maxTreeDepth) { 105 public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 106 return Create(random, grammar, maxTreeLength, maxTreeDepth); 107 } 108 109 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 105 110 SymbolicExpressionTree tree = new SymbolicExpressionTree(); 106 111 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/RampedHalfAndHalfTreeCreator.cs
r6887 r7012 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.PluginInfrastructure; 31 32 32 33 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 34 [NonDiscoverableType] 33 35 [StorableClass] 34 36 [Item("RampedHalfAndHalfTreeCreator", "An operator that creates new symbolic expression trees in an alternate way: half the trees are created usign the 'Grow' method while the other half are created using the 'Full' method")] … … 72 74 } 73 75 76 public IntValue MaximumSymbolicExpressionTreeLength { 77 get { return MaximumSymbolicExpressionTreeLengthParameter.ActualValue; } 78 } 79 74 80 public ISymbolicExpressionGrammar SymbolicExpressionTreeGrammar { 75 81 get { return ClonedSymbolicExpressionTreeGrammarParameter.ActualValue; } … … 106 112 107 113 protected override ISymbolicExpressionTree Create(IRandom random) { 108 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value); 114 return Create(random, SymbolicExpressionTreeGrammar, MaximumSymbolicExpressionTreeDepth.Value, MaximumSymbolicExpressionTreeLength.Value); 115 } 116 117 public override ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 118 return Create(random, grammar, maxTreeLength, maxTreeDepth); 109 119 } 110 120 … … 117 127 /// <param name="maxTreeDepth">Maximum tree depth</param> 118 128 /// <returns></returns> 119 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTree Depth) {129 public static ISymbolicExpressionTree Create(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth) { 120 130 var tree = new SymbolicExpressionTree(); 121 131 var rootNode = (SymbolicExpressionTreeTopLevelNode)grammar.ProgramRootSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/SymbolicExpressionTreeCreator.cs
r6233 r7012 39 39 #endregion 40 40 41 #region Prope ties41 #region Properties 42 42 public ISymbolicExpressionTree SymbolicExpressionTree { 43 43 get { return SymbolicExpressionTreeParameter.ActualValue; } … … 60 60 61 61 protected abstract ISymbolicExpressionTree Create(IRandom random); 62 public abstract ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth); 62 63 } 63 64 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/Operators/ISymbolicExpressionTreeCreator.cs
r5809 r7012 29 29 public interface ISymbolicExpressionTreeCreator : ISymbolicExpressionTreeOperator, ISolutionCreator { 30 30 ILookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter { get; } 31 ISymbolicExpressionTree CreateTree(IRandom random, ISymbolicExpressionGrammar grammar, int maxTreeLength, int maxTreeDepth); 31 32 } 32 33 } -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/FullTreeCreatorTest.cs
r6949 r7012 32 32 private const int POPULATION_SIZE = 10000; 33 33 private const int MAX_TREE_DEPTH = 10; 34 private const int MAX_TREE_LENGTH = 1000; 34 35 private TestContext testContextInstance; 35 36 … … 55 56 stopwatch.Start(); 56 57 for (int i = 0; i != POPULATION_SIZE; i++) { 57 randomTrees.Add(FullTreeCreator.Create(random, grammar, MAX_TREE_DEPTH ));58 randomTrees.Add(FullTreeCreator.Create(random, grammar, MAX_TREE_DEPTH, MAX_TREE_LENGTH)); 58 59 } 59 60 stopwatch.Stop(); -
trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4/GrowTreeCreatorTest.cs
r6949 r7012 32 32 private const int POPULATION_SIZE = 10000; 33 33 private const int MAX_TREE_DEPTH = 10; 34 private const int MAX_TREE_LENGTH = 50; 34 35 private TestContext testContextInstance; 35 36 … … 55 56 stopwatch.Start(); 56 57 for (int i = 0; i != POPULATION_SIZE; i++) { 57 randomTrees.Add(GrowTreeCreator.Create(random, grammar, MAX_TREE_DEPTH ));58 randomTrees.Add(GrowTreeCreator.Create(random, grammar, MAX_TREE_DEPTH, MAX_TREE_LENGTH)); 58 59 } 59 60 stopwatch.Stop();
Note: See TracChangeset
for help on using the changeset viewer.