getPathCost() public method

public getPathCost ( ) : double
return double
Example #1
0
 /**
  *
  * @param n
  * @return the cost, traditionally denoted by g(n), of the path from the
  *         initial state to the node, as indicated by the parent pointers.
  */
 public double g(Node n)
 {
     return(n.getPathCost());
 }
Example #2
0
 /**
  * 
  * @param n
  * @return the cost, traditionally denoted by g(n), of the path from the
  *         initial state to the node, as indicated by the parent pointers.
  */
 public double g(Node n)
 {
     return n.getPathCost();
 }
        //
        // PRIVATE METHODS
        //

        // function RECURSIVE-DLS(node, problem, limit) returns a solution, or
        // failure/cutoff
        private List<Action> recursiveDLS(Node node, Problem problem, int limit)
        {
            // if problem.GOAL-TEST(node.STATE) then return SOLUTION(node)
            if (SearchUtils.isGoalState(problem, node))
            {
                setPathCost(node.getPathCost());
                return SearchUtils.actionsFromNodes(node.getPathFromRoot());
            }
            else if (0 == limit)
            {
                // else if limit = 0 then return cutoff
                return cutoff();
            }
            else
            {
                // else
                // cutoff_occurred? <- false
                bool cutoff_occurred = false;
                // for each action in problem.ACTIONS(node.STATE) do
                foreach (Node child in this.expandNode(node, problem))
                {
                    // child <- CHILD-NODE(problem, node, action)
                    // result <- RECURSIVE-DLS(child, problem, limit - 1)
                    List<Action> result = recursiveDLS(child, problem, limit - 1);
                    // if result = cutoff then cutoff_occurred? <- true
                    if (isCutOff(result))
                    {
                        cutoff_occurred = true;
                    }
                    else if (!isFailure(result))
                    {
                        // else if result != failure then return result
                        return result;
                    }
                }

                // if cutoff_occurred? then return cutoff else return failure
                if (cutoff_occurred)
                {
                    return cutoff();
                }
                else
                {
                    return failure();
                }
            }
        }