Professional Documents
Culture Documents
Unie 2
Unie 2
Unit -2
Problems, State Space Search &
Heuristic Search Techniques
• A state space is a way to mathematically represent a problem by defining all the possible states
in which the problem can be.
• This is used in search algorithms to represent the initial state, goal state, and current state of the
problem.
• State:
A state can be an Initial State, a Goal State, or any other possible state that can be generated by
applying rules between them.
• Space:
In an AI problem, space refers to the exhaustive collection of all conceivable states.
• Search:
This technique moves from the beginning state to the desired state by applying good rules while
traversing the space of all possible states.
• Search Tree:
To visualize the search issue, a search tree is used, which is a tree-like structure that represents
the problem. The initial state is represented by the root node of the search tree, which is the
starting point of the tree.
• Transition Model:
This describes what each action does, while Path Cost assigns a cost value to each path, an
activity sequence that connects the beginning node to the end node. The optimal option has the
lowest cost among all alternatives.
• These rules are a basic representation found helpful in expert systems, automated planning, and action
selection.
• Production systems are made up of a set of production rules. Each rule has a condition and an action.
The condition is tested to see if it is true. If the condition is true, the action is carried out.
• Production systems are used to create programs that can solve problems.
• The rules in the production system are used to find a solution to the problem. The production system
can be thought of as a set of instructions for solving a problem.
• 2. Test to see if this is actually a solution by comparing the chosen point or the
endpoint of the chosen path to the set of acceptable goal states.
• Find the route the salesman should follow for the shortest possible round trip that both starts and
finishes at any one of the cities.
• – Traveler needs to visit n cities.
• – Know the distance between each pair of cities.
• – Want to know the shortest route that visits all the cities once.
Length of
Search for Path
Path
1 ABCD 19
2 ABDC 18
3 ACBD 12
4 ACDB 13
5 ADBC 16
Continued
– Problem Decomposition
– A* , Generate & Test
BFS DFS
• Greedy approach: This means that it moves in a direction in which the cost function
is optimized.
• No Backtracking: A hill-climbing algorithm only works on the current state and
succeeding states (future). It does not look at the previous states.
• Feedback mechanism: The algorithm has a feedback mechanism that helps it decide
on the direction of movement (whether up or down the hill). The feedback
mechanism is enhanced through the generate-and-test technique.
• An ‘Open’ list that keeps track of the current ‘immediate’ nodes available for traversal and a
‘CLOSED’ list that keeps track of the nodes already traversed.
• Start from the initial node and add it to the ordered open list
• Next the below steps are repeated until the final node or endpoint is reached
– If the open list is empty exit the loop and return a False statement which says that the final node cannot be
reached
– Select the top node in the open list and move it to the closed list while keeping track of the parent node
– If the node removed is the endpoint node return a True statement meaning a path has been found and moving
the node to the closed list
• “You are given two jugs, a 4-liter one and a 3-liter one. Neither has any measuring
markers on it. There is a pump that can be used to fill the jugs with water. How can you
get exactly 2 liters of water into a 4-liter jug.”
• State: (x, y)
• where x represents the quantity of water in a 4-liter jug and y represents the quantity of
water in a 3-liter jug.
• That is, x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
• Start state: (0, 0).
• Goal state: (2, n) for any n.
• Here need to start from the current state and end up in a goal state.
• (4, 2) – Rule 7, Pour water from 3-liter jug into the 4-liter jug until the 4-liter jug is full.
• (0, 2) – Rule 5, Empty the 4-liter jug on the ground
• (2, 0) – Rule 9, Pour all the water from the 3-liter jug into the 4-liter jug.
1 (x, y) is X<4 ->(4, Y) Fill the 4-liter jug Pour all the water from
(x, y) if X+Y <=4
2 (x, y) if Y<3 -> (x, 3) Fill the 3-liter jug 9 the 3-liter jug into the
and y>0 -> (x+y, 0)
(x, y) if x>0 -> (x-d, 4-liter jug.
3 Pour some water out of the 4-liter jug.
d) Pour all the water from
(x, y) if X+Y<=3
(x, y) if Y>0 -> (d, 10 the 4-liter jug into the
4 Pour some water out of the 3-liter jug. and x>0 -> (0, x+y)
y-d) 3-liter jug.
5 (x, y) if x>0 -> (0, y) Empty the 4-liter jug on the ground Pour the 2-liter water
6 (x, y) if y>0 -> (x,0) Empty the 3-liter jug on the ground 11 (0, 2) -> (2, 0) from the 3-liter jug into
the 4-liter jug.
(x, y) if X+Y >= 4
Pour water from the 3-liter jug into the Empty the 2-liter in the
7 and y>0 -> (4,
4-liter jug until the 4-liter jug is full 12 (2, Y) -> (0, y)
y-(4-x)) 4-liter jug on the ground.
(x, y) if X+Y>=3 and Pour water from the 4-liter jug into the
8
x>0 -> (x-(3-y), 3)) 3-liter jug until the 3-liter jug is full.
Artificial Intelligence (3170716)
Constraint Satisfaction
• Many AI problems can be viewed as problems of constraint satisfaction.
• For example, Crypt-arithmetic puzzle:
• As compared with a straightforward search procedure, viewing a problem as one of the constraint satisfaction can
substantially reduce the amount of search.
• Two-step process:
– If there is still not a solution, then search begins, adding new constraints.
• Initial state contains the original constraints given in the problem.
Example: The goal is to discover some problem state that satisfies the given set of constraints.
• If SUCCESSOR was not on OPEN, see if it is on CLOSED. If so, call the node on CLOSED OLD and add OLD to
the list of BESTNODE’s successors.
• If SUCCESSOR was not already on either OPEN or CLOSED, then put it on OPEN and add it to the list of
BESTNODE’s successors.
Compute f’(SUCCESSOR) = g(SUCCESSOR) + h’(SUCCESSOR)
• This decomposition or reduction generates arcs that we call AND arcs. One AND arc may point to any numbers
of successor nodes. All of which must then be solved in order for the arc to point solution.
• In order to find solution in an AND-OR graph we need an algorithm similar to best –first search but with the
ability to handle the AND arcs appropriately.
• We define FUTILITY, if the estimated cost of solution becomes greater than the value of FUTILITY then we
abandon the search, FUTILITY should be chosen to correspond to a threshold.
• The propagation of revised cost estimation backward is in the tree is not necessary in A*
algorithm. This is because in AO* algorithm expanded nodes are re-examined so that the
current best path can be selected.
Advantages of AO*:
It is Complete
Will not go in infinite loop
Less Memory Required
Disadvantages of AO*:
It is not optimal as it does not explore all the path once it find a solution.
Artificial Intelligence (3170716)
What is the difference between A* Algorithm and AO*
algorithm?
• A* algorithm provides with the optimal solution, whereas AO* stops when it finds
any solution.
• AO* algorithm requires lesser memory compared to A* algorithm.
• AO* algorithm doesn't go into infinite loop whereas the A* algorithm can go into an
infinite loop.
– a set of operate with a set of preconditions their application and difference functions that computes the
– difference between two state a(i) and s(j).
• The puzzle consists of N tiles and one empty space where the tiles can be
moved.
• Start and Goal configurations (also called state) of the puzzle are provided.
• The puzzle can be solved by moving the tiles one by one in the single empty
space and thus achieving the Goal configuration.
Artificial Intelligence (3170716)
Thank
You!