Changeset 14312 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
- Timestamp:
- 09/28/16 15:59:11 (8 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Crossovers/SubtreeCrossover.cs
r12891 r14312 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 95 95 int childLength = crossoverPoint0.Child != null ? crossoverPoint0.Child.GetLength() : 0; 96 96 // 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(0, maxTreeLength - (parent0.Length - childLength)); 98 int maxInsertedBranchDepth = Math.Max(0, maxTreeDepth - parent0.Root.GetBranchLevel(crossoverPoint0.Parent)); 99 99 100 100 List<ISymbolicExpressionTreeNode> allowedBranches = new List<ISymbolicExpressionTreeNode>(); … … 111 111 } else { 112 112 var selectedBranch = SelectRandomBranch(random, allowedBranches, internalCrossoverPointProbability); 113 if (selectedBranch != null) 114 selectedBranch = (ISymbolicExpressionTreeNode)selectedBranch.Clone(); 113 115 114 116 if (crossoverPoint0.Child != null) {
Note: See TracChangeset
for help on using the changeset viewer.