Changeset 12495 for branches/GBT/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs
- Timestamp:
- 06/23/15 12:50:05 (9 years ago)
- Location:
- branches/GBT
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GBT
- Property svn:mergeinfo changed
/trunk/sources merged: 12392-12393,12397-12401,12422,12424,12428-12435,12442-12443,12445,12455-12458,12461,12463-12465,12470-12476,12478-12482,12485,12488,12490-12494 -
Property
svn:global-ignores
set to
*.nuget
packages
- Property svn:mergeinfo changed
-
branches/GBT/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
branches/GBT/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDuplicater.cs
r12012 r12495 28 28 using HeuristicLab.Data; 29 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 30 using HeuristicLab.Random; 30 31 31 32 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 59 60 ISymbolicExpressionTree symbolicExpressionTree, 60 61 int maxFunctionDefinitions, int maxFunctionArguments) { 61 var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>() ;62 if ( functionDefiningBranches.Count() == 0|| functionDefiningBranches.Count() == maxFunctionDefinitions)62 var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList(); 63 if (!functionDefiningBranches.Any() || functionDefiningBranches.Count() == maxFunctionDefinitions) 63 64 // no function defining branches to duplicate or already reached the max number of ADFs 64 65 return false; … … 67 68 var allowedFunctionNames = from index in Enumerable.Range(0, maxFunctionDefinitions) 68 69 select "ADF" + index.ToString(formatString); 69 var selectedBranch = functionDefiningBranches.SelectRandom(random); 70 71 var selectedBranch = functionDefiningBranches.SampleRandom(random); 70 72 var duplicatedDefunBranch = (DefunTreeNode)selectedBranch.Clone(); 71 73 string newFunctionName = allowedFunctionNames.Except(UsedFunctionNames(symbolicExpressionTree)).First();
Note: See TracChangeset
for help on using the changeset viewer.