Consistent Heuristic Search - Tiebreaking Policy - search

So I have the following question in my midterm review and I'm not really sure how to go about it, it's the only one I couldn't figure out. The notation we used in class is that f(n) = g(n) + h(n)
g(n): Cost from start to current
h(n): Estimated cost from current to goal, given heuristic
C*: Optimal cost from start to goal
I know it has something to do with the fact that the heuristic is consistent and this property:
If an instance of A* uses a consistent heuristic, then A* will expand
every node n for which f(n) < C*.
Any help would be greatly appreciated.

Related

Time complexity of A* and Dijsktra's search

In a grid based environment, the number of edges E = O(V).
A* would, in the worst case, explore all the nodes of the grid.
So, number of nodes in open list would be E in the worst case.
Therefore, A's time complexity in worst case is O(E).
Now, as we know that Dijsktra's time complexity is O(E + VlogV).
And A* in worst case would explore same number of nodes as Dijkstra would explore.
Thus, the time complexity of A* should have been equal to Dijkstra = O(E).
But we have VlogV term extra in Dijkstra.
What am I missing here? I request for a detailed explanation.
Thanks in advance.

Pacman ai project - Suitable of combination of step cost and heuristic

As part of a project, I am trying to implement A* within the context of a pacman game (see UC Berkley pacman ai project). There are no ghosts or capsules, only a maze and the 'fruit'. I am having trouble, however, understanding the relationship between my heuristic function and my cost function.
As per the project, when defining the search problem, we need to specify a step cost that derives from:
score = -Nb Steps + 10*NbOfEatenDots + 200*NbOfEatenGhosts + (-500*isLoss) + (500*isWin)
This cost is supposed to be always positive and so, for simplicity, I have decided to take: 1.5 - (0.5*AteAFoodDot). I have ignored ghosts and capsules since they do not exist and I have given a preferential score for moves tht end up eating a dot. I have also ignored steps that result in a loss (since they do not exist) and steps that result in a win state.
Now as far as the A* algorithm itself is concerned, we have to implement a cost function and a heuristic function of our own:
As a cost function I have chosen: Cost = sum(step costs to current state) and as a heuristic: h = Manhattan distance between pacman and the dot closest to him + manhattan distance of this dot and another dot that is furthest away from it, as long as it exists, which is an admissible heuristic. I have also implemented this heuristic using real maze distances instead of manhattan distances, but this seemed too time consuming for mazes with many food dots.
Now if I have understood correctly if g(n) is my cost function and h(n) my heuristic, I must always have: g(n to goal) >= h(n) so that A* always returns an optimal path and the closest the values of g and h for a node n, the less nodes will be expanded.
In this respect, is it not in my interest to ignore how the score is computed, ignore the fact that a step results in eating a food dot or not and simply take step_cost = 1 for all steps?
This is how I obtain the best results with respect to computation time and nodes expanded, but ignoring the cost function of the game seems wrong.
Could someone clarify this for me? Is it a matter of rpeference/choice or is there an objective correct answer/best approach?

A* Search Advantages of Dynamic Weighting

I was reading about the variants of the A* search algorithm and I came across dynamic weighting. As I understand it, a weight is applied to the search equation, which decreases as the search gets closer to the goal node. I was specifically looking at this article : http://theory.stanford.edu/~amitp/GameProgramming/Variations.html
Can anyone tell me what the advantages of this would be? Why would you not care what nodes you expand at the start? Is it to help searches that don't necessarily have a good heuristic?
Thanks
For the TLDNR-crowd:
Dynamic weighting sacrifices solution optimality to speed up the search. The larger the weight, the more greedy the search.
For my fellow scholars:
Motivation
From the Wikipedia A-star article:
A-star's admissibility criterion guarantees an optimal solution path, but it also means that A* must examine all equally meritorious paths to find the optimal path. We can speed up the search at the expense of optimality by relaxing the admissibility criterion to obtain an approximate solution. Oftentimes we want to bound this relaxation, so that we can guarantee that the solution path is no worse than (1 + ε) times the optimal solution path. This new guarantee is referred to as ε-admissible.
Static Weighting
Before we talk about dynamic weighting, let's compare A-star to the simplest ε-admissible relaxation: static-weighted A-star.
In static-weighted A-star, f(n) = g(n) + w·h(n), with w=(1+ε) for some ε>0. To illustrate the effect on optimality and search speed, compare the number of nodes expanded in each of the following illustrations. Empty circles represent nodes in the open set; filled-in circles are in the closed set.
A-star (left) vs. Weighted A-star with ε=4 (right)
As you can see, weighted A-star expanded far fewer nodes and completed about 3x as fast. However, since we used ε=4, weighted A-star could theoretically return a solution that is (1+ε)=(1+4)=5x times as long as the optimal path.
Dynamic Weighting
Dynamic Weighting is a technique that makes the heuristic weight a function of the search state, i.e. f(n) = g(n) + w(n)·h(n), where w(n) = (1 + ε - (ε*d(n))/N), d(n) is the depth of the current search and N is an upper bound on the search depth.
In this way, dynamic-weight A-Star initially behaves very much like a Greedy Best First search, but as the search depth (i.e. the number of hops in the graph) increases, the algorithm takes a more conservative approach, behaving more like the traditional A-star algorithm.
Amit Patel's page says
With dynamic weighting, you assume that at the beginning of your
search, it’s more important to get (anywhere) quickly; at the end of
the search, it’s more important to get to the goal.
He is correct, but I would saythat with dynamic weighting, you assume that at the beginning of your search, it's more important to follow your heuristic; at the end of the search, it becomes equally important to consider the length of the path, too.
Additional Materials and Links:
Asst. Prof. Ira Pohl -- The Avoidance of (Relative)
Catastrophe, Heuristic Competence, Genuine DYnamic Weighting and
Computational Issues in Heuristic Problem Solving
Dynamic Weighting on Amit Patel's Variants of A*
Wikipedia -- Bounded Relaxation for the A* Search Algorithm

What is the difference between uniform-cost search and best-first search methods?

Both methods have a data structure which holds the nodes (with their cost) to expand. Both methods first expand the node with the best cost. So, what is the difference between them?
I was told that uniform-cost search is a blind method and best-first search is not, which confused me even more (both have information about node costs or not?).
The difference is in the heuristic function.
Uniform-cost search is uninformed search: it doesn't use any domain knowledge. It expands the least cost node, and it does so in every direction because no information about the goal is provided. It can be viewed as a function f(n) = g(n) where g(n) is a path cost ("path cost" itself is a function that assigns a numeric cost to a path with respect to performance measure, e.g. distance in kilometers, or number of moves etc.). It simply is a cost to reach node n.
Best-first search is informed search: it uses a heuristic function to estimate how close the current state is to the goal (are we getting close to the goal?). Hence our cost function f(n) = g(n) is combined with the cost to get from n to the goal, the h(n) (heuristic function that estimates that cost) giving us f(n) = g(n) + h(n). An example of a best-first search algorithm is A* algorithm.
Yes, both methods have a list of expanded nodes, but best-first search will try to minimize that number of expanded nodes (path cost + heuristic function).
There is a little misunderstanding in here. Uniform cost search, best first search and A* search algorithms are all different algorithms. Uniform cost is an uninformed search algorithm when Best First and A* search algorithms are informed search algorithms. Informed means that it uses a heuristic function for deciding the expanding node. Difference between best first search and A* is that best first uses f(n) = h(n) for expanding and A* uses f(n) = g(n)+h(n) for choosing the expanding node. h(n) is the heuristic function. g(n) is the actual cost from starting node to node n.
https://www.cs.utexas.edu/~mooney/cs343/slide-handouts/heuristic-search.4.pdf It can be seen here with more details.
Slight correction to the accepted answer
Best-first search does not estimate how close to goal the current state is, it estimates how close to goal each of the next states will be (from the current state) to influence the path selected.
Uniform-cost search expands the least cost node (regardless of heuristic), and best-first search expands the least (cost + heuristic) node.
f(n) is the cost function used to evaluate the potential nodes to
expand
g(n) is the cost of moving to a node n
h(n) is the estimated
cost that it will take to get to the final goal state from if we were
to go to n
The f(n) used in uniform-cost search
f(n) = g(n)
The f(n) used in best-first search (A* is an example of best-first search)
f(n) = h(n)
The f(n) used in A* search.
Note: The h(n) from best-first search above is expanded in A* so that it always includes g(n). It is still basically just a heuristic, but it is a heuristic that includes g(n).
f(n) = g(n) + h(n).
Each of these functions is evaluating the potential expansion nodes, not the current node when traversing the tree looking for an n that is a goal state
The differences are given below:
Uniform-cost search (UCS) expands the node with lowest path cost (i.e. with the lowest g(n)), whereas best-first search (BFS) expand the node with closest to the goal
UCS cannot deal with a heuristic function, whereas BFS can deal with a heuristic function
In UCS, f(n) = g(n), whereas, in BFS, f(n) = g(n) + h(n).
Uniform-cost search picks the unvisited node with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if smaller.
Best-first search is an heuristic-based algorithm that attempts to predict how close the end of a path (i.e. the last node in the path) is to the goal node, so that paths which are judged to be closer to a solution are expanded first.

How is the max of a set of admissible heuristics, a dominating heuristic?

If you have a set of admissible heuristics: h1,h2,h2,...,hn
How is h = max(h1,h2,h2,...,hn) an admissible heuristic that dominates them all?
Isn't a lower h(n) value better?
For A*, f = g + n, and the element with the lowest f will be removed from the list. So shouldn't taking the min give the dominating heuristic?
An admissible heuristic never overestimates the cost of reaching the goal state. That is, its estimate will be lower than the actual cost or exactly the actual cost, but never higher. This is required for greedy approaches like A* search to find the global best solution.
For example, imagine you found a solution with cost 10. The best solution has cost 8. You're not using an admissible heuristic, and the estimate of the heuristic for the solution that really has cost 8 is 12 (it's overestimating). As you already have a solution with cost 10, A* will never evaluation the best solution as it is estimated to be more expensive.
Ideally, your heuristic should be as accurate as possible, i.e. an admissible heuristic shouldn't underestimate the true cost too much. If it does, A* will still find the best solution eventually, but it may take a lot longer to do so because it tries a lot of solutions that look good according to your heuristic, but turn out to be bad.
This is where the answer for your question lies. Your heuristics h1, ..., hn are all admissible, therefore they estimate a cost equal to or less than the true cost. The maximum of this set of estimates is therefore by definition the estimate that is closest to the actual cost (remember that you'll never overestimate). In the ideal case, it will be the exact cost.
If you were to take the minimum value, you would end up with the estimate that is furthest away from the actual cost -- as outlined above, A* would still find the best solution, but in a much less efficient manner.

Resources