Changeset 324 for trunk/sources/HeuristicLab.Functions
- Timestamp:
- 06/18/08 16:20:26 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.Functions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/BakedFunctionTree.cs
r323 r324 132 132 } 133 133 134 public int Size { 135 get { 136 if(treesExpanded) { 137 int size = 1; 138 foreach(BakedFunctionTree tree in subTrees) { 139 size += tree.Size; 140 } 141 return size; 142 } else 143 return linearRepresentation.Count; 144 } 145 } 146 147 public int Height { 148 get { 149 if(treesExpanded) { 150 int height = 0; 151 foreach(IFunctionTree subTree in subTrees) { 152 int curHeight = subTree.Height; 153 if(curHeight > height) height = curHeight; 154 } 155 return height+1; 156 } else { 157 int nextBranchStart; 158 return BranchHeight(0, out nextBranchStart); 159 } 160 } 161 } 162 163 private int BranchHeight(int branchStart, out int nextBranchStart) { 164 LightWeightFunction f = linearRepresentation[branchStart]; 165 int height = 0; 166 branchStart++; 167 for(int i = 0; i < f.arity; i++) { 168 int curHeight = BranchHeight(branchStart, out nextBranchStart); 169 if(curHeight > height) height = curHeight; 170 branchStart = nextBranchStart; 171 } 172 nextBranchStart = branchStart; 173 return height + 1; 174 } 175 134 176 public IList<IFunctionTree> SubTrees { 135 177 get { … … 142 184 int length = BranchLength(branchIndex); 143 185 for(int j = branchIndex; j < branchIndex + length; j++) { 144 subTree.linearRepresentation.Add(linearRepresentation[j] .Clone());186 subTree.linearRepresentation.Add(linearRepresentation[j]); 145 187 } 146 188 branchIndex += length; -
trunk/sources/HeuristicLab.Functions/IFunctionTree.cs
r155 r324 28 28 namespace HeuristicLab.Functions { 29 29 public interface IFunctionTree : IItem { 30 int Size { get; } 31 int Height { get; } 30 32 IList<IFunctionTree> SubTrees { get; } 31 33 ICollection<IVariable> LocalVariables { get; }
Note: See TracChangeset
for help on using the changeset viewer.