class AStarEvaluationFunction(EvaluationFunction): """ Function that evaluate path cost from initial state to a goal state if path from root node to the current node is used. """ def __init__(self, heuristic_function): self._heuristic_function = heuristic_function self._path_cost_function = PathCostFunction() def f(self, node): """ f(n) = g(n) + h(n) Where: f(n) - result of this function g(n) - cost of a path from initial state to a current state h(n) - approximation of a path cost from a current state to a goal state :param (Node) node: node that is used to calculate evaluation function """ return self._path_cost_function.g(node) + self._heuristic_function.h(node.get_state())
class AStarEvaluationFunction(EvaluationFunction): """ Function that evaluate path cost from initial state to a goal state if path from root node to the current node is used. """ def __init__(self, heuristic_function): self._heuristic_function = heuristic_function self._path_cost_function = PathCostFunction() def f(self, node): """ f(n) = g(n) + h(n) Where: f(n) - result of this function g(n) - cost of a path from initial state to a current state h(n) - approximation of a path cost from a current state to a goal state :param (Node) node: node that is used to calculate evaluation function """ return self._path_cost_function.g(node) + self._heuristic_function.h( node.get_state())
def __init__(self, heuristic_function): self._heuristic_function = heuristic_function self._path_cost_function = PathCostFunction()