0% found this document useful (0 votes)
126 views19 pages

FAI - Unit-2 - State Space Search & Heuristic Search Techniques

The document discusses problem solving and state space representation. It defines key concepts like states, state space, initial and goal states. It provides examples like playing chess, the water jug problem, and the 8 puzzle problem to illustrate defining the problem as a state space search. Production rules are specified to represent the possible state transitions. Characteristics of problems that impact solving them are also listed.

Uploaded by

SR SR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
126 views19 pages

FAI - Unit-2 - State Space Search & Heuristic Search Techniques

The document discusses problem solving and state space representation. It defines key concepts like states, state space, initial and goal states. It provides examples like playing chess, the water jug problem, and the 8 puzzle problem to illustrate defining the problem as a state space search. Production rules are specified to represent the possible state transitions. Characteristics of problems that impact solving them are also listed.

Uploaded by

SR SR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Problem and Problem Solving

 The steps that are required to build a system to solve a particular problem are:
1. Problem Definition that must include precise specifications of what the initial situation will be, as well as
what final situations constitute acceptable solutions to the problem.
2. Problem Analysis, this can have immense impact on the appropriateness of various possible techniques for
solving the problem.
3. Isolate and Represent the task knowledge required to solve the problem.
4. Selection of the best technique(s) for solving the particular problem.

 Problem solving is a process of generating solutions from the observed data.


State and State Space Representation
 A state is a representation of problem elements at a given moment.
 A state space is the set of all possible states reachable from the initial state.
 A state space forms a graph in which the nodes are states and the arcs between nodes are
actions.
 In a state space, a path is a sequence of states connected by a sequence of actions.
 The solution of a problem is a part of the graph formed by the state space.

Chess - Initial Position Position after a legal move


Define the Problem as State Space Search
 To provide a formal description of a problem, we need to do the following:
1. Define a state space that contains all the possible configurations of the relevant objects.
2. Specify one or more states that describe possible situations, from which the problem solving process may
start. These states are called initial states.
3. Specify one or more states that would be acceptable solution to the problem. These states are called goal
states.
 Specify a set of rules that describe the actions (operators) available.
 The problem can then be solved by using the rules, in combination with an appropriate control
strategy, to move through the problem space until a path from an initial state to a goal state is
found. This process is known as ‘search’.
State Space Representation - Play Chess
 Consider the problem of “Playing Chess”, to build a program that could play chess, we have to
specify,
1. The starting position of the chess board,
2. The rules that define legal moves.
3. And the board position that represent a win.

1. Initial Position of the chess board : The starting position can be described by an 8 X 8 array
square in which each element square (x, y) describes the board position of an appropriate
piece in the official chess opening position.
State Space Representation - Play Chess
2. The rules that define legal moves
 The legal moves provide the way of getting from initial state of final state.
 It can be described as a set of rules consisting of two parts: A left side that gives the current position and
the right side that describes the change to be made to the board position.

3. The board position that represents a win


 The goal is any board position in which the opponent does not have a legal move and his or her “king” is
under attack.
State Space Representation – Water Jug
 Problem Definition: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which
has unlimited water which you can use to fill the jug, and the ground on which water may be
poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of
water in the 4-gallon jug?

1. Initial State
 We will represent a state of the problem as a tuple (x, y), where x represents the amount of water in the 4-
gallon jug and y represents the amount of water in the 3-gallon jug.
 Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.
 Here the initial state is (0, 0). The goal state is (2, n) for any value of n.
State Space Representation – Water Jug
2. Production Rules

Sr. Current state Next state Description

1 (x, y) If x<4 (4, y) fill the 4- gallon jug

2 (x, y) If y<3 (x,3) fill the 3-gallon jug

3 (x, y) If x>0 (x-d, y) pour some water out of the 4- gallon jug

4 (x, y) If y>0 (x, y-d) pour some water out of the 3- gallon jug

5 (x, y) If x>0 (0, y) empty the 4- gallon jug on the ground

6 (x, y) If y>0 (x, 0) empty the 3- gallon jug on the ground


State Space Representation – Water Jug
2. Production Rules

Sr. Current state Next state Description

7 (x, y) If x + y >= 4 & y>0 (4,y-(4-x)) pour water from the 3- gallon jug
into the 4-gallon jug until the 4-
gallon jug is full

8 (x, y) If x + y >= 3 & x>0 (x-(3-y),3)) pour water from the 4- gallon jug
into the 3-gallon jug until the 3-
gallon jug is full

9 (x, y) If x + y <= 4 & y>0 (x+y,0) pour all the water from the 3-
gallon jug into the 4-gallon jug
State Space Representation – Water Jug
2. Production Rules

Sr. Current state Next state Description

10 (x, y) If x + y <= 3 & x>0 (0,x+y) pour all the water from the 4 -
gallon jug into the 3-gallon jug

11 (0,2) (2,0) pour the 2-gallon from the 3 –


gallon jug into the 4-gallon jug

12 (2,y) (0, y) empty the 2 gallon in the 4 gallon


on the ground
Water Jug – Solution
3. Productions for the water jug problem

Gallons in the 4- gallon Jug Gallons in the 3- gallon Rule Applied

0 0
0 3 2
3 0 9
3 3 2
4 2 7
0 2 5 or 12
2 0 9 or 11
State Space Representation – 8 Puzzle
 Problem Definition: The 8 puzzle consists of eight numbered, movable tiles set in a 3x3 frame.
One cell of the frame is always empty thus making it possible to move an adjacent numbered
tile into the empty cell. Such a puzzle is illustrated in following diagram.

2 8 3 1 2 3

1 6 4 8 4

7 5 7 6 5

Initial State Goal State


State Space Representation – 8 Puzzle
 A solution to the problem is an appropriate sequence of moves, such as “move tiles 5 to the
right, move tile 7 to the left ,move tile 6 to the down” etc…

2 8 3 2 8 3

1 6 4 1 4

7 5 7 6 5

Initial State Next State after


one legal move
1 2 8 3
1 6 4
7 5

2 8 3 2 2 8 3 2 8 3
8 Puzzle - Game Tree

1 6 4 1 4 1 6 4
7 5 7 6 5 7 5

3 2 8 3 4 2 3 2 8 3
1 4 1 8 4 1 4
7 6 5 7 6 5 7 6 5

8 3 2 8 3 5 2 3 2 3
2 1 4 7 1 4 1 8 4 1 8 4
7 6 5 6 5 7 6 5 7 6 5

6 1 2 3
8 4
7 6 5

7 1 2 3 1 2 3
8 4 7 8 4
7 6 5 6 5
Problem Characteristics
1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
2. Can solution steps be ignored or at least undone if they prove unwise?
3. Is the problem’s universe predictable?
4. Is a good solution to the problem obvious without comparison to all other possible solutions?
5. Is the desired solution a state of the world or a path to a state?
6. Is a large amount of knowledge absolutely required to solve the problem or is knowledge
important only to constrain the search?
7. Can a computer that is simply given the problem return the solution or will the solution of the
problem require interaction between the computer and a person?
Production System
 Production systems provide appropriate structures for performing and describing search
processes.
 A production system has four basic components:
1. A set of rules each consisting of a left side that determines the applicability of the rule and a right side that
describes the operation to be performed if the rule is applied.
2. A database of current facts established during the process of inference.
3. A control strategy that specifies the order in which the rules will be compared with facts in the database
and also specifies how to resolve conflicts in selection of several rules or selection of more facts.
4. A rule applier.
 Production systems provide us with good ways of describing the operations that can be
performed in a search for a solution to a problem.
Production System Characteristics
1. A monotonic production system is a production system in which the application of a rule
never prevents the later application of another rule that could also have been applied at the
time the first rule was selected.
2. A non-monotonic production system is one in which this is not true. This production system
increases the problem-solving efficiency of the machine by not keeping a record of the
changes made in the previous search process.
3. A partially communicative production system is a production system with the property that if
the application of a particular sequence of rules transforms state P into state Q, then any
combination of those rules that is allowable also transforms state P into state Q.
4. A commutative production system is a production system that is both monotonic and partially
commutative. These type of production systems is used when the order of operation is not
important, and the changes are reversible.
Issues in the Design of Search Programs
1. The direction in which to conduct the search (forward versus backward reasoning). If the
search proceeds from start state towards a goal state, it is a forward search or we can also
search from the goal, i.e., backward search.
2. How to select applicable rules (Matching). Production systems typically spend most of their
time looking for rules to apply. So, it is critical to have efficient procedures for matching rules
against states.
3. How to represent each node of the search process (knowledge representation problem).

You might also like