Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/16 14:32:12 (8 years ago)
Author:
bburlacu
Message:

#2643: Prevent invalid values for maxInsertedBranchLength and maxInsertedBranchDepth in SubtreeCrossover.cs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs

    r12509 r14181  
    9595      int childLength = crossoverPoint0.Child != null ? crossoverPoint0.Child.GetLength() : 0;
    9696      // calculate the max length and depth that the inserted branch can have
    97       int maxInsertedBranchLength = maxTreeLength - (parent0.Length - childLength);
    98       int maxInsertedBranchDepth = maxTreeDepth - parent0.Root.GetBranchLevel(crossoverPoint0.Parent);
     97      int maxInsertedBranchLength = Math.Max(1, maxTreeLength - (parent0.Length - childLength));
     98      int maxInsertedBranchDepth = Math.Max(1, maxTreeDepth - parent0.Root.GetBranchLevel(crossoverPoint0.Parent));
    9999
    100100      List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>();
Note: See TracChangeset for help on using the changeset viewer.