Ch-2Problem Solving
Ch-2Problem Solving
Environment
How the world evolves
What my actions do
What it will be like
if I do action A
What action I
Goals Actuators
should do now Actions
• The agent carries out its plans with its eyes closed
– Certain of what’s going on
– Open loop system
• Goal state:
– One of the buckets has two gallons of water in it
– Represented by either ( x 2 ) or ( 2 x )
• Path cost:
– 1 per unit step
January 26, 2003 AI: Chapter 3: Solving Problems 8
by Searching
Example: Water Pouring
• Actions and Successor Function
– Fill a bucket
• (x y) -> (3 y)
• (x y) -> (x 4)
– Empty a bucket
• (x y) -> (0 y)
• (x y) -> (x 0)
– Pour contents of one bucket into another
• (x y) -> (0 x+y) or (x+y-4, 4)
• (x y) -> (x+y 0) or (3, x+y-3)
January 26, 2003 AI: Chapter 3: Solving Problems 9
by Searching
Example: Water Pouring
(0,0)
(4,0) (0,3)
(1,0) (0,1)
(3,3) (4,2)
(4,1)
(2,3)
(2,0) (0,2)
• Breadth-first search
• Uniform-cost search
• Depth-first search
• Depth-limited search
• Iterative deepening search
January 26, 2003 AI: Chapter 3: Solving Problems 24
by Searching
Comparing Uninformed Search
Strategies
• Completeness
– Will a solution always be found if one exists?
• Time
– How long does it take to find the solution?
– Often represented as the number of nodes searched
• Space
– How much memory is needed to perform the search?
– Often represented as the maximum number of nodes stored at
once
• Optimal
– Will the optimal (least cost) solution be found?
B D A E
C E E B B F
11
D F B F C E A C G
14 17 15 15 13
G C G F
19 19 17
G 25
The performance measure of Bidirectional
search
Complete: Bidirectional search is complete.
Optimal: It gives an optimal solution.
Time and space complexity: Bidirectional
search has O(bd/2)
Disadvantage of Bidirectional Search
It requires a lot of memory space.
Global Maximum: It is the highest point on the hill, which is the goal state.
Local Maximum: It is the peak higher than all other peaks but lower than the
global maximum.
Flat local maximum: It is the flat area over the hill where it has no uphill or
downhill. It is a saturated point of the hill.
If he finds his next step better than the previous one, he continues to move else
remain in the same state.
If the CURRENT node=GOAL node, return GOAL and terminate the search.
Note: Both simple, as well as steepest-ascent hill climbing search, fails when
there is no closer node.
It selects one node at random and decides whether it should be expanded or
search for a better one.
It iteratively searches the node and selects the best one at each step until the
goal is not found.
If there are few plateaus, local maxima, and ridges, it becomes easy to reach the
destination.
83
Limitations of Hill climbing
algorithm
Local Maxima:
It is that peak of the mountain which is highest than all its neighboring states but
lower than the global maxima. It is not the goal peak because there is another peak
higher than it.
The evaluation function expands that node first, which has the lowest cost. A component of
f(n) is h(n) which carries the additional information required for the search algorithm, i.e.,
h(n)= estimated cost of the cheapest path from the current node n to the goal node.
Note: If the current node n is a goal node, the value of h(n) will be 0.
Initially, traverse the root node and visit its next successor nodes and place
them in the OPEN list in ascending order of their heuristic value.
Select the first successor node from the OPEN list with the lowest heuristic
value and expand further.
Now, rearrange all the remaining unexpanded nodes in the OPEN list and
repeat above two steps.
If the goal node is reached, terminate the search, else expand further.
The function g(n) is the path cost from the start/initial node to a
node n and h(n) is the estimated cost of the cheapest path from
node n to the goal node. Therefore, we have
f(n)=g(n)+h(n)
Underestimating the cost value means the cost we assumed in our mind is less
than the actual cost.
Overestimating the cost value means the cost we assumed is greater than the
actual cost, i.e.,
96
Here, h(n) is the actual heuristic cost
value and h’(n) is the estimated heuristic cost
value.
•But if the h(n) value is underestimated, it will try and reach the best optimal value of
h(n) which will lead to a good optimal solution.
We have two ways, either order food from any restaurant or buy some food
ingredients and cook to eat food.
Thus, we can apply any of the two ways, the choice depends on us.
It is not guaranteed whether the order will be delivered on time, food will be
tasty or not, etc.
Therefore, the AO* search provides two ways to choose either OR or AND.
A state-space