Changeset 5014 for trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators
- Timestamp:
- 12/03/10 14:11:02 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/Manipulators/ReplaceBranchManipulation.cs
r4722 r5014 53 53 from subtree in parent.SubTrees 54 54 select new { Parent = parent, Node = subtree, Index = parent.SubTrees.IndexOf(subtree) }).SelectRandom(random); 55 56 int maxSize = maxTreeSize - symbolicExpressionTree.Size + manipulationPoint.Node.GetSize(); 57 int maxHeight = maxTreeHeight - symbolicExpressionTree.Height + manipulationPoint.Node.GetHeight(); 55 58 // find possible symbols for the node (also considering the existing branches below it) 56 var allowedSymbols = from symbol in manipulationPoint.Parent.GetAllowedSymbols(manipulationPoint.Index )59 var allowedSymbols = from symbol in manipulationPoint.Parent.GetAllowedSymbols(manipulationPoint.Index, maxHeight) 57 60 select symbol; 61 if (allowedSymbols.Count() <= 1) return; 58 62 59 if (allowedSymbols.Count() <= 1) { 60 return; 61 } 62 var oldBranch = manipulationPoint.Node; 63 int oldBranchSize = manipulationPoint.Node.GetSize(); 64 65 var seedSymbol = SelectRandomSymbol(random, allowedSymbols); 66 67 // replace the old node with the new node 63 var seedSymbol = SelectRandomSymbol(random, allowedSymbols); // replace the old node with the new node 68 64 var seedNode = seedSymbol.CreateTreeNode(); 69 65 if (seedNode.HasLocalParameters) … … 72 68 manipulationPoint.Parent.RemoveSubTree(manipulationPoint.Index); 73 69 manipulationPoint.Parent.InsertSubTree(manipulationPoint.Index, seedNode); 74 int maxSize = Math.Max(oldBranchSize, seedNode.Grammar.GetMinExpressionLength(seedNode.Symbol)) * 2; 75 var bla = ProbabilisticTreeCreator.PTC2(random, seedNode, maxSize, maxSize, 0, 0); 70 seedNode = ProbabilisticTreeCreator.PTC2(random, seedNode, maxSize, maxHeight, 0, 0); 76 71 success = true; 77 72 }
Note: See TracChangeset
for help on using the changeset viewer.