Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/23/15 20:00:14 (9 years ago)
Author:
aballeit
Message:

#2283 added GUI and charts; fixed MCTS

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  
    1717        public IBanditPolicyActionInfo actionInfo;
    1818
    19         public TreeNode(TreeNode parent, string phrase)
     19        public TreeNode(TreeNode parent, string phrase, IBanditPolicyActionInfo actionInfo)
    2020        {
    2121            this.parent = parent;
    2222            this.phrase = phrase;
    23             actionInfo = new DefaultPolicyActionInfo();
     23            this.actionInfo = actionInfo;
    2424        }
    2525        public bool IsLeaf()
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Algorithms.MonteCarloTreeSearch/MonteCarloTreeSearch.cs

    r12098 r12503  
    5353                string phrase = currentNode.phrase;
    5454
    55                 if (!grammar.IsTerminal(phrase))
     55                if (!grammar.IsTerminal(phrase) && phrase.Length <= maxLen)
    5656                {
    5757                    ExpandTreeNode(currentNode);
     
    6060                        currentNode.children[behaviourPolicy.SelectAction(random, currentNode.GetChildActionInfos())];
    6161                }
    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);
    6466
    65                 Propagate(currentNode, quality);
     67                    Propagate(currentNode, quality);
     68                }
    6669            }
    6770        }
     
    8891                            if (newSequence.Length <= maxLen)
    8992                            {
    90                                 TreeNode childNode = new TreeNode(treeNode, newSequence.ToString());
     93                                TreeNode childNode = new TreeNode(treeNode, newSequence.ToString(), behaviourPolicy.CreateActionInfo());
    9194                                treeNode.children.Add(childNode);
    9295                            }
     
    101104            StopRequested = false;
    102105            bestQuality = 0.0;
    103             rootNode = new TreeNode(null, grammar.SentenceSymbol.ToString());
     106            rootNode = new TreeNode(null, grammar.SentenceSymbol.ToString(), behaviourPolicy.CreateActionInfo());
    104107        }
    105108
Note: See TracChangeset for help on using the changeset viewer.