Changeset 12503 for branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch
- Timestamp:
- 06/23/15 20:00:14 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/Base/TreeNode.cs
r12098 r12503 17 17 public IBanditPolicyActionInfo actionInfo; 18 18 19 public TreeNode(TreeNode parent, string phrase )19 public TreeNode(TreeNode parent, string phrase, IBanditPolicyActionInfo actionInfo) 20 20 { 21 21 this.parent = parent; 22 22 this.phrase = phrase; 23 actionInfo = new DefaultPolicyActionInfo();23 this.actionInfo = actionInfo; 24 24 } 25 25 public bool IsLeaf() -
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch.cs
r12098 r12503 53 53 string phrase = currentNode.phrase; 54 54 55 if (!grammar.IsTerminal(phrase) )55 if (!grammar.IsTerminal(phrase) && phrase.Length <= maxLen) 56 56 { 57 57 ExpandTreeNode(currentNode); … … 60 60 currentNode.children[behaviourPolicy.SelectAction(random, currentNode.GetChildActionInfos())]; 61 61 } 62 double quality = simulation.Simulate(currentNode); 63 OnSolutionEvaluated(phrase, quality); 62 if (currentNode.phrase.Length <= maxLen) 63 { 64 double quality = simulation.Simulate(currentNode); 65 OnSolutionEvaluated(phrase, quality); 64 66 65 Propagate(currentNode, quality); 67 Propagate(currentNode, quality); 68 } 66 69 } 67 70 } … … 88 91 if (newSequence.Length <= maxLen) 89 92 { 90 TreeNode childNode = new TreeNode(treeNode, newSequence.ToString() );93 TreeNode childNode = new TreeNode(treeNode, newSequence.ToString(), behaviourPolicy.CreateActionInfo()); 91 94 treeNode.children.Add(childNode); 92 95 } … … 101 104 StopRequested = false; 102 105 bestQuality = 0.0; 103 rootNode = new TreeNode(null, grammar.SentenceSymbol.ToString() );106 rootNode = new TreeNode(null, grammar.SentenceSymbol.ToString(), behaviourPolicy.CreateActionInfo()); 104 107 } 105 108
Note: See TracChangeset
for help on using the changeset viewer.