0% found this document useful (0 votes)
2 views

Final Chapter 3 -3.1-3.2

The document discusses problem-solving in AI through state-space search, emphasizing the importance of defining the problem, search space, and transition rules. It outlines the process of finding a path from an initial state to a goal state, with optimal solutions being those with the least path cost. The Water Jug Problem is presented as an example to illustrate the concepts of state space and production rules in problem-solving.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Final Chapter 3 -3.1-3.2

The document discusses problem-solving in AI through state-space search, emphasizing the importance of defining the problem, search space, and transition rules. It outlines the process of finding a path from an initial state to a goal state, with optimal solutions being those with the least path cost. The Water Jug Problem is presented as an example to illustrate the concepts of state space and production rules in problem-solving.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 48

Solving Problems by

Searching
CHAPTER 3 (3.1,3.2)

CMPT 310 - Blind Search 1


Problem Solving through AI

• Problem:
• It is the question which is to be solved
• For solving a problem it needs to be precisely defined
• Problem definition means, defining the start goal, goal state,
other valid states and transition rules

Problem solving  Searching for a goal state

2
Problem Solving through AI

• The method of solving problem through AI involves the


process of defining the search space, deciding start and
goal states and then finding the path from start state to
goal state through search space

3
Solution of the problem

• A solution of the problem is a path from initial state to


goal state. The movement from start states to goal
states is guided by transition rules.
• Among all the solutions, whichever solution has least
path cost is called optimal solution

4
Method of solving problems through
AI techniques
• It involves the process of defining the search space,
deciding about start and goal state and then finding a
path from start state to goal state through search
space
• The search techniques are methods which are used to
find a way from start to goal state

5
Search Space & Search

• Search space: It is the complete set of states


including start and goal states, where the answer of the
problem is to be searched
• Search: It is the process of finding the solution in
search space. The input to search space algorithm is
problem and output is solution in form of action
sequences

6
Search Through State-Space

Goal state

Initial state

7
Production rules

• The movement from start state to goal state is guided


by set of rules specifically designed for that particular
problem (sometimes called production rules)
• The production rules are nothing but valid moves
described by the problems

8
Defining the problem as a state
space search
• Problem solving  Searching for a goal state
• The state space representation forms the basis of most
of the AI problems
• Search is a very important process in the solution of
hard problems for which no more direct techniques are
available.

10
State Space Search
1. Define a state space that contains all the possible
configurations of the relevant objects.
2. Specify the initial states.
3. Specify the goal states.
4. Specify a set of rules:
 What are unstated assumptions?
 How general should the rules be?
 How much knowledge for solutions should be in
the rules?

11
A problem solving agent is an agent which considers a
sequence of actions that forms a path to reach to the
goal state. Means it is an agent that facilitates to
obtain the final solution of the problem.

CMPT 310 - Blind Search 12


CMPT 310 - Blind Search 13
CMPT 310 - Blind Search 14
• Means problem is formulated after the goal formulation

CMPT 310 - Blind Search 15


Problem Definition/Formulation

CMPT 310 - Blind Search 16


CMPT 310 - Blind Search 17
CMPT 310 - Blind Search 18
CMPT 310 - Blind Search 19
CMPT 310 - Blind Search 20
CMPT 310 - Blind Search 21
CMPT 310 - Blind Search 22
CMPT 310 - Blind Search 23
CMPT 310 - Blind Search 24
CMPT 310 - Blind Search 25
Abstraction: The process of removing details from a
representation CMPT 310 - Blind Search 26
CMPT 310 - Blind Search 27
CMPT 310 - Blind Search 28
CMPT 310 - Blind Search 29
CMPT 310 - Blind Search 30
CMPT 310 - Blind Search 31
CMPT 310 - Blind Search 32
CMPT 310 - Blind Search 33
CMPT 310 - Blind Search 34
CMPT 310 - Blind Search 35
CMPT 310 - Blind Search 36
State Space Search
1. Define a state space that contains all the possible
configurations of the relevant objects.
2. Specify the initial states.
3. Specify the goal states.
4. Specify a set of rules:
 What are unstated assumptions?
 How general should the rules be?
 How much knowledge for solutions should be in
the rules?

39
Famous Problems for Illustrating AI
Concepts
• Water Jug Problem
• Chess Problem
• 8-Puzzle Problem
• Tower of Hanoi Problem
• Traveling Salesperson Problem

40
State Space Search: Water Jug Problem
“You are given two jugs, a 4-gallon (litre) one and a 3-
gallon (litre) one. Neither has any measuring markers
on it. There is a pump (tap) that can be used to fill the
jugs with water. How can you get exactly 2 litres of
water into 4-litre jug.”

3 liters 4 liters
41
Water Jug Problem

State space: set of ordered pairs of integers (x, y) such at x =


0,1,2,3, or 4 for amount of water in 4-gallon jug, and y = 0, 1, 2, or
3 for amount of water in the 3-gallon jug.
The start state is (0,0).
The goal state is (2,n) for any value of n.
The operators are represented as rules whose left sides are
matched against the current state and whose right rules describe
the new state that results from applying the rule. Explicit
assumptions required: we can fill a jug from the pump, we can
pour water out of a jug onto the ground, we can pour water from
one jug to the other, and there are no other measuring devices
available.

42
State Space Search: Water Jug Problem

• State: (x, y) i.e


Where X is gallons of water in 4 gallon jug
& y is gallons of water in 3 gallon jug

• x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
• Start state: (0, 0).
• Goal state: (2, n) for any n.
• Attempting to end up in a goal state.

43
Water Jug Problem: A State
Space Search
Control structure needed that loops through a cycle in which a rule
whose left side matches the current state is chosen, an appropriate
change is made to the state as described in the right side of the
rule, and the resulting state is checked to see if it corresponds to a
goal state.
Production rules for Water Jug Problem
1. (x, y)  (4, y)
if x  4
2. (x, y)  (x, 3)
if y  3
3. (x, y)  (x  d, y)
if x  0
4. (x, y)  (x, y  d)
if y  0

45
Production rules for Water Jug Problem
5. (x, y)  (0, y)
if x  0
6. (x, y)  (x, 0)
if y  0
7. (x, y)  (4, y  (4  x))
if x  y  4, y  0
8. (x, y)  (x  (3  y), 3)
if x  y  3, x  0

46
Production rules for Water Jug Problem
9. (x, y)  (x  y, 0)
if x  y  4, y  0
10. (x, y)  (0, x  y)
if x  y  3, x  0
11. (0, 2)  (2, 0)

12. (2, y)  (0, y)

47
Production rules for Water Jug
Problem

48
Production rules for Water Jug
Problem

49
State Space Search: Water Jug Problem
1. Current state = (0, 0)
2. Loop until reaching the goal state (2, 0)
 Apply a rule whose left side matches
the current state
 Set the new current state to be the
resulting state
(0, 0)
(0, 3)
(3, 0)
(3, 3)
(4, 2)
(0, 2)
(2, 0)

50
One Solution to the Water jug
Problem

51

You might also like