/// <summary> /// expands a given node /// </summary> /// <param name="toExpand"></param> /// <param name="allChildren"></param> private void Expand(MddMatchAndPruneState toExpand, successorIterator allChildren) { allChildren.initialize(toExpand); MddMatchAndPruneState successor; while (allChildren.hasNext) { successor = allChildren.getNext(); if (closedList.ContainsKey(successor)) { closedList[successor].addParent(toExpand); } else { this.nodeSolver.matchCounter++; successor.addParent(toExpand); closedList.Add(successor, successor); openList.Enqueue(successor); if (successor.stateLevel + 1 == this.solutionDepth) { goal = successor; } } } }
/// <summary> /// Build the generalized MDD /// </summary> /// <returns>Whether it was successful</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); }