/** * Return the best node from a list according to the heuristic value. * * @param nodes the list containing nodes. * @return the best node from the nodes' list. */ private Node popBestNode(Collection<Node> nodes) { Node node = null; if (!nodes.isEmpty()) { final Iterator<Node> i = nodes.iterator(); node = i.next(); while (i.hasNext()) { final Node next = i.next(); if (next.getHeuristic() < node.getHeuristic()) { node = next; } } nodes.remove(node); } return node; } }
/** * Return the best node from a list according to the heuristic value. * * @param nodes the list containing nodes. * @return the best node from the nodes' list. */ private Node popBestNode(Collection<Node> nodes) { Node node = null; if (!nodes.isEmpty()) { final Iterator<Node> i = nodes.iterator(); node = i.next(); while (i.hasNext()) { final Node next = i.next(); if (next.getHeuristic() < node.getHeuristic()) { node = next; } else if (Math.abs(next.getHeuristic() - node.getHeuristic()) < .001 && !restartList.contains(next)) { restartList.addLast(next); } } nodes.remove(node); } return node; } }
/** * Get a node from a list of nodes. * * @param states the list of nodes (successors). * @return the node from the list. */ private Node popPriorityNode(Collection<Node> states) { Node state = null; if (!states.isEmpty()) { final Iterator<Node> i = states.iterator(); state = i.next(); while (i.hasNext()) { final Node next = i.next(); if (next.getHeuristic() < state.getHeuristic()) { state = next; } } states.remove(state); } return state; } }
/** * Get a node from a list of nodes. * * @param states the list of nodes (successors). * @return the node from the list. */ private Node popPriorityNode(Collection<Node> states) { Node state = null; if (!states.isEmpty()) { final Iterator<Node> i = states.iterator(); state = i.next(); while (i.hasNext()) { final Node next = i.next(); if (next.getHeuristic() < state.getHeuristic()) { state = next; } } states.remove(state); } return state; } }
openList.add(root); double bestHeuristic = root.getHeuristic(); final Node successor = successors.pop(); this.setExploredNodes(this.getExploredNodes() + 1); final double heuristicSuccessor = successor.getHeuristic(); if (heuristicSuccessor == 0.0) { solution = successor;
returnedSolution.getCost(), returnedSolution.getDepth(), returnedSolution.getHeuristic())); bound = returnedSolution.getCost(); solution = returnedSolution;
current.getCost(), current.getDepth(), current.getHeuristic())); solution = current; fireSolution(new SolutionEvent(this, solution, problem));
current.getCost(), current.getDepth(), current.getHeuristic())); solution = current; fireSolution(new SolutionEvent(this, solution, problem));