Problem solving AI
Problem solving AI
Together, the initial state, actions, and transition model implicitly define
the state space of the problem—the set of all states reachable from the
initial state by any sequence of actions.
Simple algorithm for any search problem:
Disadvantages:
• Depth-limited search also has a disadvantage of incompleteness.
• It may not be optimal if the problem has more than one solution.
4. Iterative deepening depth-first Search
• This algorithm performs depth-first search up to a certain "depth limit",
and it keeps increasing the depth limit after each iteration until the goal
node is found.
• This Search algorithm combines the benefits of Breadth-first search's fast
search and depth-first search's memory efficiency.
• The iterative search algorithm is useful uninformed search when search
space is large, and depth of goal node is unknown.
• 1'st Iteration-----> A
2'nd Iteration----> A, B, C
3'rd Iteration------>A, B, D, E, C, F, G
4'th Iteration------>A, B, D, H, I, E, C, F, K, G
In the fourth iteration, the algorithm will find the goal node.
Advantages
• IDDFS gives us the hope to find the solution if it exists in the tree.
• IDS's ability to be utilized for both tree and graph search is its third
benefit. This is due to the fact that IDS is a generic search algorithm that
works on any search space, including a tree or a graph.
Disadvantages
• The time taken is exponential to reach the goal node.
• The main problem with IDDFS is the time and wasted calculations that
take place at each depth.
5. Uniform-cost Search Algorithm:
• Bidirectional search can use search techniques such as BFS, DFS, DLS, etc.
Heuristics function:
• Heuristic is a function which is used in Informed Search, and it
finds the most promising path.
• It might not always give the best solution, but it guaranteed to find
a good solution in reasonable time.
Admissibility of the heuristic function is given as:
h(n) <= h*(n)
Here h(n) is heuristic cost, and h*(n) is the estimated cost. Hence
heuristic cost should be less than or equal to the estimated cost.
Pure Heuristic Search:
Greedy best-first search algorithm always selects the path which appears best
at that moment. With the help of best-first search, at each step, we can
choose the most promising node.
Best first search algorithm:
• Step 1: Place the starting node into the OPEN list.
• Step 2: If the OPEN list is empty, Stop and return failure.
• Step 3: Remove the node n, from the OPEN list which has the lowest
value of h(n), and places it in the CLOSED list.
• Step 4: Expand the node n, and generate the successors of node n.
• Step 5: Check each successor of node n, and find whether any node is
a goal node or not. If any successor node is goal node, then return
success and terminate the search, else proceed to Step 6.
• Step 6: For each successor node, algorithm checks for evaluation
function f(n), and then check if the node has been in either OPEN or
CLOSED list. If the node has not been in both list, then add it to the
OPEN list.
• Step 7: Return to Step 2.
• Advantages:
– Best first search can switch between BFS and DFS by gaining the
advantages of both the algorithms.
– This algorithm is more efficient than BFS and DFS algorithms.
• Disadvantages:
– It can behave as an unguided depth-first search in the worst case
scenario.
– It can get stuck in a loop as DFS.
– This algorithm is not optimal.
• In this search example, we are using two lists which are OPEN and CLOSED Lists.
Following are the iteration for traversing the above example.
• Expand the nodes of S and put in the CLOSED list
• Initialization: Open [A, B], Closed [S]
• Iteration 1: Open [A], Closed [S, B]
• Iteration 2: Open [E, F, A], Closed [S, B]
: Open [E, A], Closed [S, B, F]
• Iteration 3: Open [I, G, E, A], Closed [S, B, F]
: Open [I, E, A], Closed [S, B, F, G]
• Hence the final solution path will be: S----> B----->F----> G
• Time Complexity: The worst case time complexity of Greedy best first search is
O(bm).
• Space Complexity: The worst case space complexity of Greedy best first search is
O(bm). Where, m is the maximum depth of the search space.
• Complete: Greedy best-first search is also incomplete, even if the given state
space is finite.
• Optimal: Greedy best first search algorithm is not optimal.
2. A* Search Algorithm:
• It uses heuristic function h(n), and cost to reach the node n from the start
state g(n).
• A* search algorithm finds the shortest path through the search space using
the heuristic function.
• This search algorithm expands less search tree and provides optimal result
faster
• In A* search algorithm, we use search heuristic as well as the cost to reach
the node. Hence we can combine both costs as following, and this sum is
called as a fitness number.
• At each point in the search space, only those node is expanded which have
the lowest value of f(n)
Algorithm of A* search:
Disadvantages:
• It does not always produce the shortest path as it mostly
based on heuristics and approximation.
• A* search algorithm has some complexity issues.
• The main drawback of A* is memory requirement as it
keeps all generated nodes in the memory, so it is not
practical for various large-scale problems.
Optimal: A* search algorithm is optimal if it follows below two conditions: