Changeset 12706 for stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs
- Timestamp:
- 07/10/15 12:02:20 (9 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 12422,12424,12480-12482
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/ArchitectureManipulators/SubroutineDeleter.cs
r12009 r12706 26 26 using HeuristicLab.Data; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Random; 28 29 29 30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { … … 55 56 ISymbolicExpressionTree symbolicExpressionTree, 56 57 int maxFunctionDefinitions, int maxFunctionArguments) { 57 var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>() ;58 var functionDefiningBranches = symbolicExpressionTree.IterateNodesPrefix().OfType<DefunTreeNode>().ToList(); 58 59 59 if ( functionDefiningBranches.Count() == 0)60 if (!functionDefiningBranches.Any()) 60 61 // no ADF to delete => abort 61 62 return false; 62 var selectedDefunBranch = functionDefiningBranches.SelectRandom(random); 63 64 var selectedDefunBranch = functionDefiningBranches.SampleRandom(random); 63 65 // remove the selected defun 64 66 int defunSubtreeIndex = symbolicExpressionTree.Root.IndexOfSubtree(selectedDefunBranch); … … 92 94 var allowedSymbolsList = invocationCutPoint.Parent.Grammar.GetAllowedChildSymbols(invocationCutPoint.Parent.Symbol, invocationCutPoint.ChildIndex).ToList(); 93 95 var weights = allowedSymbolsList.Select(s => s.InitialFrequency); 96 97 #pragma warning disable 612, 618 94 98 var selectedSymbol = allowedSymbolsList.SelectRandom(weights, random); 99 #pragma warning restore 612, 618 100 95 101 96 102 int minPossibleLength = invocationCutPoint.Parent.Grammar.GetMinimumExpressionLength(selectedSymbol);
Note: See TracChangeset
for help on using the changeset viewer.