コード例 #1
0
ファイル: BeliefNode.cs プロジェクト: ebriant/POMCP.Website
 public void SetAsRoot(Distribution <State> d)
 {
     Parent = null;
     Belief = d;
 }
コード例 #2
0
ファイル: BeliefNode.cs プロジェクト: ebriant/POMCP.Website
 /// <summary>
 /// Add a child node at the end of the children list
 /// </summary>
 /// <param name="childNode"></param>
 public void AddChild(ActionNode childNode)
 {
     Children.Add(childNode);
 }
コード例 #3
0
ファイル: SamplingTree.cs プロジェクト: ebriant/POMCP.Website
        //
        /// <summary>
        /// Function that perform one exploration of the tree, and make it grow by a pair of action & belief nodes
        /// </summary>
        /// <param name="maxDepth"></param>
        public void GrowTree(int maxDepth, float gama, float C)
        {
            BeliefNode beliefNode = Root;

            Root.IncrementOccurrence();


            // Explore the tree until it reaches the finish point or the number of iteration is too high
            int depth = 1;

            ActionNode actionNode;
            Action     action;
            State      state;
            bool       stocking = true;

            while (depth < maxDepth & !beliefNode.IsTerminal())
            {
                // Pick a state in the belief of the actual belief node
                state = beliefNode.Belief.GetNormalisedCopy().Draw();

                // Draw the next action
                action = beliefNode.DrawAction(state, stocking, C);

                // If the new node is not in the children, it is added, else its occurrence is incremented
                actionNode = beliefNode.SearchChildren(action);
                if (actionNode == null)
                {
                    actionNode = new ActionNode(action, beliefNode);
                    if (stocking)
                    {
                        beliefNode.AddChild(actionNode);
                    }
                }
                else
                {
                    actionNode.IncrementOccurrence();
                }

                // Get a new state of the system
                state = _markovModel.ApplyTransition(state, action).Draw();

                Observation observation = _markovModel.GetAllObservations(state).Draw();

                // If the new node is not in the children, it is added, else its occurrence is incremented

                beliefNode = actionNode.SearchChildren(observation);
                if (beliefNode == null)
                {
                    beliefNode = new BeliefNode(observation, actionNode, _markovModel);
                    if (stocking)
                    {
                        actionNode.AddChild(beliefNode);
                    }
                    stocking = false;
                }
                else
                {
                    beliefNode.IncrementOccurrence();
                }

                beliefNode.AddState(state);

                depth++;
            }

            beliefNode.UpdateValue(gama);
        }