Changeset 1209
- Timestamp:
- 02/05/09 12:56:43 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP/Recombination/SizeConstrictedGPCrossoverBase.cs
r1196 r1209 50 50 int tries = 0; 51 51 do { 52 if (tries++ > MaxRecombinationTries) 53 // if after so many tries it was not possible to create a solution within the given size constraints just return the tree without changes. 54 return tree0; 52 55 if (tree0.SubTrees.Count > 0) { 53 56 newTree = Cross(gardener, random, (IFunctionTree)tree0.Clone(), (IFunctionTree)tree1.Clone(), maxTreeSize, maxTreeHeight); … … 55 58 newTree = Cross(gardener, random, (IFunctionTree)tree1.Clone(), (IFunctionTree)tree0.Clone(), maxTreeSize, maxTreeHeight); 56 59 } else newTree = tree0; 57 if (tries++ > MaxRecombinationTries)58 throw new InvalidOperationException("Couldn't recombine parents to create a valid child not larger than " + maxTreeSize + " and not higher than " + maxTreeHeight + ".");59 60 } while (newTree.Size > maxTreeSize || newTree.Height > maxTreeHeight); 60 61 return newTree;
Note: See TracChangeset
for help on using the changeset viewer.