Changeset 8086 for branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4
- Timestamp:
- 06/22/12 11:11:38 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding (added) merged: 7795,7836,7955,7961,7964,7972
- Property svn:mergeinfo changed
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/FullTreeCreator.cs
r7259 r8086 161 161 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 162 162 .ToList(); 163 var selectedSymbol = possibleSymbols.SelectRandom(random); 163 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 164 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 164 165 var tree = selectedSymbol.CreateTreeNode(); 165 166 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 192 193 if (!possibleSymbols.Any()) 193 194 throw new InvalidOperationException("No symbols are available for the tree."); 194 195 var selectedSymbol = possibleSymbols.SelectRandom( random);195 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 196 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 196 197 var tree = selectedSymbol.CreateTreeNode(); 197 198 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Creators/GrowTreeCreator.cs
r7259 r8086 160 160 .Where(s => seedNode.Grammar.IsAllowedChildSymbol(seedNode.Symbol, s, i)) 161 161 .ToList(); 162 var selectedSymbol = possibleSymbols.SelectRandom(random); 162 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 163 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 163 164 var tree = selectedSymbol.CreateTreeNode(); 164 165 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); … … 178 179 throw new ArgumentException("Cannot grow node of arity zero. Expected a function node."); 179 180 180 var allowedSymbols = root.Grammar.AllowedSymbols 181 .Where(s => s.InitialFrequency > 0.0) 182 .ToList(); 181 var allowedSymbols = root.Grammar.AllowedSymbols.Where(s => s.InitialFrequency > 0.0).ToList(); 183 182 184 183 for (var i = 0; i < arity; i++) { … … 187 186 root.Grammar.GetMinimumExpressionDepth(s) - 1 <= maxDepth - currentDepth) 188 187 .ToList(); 188 189 189 if (!possibleSymbols.Any()) 190 190 throw new InvalidOperationException("No symbols are available for the tree."); 191 var selectedSymbol = possibleSymbols.SelectRandom(random); 191 var weights = possibleSymbols.Select(s => s.InitialFrequency).ToList(); 192 var selectedSymbol = possibleSymbols.SelectRandom(weights, random); 192 193 var tree = selectedSymbol.CreateTreeNode(); 193 194 if (tree.HasLocalParameters) tree.ResetLocalParameters(random); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTree.cs
r7259 r8086 29 29 int Depth { get; } 30 30 31 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth(); 31 32 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix(); 32 33 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix(); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbolicExpressionTreeNode.cs
r7507 r8086 34 34 int GetBranchLevel(ISymbolicExpressionTreeNode child); 35 35 36 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth(); 36 37 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPostfix(); 37 38 IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix(); -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Manipulators/OnePointShaker.cs
r7259 r8086 57 57 58 58 protected override void Manipulate(IRandom random, ISymbolicExpressionTree tree) { 59 OnePointShaker.Shake(random, tree, ShakingFactor); 60 } 61 62 public static void Shake(IRandom random, ISymbolicExpressionTree tree, double shakingFactor) { 59 63 List<ISymbolicExpressionTreeNode> parametricNodes = new List<ISymbolicExpressionTreeNode>(); 60 64 tree.Root.ForEachNodePostfix(n => { … … 63 67 if (parametricNodes.Count > 0) { 64 68 var selectedPoint = parametricNodes.SelectRandom(random); 65 selectedPoint.ShakeLocalParameters(random, ShakingFactor);69 selectedPoint.ShakeLocalParameters(random, shakingFactor); 66 70 } 67 71 } -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTree.cs
r7259 r8086 75 75 } 76 76 77 public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() { 78 if (root == null) 79 return new SymbolicExpressionTreeNode[0]; 80 return root.IterateNodesBreadth(); 81 } 82 77 83 public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() { 78 84 if (root == null) -
branches/ScatterSearch (trunk integration)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionTreeNode.cs
r7654 r8086 53 53 protected SymbolicExpressionTreeNode(bool deserializing) { } 54 54 protected SymbolicExpressionTreeNode(SymbolicExpressionTreeNode original, Cloner cloner) 55 : base( ) {55 : base(original, cloner) { 56 56 symbol = original.symbol; // symbols are reused 57 57 length = original.length; … … 174 174 } 175 175 176 public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesBreadth() { 177 var list = new List<ISymbolicExpressionTreeNode>() { this }; 178 int i = 0; 179 while (i != list.Count) { 180 for (int j = 0; j != list[i].SubtreeCount; ++j) 181 list.Add(list[i].GetSubtree(j)); 182 ++i; 183 } 184 return list; 185 } 186 176 187 public IEnumerable<ISymbolicExpressionTreeNode> IterateNodesPrefix() { 177 188 List<ISymbolicExpressionTreeNode> list = new List<ISymbolicExpressionTreeNode>();
Note: See TracChangeset
for help on using the changeset viewer.