Confusion on UCS's `evaluation_function()`

    def evaluation_function(self, node_current: PriorityNode) -> float:
        """
        Evaluation function of UCS is f(n) = g(n)
        """

        # calculate g(n)
        if self.reached_goal(node_current.list_paths[-1]):
            node_current.list_paths = self.remove_states_behind_goal(node_current.list_paths)
        node_current.priority += (len(node_current.list_paths[-1]) - 1) * self.scenario.dt

        return node_current.priority

From the doc in code, f(n) = g(n). I think g(n) should be the length of current path(or number_steps * step_time = total_time). Why there is += operator instead of =?

g(n) is an accumulated value over time (in the current definition). In this case, a child node computes its value on top of its parent node. You can compare this evaluation function with that of the A* search: the heuristic h(n) there is only dependent on the child node.

Thx for replying.

If g(n) is accumulated value over time, it should be the total time spent along the path to current node? node_current.priority = (len(node_current.list_paths[-1]) - 1) * self.scenario.dt, the right side of this assignment is the total time, instead of node_current.priority += (len(node_current.list_paths[-1]) - 1) * self.scenario.dt.

Or, I misunderstood it. g(n) is just a value that increases by the total_time of child node’s path each time a new child node is found, and doesn’t have direct physical meaning.