- Timestamp:
- 06/18/08 16:20:26 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.StructureIdentification/Manipulation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/ChangeNodeTypeManipulation.cs
r238 r324 96 96 // calculate the height and size difference and 97 97 // check if the size of the new tree is still in the allowed bounds 98 int oldChildSize = gardener.GetTreeSize(selectedChild);99 int oldChildHeight = gardener.GetTreeSize(selectedChild);100 int newChildSize = gardener.GetTreeSize(newFunctionTree);101 int newChildHeight = gardener.GetTreeHeight(newFunctionTree);98 int oldChildSize = selectedChild.Size; 99 int oldChildHeight = selectedChild.Height; 100 int newChildSize = newFunctionTree.Size; 101 int newChildHeight = newFunctionTree.Height; 102 102 if((treeHeight.Data - oldChildHeight) + newChildHeight > maxTreeHeight || 103 103 (treeSize.Data - oldChildSize) + newChildSize > maxTreeSize) { … … 118 118 // update size and height 119 119 treeSize.Data = (treeSize.Data - oldChildSize) + newChildSize; 120 treeHeight.Data = gardener.GetTreeHeight(root); // must recalculate height because we can't know wether the manipulated branch was the deepest branch120 treeHeight.Data = root.Height; // must recalculate height because we can't know wether the manipulated branch was the deepest branch 121 121 // check if whole tree is ok 122 122 Debug.Assert(gardener.IsValidTree(root)); -
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/CutOutNodeManipulation.cs
r238 r324 74 74 if (root.SubTrees.Count > 0) { 75 75 root = root.SubTrees[random.Next(root.SubTrees.Count)]; 76 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);77 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);76 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 77 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 78 78 // update the variable 79 79 scope.GetVariable(scope.TranslateName("FunctionTree")).Value = root; … … 85 85 IFunctionTree newTree; 86 86 newTree = gardener.CreateRandomTree(gardener.Terminals, 1, 1); 87 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(newTree);88 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(newTree);87 GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size; 88 GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height; 89 89 // update the variable 90 90 scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree; … … 107 107 Debug.Assert(gardener.IsValidTree(root)); 108 108 // update the size and height of our tree 109 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);110 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);109 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 110 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 111 111 // don't need to schedule initialization operations 112 112 return null; … … 118 118 parent.RemoveSubTree(childIndex); 119 119 // then determine the number of nodes left over after the child has been removed! 120 int remainingNodes = gardener.GetTreeSize(root);120 int remainingNodes = root.Size; 121 121 allowedFunctions = gardener.GetAllowedSubFunctions(parent.Function, childIndex); 122 122 IFunctionTree newFunctionTree = gardener.CreateRandomTree(allowedFunctions, maxTreeSize - remainingNodes, maxTreeHeight - parentLevel); 123 123 parent.InsertSubTree(childIndex, newFunctionTree); 124 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);125 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);124 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 125 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 126 126 Debug.Assert(gardener.IsValidTree(root)); 127 127 // schedule an initialization operation for the new function-tree -
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/DeleteSubTreeManipulation.cs
r238 r324 64 64 Debug.Assert(gardener.IsValidTree(newTree)); 65 65 // update sizes to match the new tree 66 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(newTree);67 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(newTree);66 GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size; 67 GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height; 68 68 scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree; 69 69 … … 86 86 87 87 Debug.Assert(gardener.IsValidTree(root)); 88 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);89 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);88 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 89 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 90 90 // root hasn't changed so don't need to update 'FunctionTree' variable 91 91 return null; … … 97 97 parent.InsertSubTree(childIndex, newFunctionTree); 98 98 Debug.Assert(gardener.IsValidTree(root)); 99 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);100 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);99 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 100 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 101 101 // again the root hasn't changed so we don't need to update the 'FunctionTree' variable 102 102 // but we have to return an initialization operation for the newly created tree -
trunk/sources/HeuristicLab.StructureIdentification/Manipulation/SubstituteSubTreeManipulation.cs
r238 r324 65 65 66 66 // update the variables in the scope with the new values 67 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(newTree);68 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(newTree);67 GetVariableValue<IntData>("TreeSize", scope, true).Data = newTree.Size; 68 GetVariableValue<IntData>("TreeHeight", scope, true).Data = newTree.Height; 69 69 scope.GetVariable(scope.TranslateName("FunctionTree")).Value = newTree; 70 70 … … 86 86 int parentLevel = gardener.GetBranchLevel(root, parent); 87 87 int maxSubTreeHeight = maxTreeHeight - parentLevel; 88 int maxSubTreeSize = maxTreeSize - (treeSize - gardener.GetTreeSize(parent.SubTrees[childIndex]));88 int maxSubTreeSize = maxTreeSize - (treeSize - parent.SubTrees[childIndex].Size); 89 89 90 90 // create a random function tree … … 95 95 Debug.Assert(gardener.IsValidTree(root)); 96 96 // update the values of treeSize and treeHeight 97 GetVariableValue<IntData>("TreeSize", scope, true).Data = gardener.GetTreeSize(root);98 GetVariableValue<IntData>("TreeHeight", scope, true).Data = gardener.GetTreeHeight(root);97 GetVariableValue<IntData>("TreeSize", scope, true).Data = root.Size; 98 GetVariableValue<IntData>("TreeHeight", scope, true).Data = root.Height; 99 99 // the root hasn't changed so we don't need to update 100 100 // return a CompositeOperation that randomly initializes all nodes of the new subtree
Note: See TracChangeset
for help on using the changeset viewer.