AI( Lec 3)
Informed Search
Uninformed and informed searches
• Based on the search problems we can classify the search algorithms into two major types:
– Uninformed search (Blind Search) Algorithms. – Informed search (Heuristic Search) Algorithms.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Uninformed Search algorithms
• These kind of algorithms does not contain any Knowledge of the domain such as how closeness to the goal or the location of the goal.
• They operate in a brute force way as it only includes information about how to traverse the tree and how to identify leaf and goals.
• Applies away in which search tree is searched without any information about the goal.
• They examine each node until it reaches the goal node and it can stop after that.
Examples
• Depth first search (DFS) • Breadth first search (BFS) • Uniform cost search (UCS)
• Depth limited search • Iterative Deeping depth first search • Bidirectional search
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Informed search Algorithms.
• They use domain knowledge, the problem information to the goal is available which can guide the search.
• Informed search strategies can find a solution more efficient than an uninformed search.
• Heuristic is away which might not always be guaranteed for the best solution but guaranteed to find a good solution in a reasonable time.
• They can solve much complex problem which could not be solved in other ways.
Examples
• Greedy Best First Search • A* Search • Hill climbing Search
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Heuristic Function
• Is a function that estimates how close is a state to a goal
• Designed for a particular search problem i.e: May differ from one problem to another
• Example: Euclidean distance or Manhattan distance for a path problem
• The accuracy of choosing the heuristic function affects the accuracy of the algorithm.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A heuristic function
• Let evaluation function h(n) (heuristic)
– h(n) = estimated cost of the cheapest path from node n to goal node.
– If n is goal then h(n)=0
Best First Search
• Uses an evaluation function f(n) for each node and the node to be expanded is the node n with the smallest f(n)
• Example: – A* Search – Greedy best first search
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A Quick Review
• g(n) = cost from the initial state to the current state n
• h(n) = estimated cost of the cheapest path from node n to a goal node
• f(n) = evaluation function to select a node for expansion (usually the lowest cost node)
Examples
• Greedy Best First Search • A* Search • Hill climbing Search
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Greedy best-first search
• Evaluation function f(n) = h(n) (heuristic) = estimate of cost from n to goal
• Ignores the path cost • Greedy best-first search expands the node that appears to be closest to goal
Properties of greedy best-first search
• Complete? – Not unless it keeps track of all states visited • Otherwise can get stuck in loops (just like DFS)
• Optimal?– No – we just saw a counter-example
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
A* Search Algorithm Evaluation function f(n) = h(n) + g(n) f(n) estimated total cost of path through n to goal
h(n) estimated cost to goal from n -g(n) cost so far to reach n (the node) A* Search finds the optimal path
A* uses admissible heuristics, i.e., h(n) ≤ h*(n) where h*(n) is the true cost from n. • Best-known form of best-first search.
• Idea: avoid expanding paths that are already expensive. • Combines uniform-cost and greedy search
• Implementation: Expand the node n with minimum f(n)
Properties of A*
• Complete? Yes (unless there are infinitely
many nodes with f ≤ f(G) )
• Optimal? Yes
• A* uses both backward costs and (estimates of) forward costs
• A* is optimal with admissible / consistent heuristics
• Heuristic design is key: often use relaxed problems
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Hill Climbing Search
• For artefact-only problems (don’t care about the path)
• Depends on some e(state) : – Hill climbing tries to maximise score e
• Randomly choose a state : – Only choose actions which improve e
– If cannot improve e, then perform a random restart (• Choose another random state to restart the search from)
• Only ever have to store one state (the present one) : – Can’t have cycles as e always improves
Hill Climbing - Algorithm
1. Pick a random point in the search space 2. Consider all the neighbors of the current state
3. Choose the neighbor with the best quality and move to that state 4. Repeat 2 thru 4 until all the neighboring states are of lower quality
5. Return the current state as the solution state
Hill-climbing search
• Looks one step ahead to determine if any successor is better than the current state; if there is, move to the best successor.
• Rule: If there exists a successor s for the current state n such that • h(s) < h(n) and • h(s) ≤ h(t) for all the successors t of n,
then move from n to s. Otherwise, halt at n.
• Similar to Greedy search in that it uses h(), but does not allow backtracking or jumping to any alternative path since it doesn’t “remember” where it has
been.
• If Hill climbing failed to find the goal it will start from another random node searching for the goal node(may choose the same failed node ).
Properties of Hill Climbing
• Complete? NO
• Optimal? NO
-------------------------------------------------------------------------------------------------------------------------------------------------
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
Current Queue
------------------------------------------------------------------------------------------------------------------------------------------------