Ejemplo n.º 1
0
        /// <summary>
        /// expands a given node
        /// </summary>
        /// <param name="toExpand"></param>
        private void Expand(MddMatchAndPruneState toExpand, successorIterator allChildren)
        {
            allChildren.initialize(toExpand);
            MddMatchAndPruneState successor;

            while (allChildren.hasNext)
            {
                successor = allChildren.getNext();
                if (closedList.ContainsKey(successor))
                {
                    ((MddMatchAndPruneState)closedList[successor]).addParent(toExpand);
                }
                else
                {
                    CostTreeNodeSolver.matchCounter++;
                    successor.addParent(toExpand);
                    closedList.Add(successor, successor);
                    openList.Enqueue(successor);
                    if (successor.stateLevel + 1 == this.solutionDepth)
                    {
                        goal = successor;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build the generalized MDD
        /// </summary>
        /// <returns></returns>
        private bool buildGeneralMDD()
        {
            MddMatchAndPruneState current     = openList.Dequeue();
            successorIterator     allChildren = new successorIterator(allMDDs.Length);
            int currentLevel = current.stateLevel;

            while (current.stateLevel + 1 != this.solutionDepth) // while not goal
            {
                Expand(current, allChildren);
                if (openList.Count == 0)
                {
                    return(false);
                }
                current = openList.Dequeue();
                if (current.stateLevel != currentLevel)
                {
                    closedList.Clear();
                    currentLevel++;
                }
                if (runner.ElapsedMilliseconds() > Constants.MAX_TIME)
                {
                    return(false);
                }
            }
            return(true);
        }