Problems, Problem spaces and Search

15,537 views 60 slides Aug 29, 2018
Slide 1
Slide 1 of 60
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60

About This Presentation

According to VTU syllabus for both BE and M.tech


Slide Content

ArtificiAl intelligence
15cS562

Ravi Kumar B N
Assistant Professor
Dept. of CSE
BMSIT&M

PROBLEMS,
PROBLEM SPACES
AND SEARCH
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2

Contents
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
•Defining the problem as a State Space Search
•Production Systems
•Control Strategies
•Breadth First Search
•Depth First Search
•Heuristic Search
•Problem Characteristics
•Is the Problem Decomposable?
•Can Solution Steps be ignored or undone?
•Production system characteristics
•Issues in the design of search programs

To Build a System to Solve a Particular Problem,
The Following Four Things are Needed
1.Define the problem precisely- specify both initial
and final situations(state)
2.Analyze the problem
3.Isolate and represent the task knowledge that is
necessary to solve the problem
4.Choose the best problem solving technique and
apply it
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4

State space search
Problem = Searching for a goal state
It is a process in which successive configurations or states of an
instance are considered , with the goal of finding a goal state with a
desired property
. State space- a set of states that a problem can be in.
- The group consisting of all the attainable states of a
problem
ex: Customers in a line would have state space {0,1,2….}
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5

Search Problem
S: the full set of states
S
0
:the initial state
A:SS set of operators
G : the set of final states.
G is subset of S
Search problem:
Find a sequence of actions which
transforms the agent from the
initial state to goal state.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 6

Representing search problems
Using directed graph
- The states are represented as nodes
- The allowed actions are represented as arcs.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 7

Problem Formulation
•A single state problem formulation is defined by four items
Initial state, successor function, goal test and path cost
•Problem formulation means choosing a relevant set of states
to consider, and a feasible set of operators for moving from
one state to another
•Search is the process of imagining sequences of operators
applied to the initial state and checking which sequence
reaches a goal state.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 8

Examples.
Problem: On holiday in Singapur; currently in Mysur. Flight
leaves tomorrow from Bangalore. Find a short route to drive
to Bangalore.
Formulate problem:
states: various cities
actions: drive between cities
solution: sequence of cities
Path Cost: distance travelled
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 9

Vacuum world state space
Ravi Kumar B N, Asst.Prof,CSE,BMSIT
1
0
States: Dirt and Robot Location
Actions: Left, right, clean
Goal test: No dirt at all locations
Path cost: 1 per action

The 8 - Puzzle
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
1

The 8 - Puzzle
Ravi Kumar B N, Asst.Prof,CSE,BMSIT
States: Locations of tiles
Actions: Move blank left, right, up, down
Goal test: Given
Path cost: 1 per move
1
2

State space search: Playing
Chess
•Each position can be described by an 8 by 8 array.
•Initial position is the game opening position.
•Goal position is any position in which the opponent does not
have a legal move and his or her king is under attack.
•Legal moves can be described by a set of rules:
-Left sides can be described by a set of rules
-Right sides describe the new resulting state
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
3

Playing chess contd…
•State space is a set of legal positions.
•Starting at the initial state.
•Using the set of rules to move from one state to another.
•Attempting to end up in a goal state.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
4

Playing Chess Contd..
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
5
One Legal Chess move

Playing Chess Contd..
•Writing the rules like above leads to very large number
•These rule poses serious practical difficulties
-No person could ever supply a complete set of rules. It
would take too long and could certainly not be done
without mistakes
-No program could easily handle all those rules.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
6

Playing Chess Contd..
Another way to describe the chess moves
White pawn at
Square(file e, rank 2) Move a pawn from
AND Square(file e, rank 2)
Square(file e, rank 3) is empty  to
AND Square(file e, rank 4)
Square(file e, rank 4) is empty
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
7

The Water Jug Problem
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
8
Given two jugs, a 4-gallon and 3-gallon, neither has any measuring maskers on it. There is a pump that
can be used to fill the jugs with water. How can you get exactly 2 gallons of water into the 4-gallon jug?
1 Gallon = 3.785 Liter

The Water Jug Problem
The state space for this problem can be described as the set of
ordered pairs of integers (x,y) such that x = 0, 1,2, 3 or 4 and
y = 0,1,2 or 3; x represents the number of gallons of water in
the 4-gallon jug and y represents the quantity of water in 3-
gallon jug
The start state is (0,0)
The goal state is (2,n)
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 1
9

Production rules for Water Jug
Problem
The operators to be used to solve the problem can be described as
follows:
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
0

Production rules
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
1

To solve the water jug problem
•Required a control structure that loops through a simple
cycle in which some rule whose left side matches the current
state is chosen
• the appropriate change to the state is made as described in
the corresponding right side
•the resulting state is checked to see if it corresponds to goal
state.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
2

One solution to the water jug problem
Shortest such sequence will have a impact on the choice of appropriate
mechanism to guide the search for solution.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
3

Production Systems
To Structure AI Programs
A production system consists of:
•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 that rule is
applied.
•One or more knowledge/databases that contain whatever information is
appropriate for the particular task. Some parts of the database may be permanent,
while other parts of it may pertain only to the solution of the current problem.
•A control strategy that specifies the order in which the rules will be compared
to the database and a way of resolving the conflicts that arise when several rules
match at once.
•A rule applier
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
4

Control Strategies
How to decide which rule to apply next during the process
of searching for a solution to a problem?
The two requirements of good control strategy are that
•It should cause motion.
•It should be systematic
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
5

BFS Tree for Water Jug
problem

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
6
(0,0)
(4,0) (0,3)
(4,3)
(0,0)(1,3) (4,3) (0,0) (3,0)

Breadth First Search
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
7

Breadth First Search
Algorithm:
1.Create a variable called NODE-LIST and set it to initial
state
2.Until a goal state is found or NODE-LIST is empty do
a.Remove the first element from NODE-LIST and call it E. If NODE-
LIST was empty, quit
b.For each way that each rule can match the state described in E do:
i.Apply the rule to generate a new state
ii.If the new state is a goal state, quit and return this state
iii.Otherwise, add the new state to the end of NODE-LIST
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
8

Depth First Search
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 2
9

Depth First Search
Algorithm:
1.If the initial state is a goal state, quit and return success
2.Otherwise, do the following until success or failure is
signaled:
a.Generate a successor, E, of initial state. If there are no
more successors, signal failure.
b.Call Depth-First Search, with E as the initial state
c.If success is returned, signal success. Otherwise continue
in this loop.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
0

Backtracking
•In this search, we pursue a single branch of the tree until it
yields a solution or until a decision to terminate the path is
made.
•It makes sense to terminate a path if it reaches dead-end,
produces a previous state. In such a state backtracking occurs
•Chronological Backtracking: Order in which steps are undone
depends only on the temporal sequence in which steps were
initially made.
•Specifically most recent step is always the first to be undone.
•This is also simple backtracking.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
1

Advantages of Depth-First
Search
•DFS requires less memory since only the nodes on
the current path are stored.
•By chance, DFS may find a solution without
examining much of the search space at all
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
2

Advantages of BFS
•BFS will not get trapped exploring a blind alley.
•If there are multiple solutions, then a minimal
solution will be found.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
3

Problem Characteristics
Inorder to choose the most appropriate method for a particular
problem, it is necessary to analyze the problem along several
key dimensions:
•Is the problem decomposable into a set of independent smaller or
easier subproblems?
•Can solution steps be ignored or at least undone if they prove unwise?
•Is the problem’s universe predictable?
•Is a good solution to the problem obvious without comparison to all
other possible solutions?
•Is the desired solution a state of the world or a path to a state?
•Is a large amount of knowledge absolutely required to solve the
problem or is knowledge important only to constrain the search?
•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?
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
4

Is the problem
Decomposable?
•Whether the problem can be decomposed into
smaller problems?
•Using the technique of problem decomposition,
we can often solve very large problems easily.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
5

Symbolic Integration
Decomposable
Sigma(x
2
+3x+sin
2
xcos
2
x)
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
6

Blocks World Problem
Non Decomposable

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
7
Following
operators are
available:
CLEAR(x) [ block x
has nothing on it]-
> ON(x, Table)
CLEAR(x) and
CLEAR(y) ->
ON(x,y) [ put x on
y]
C
A B
A
B
C
Start: ON(C,A)
Goal:
ON(B,C) and
ON(A,B)
ON(B,C)
ON(B,C) and ON(A,B)
ON(B,C)
ON(A,B)
CLEAR(A) ON(A,B)
CLEAR(A) ON(A,B)

Can Solution Steps be
ignored or undone?
Suppose we are trying to prove a math theorem. We can prove a lemma. If we find
the lemma is not of any help, we can still continue.
8-puzzle problem
Chess: A move cannot be taken back.
Important classes of problems:
•Ignorable ( theorem proving)
•Recoverable ( 8-puzzle)
•Irrecoverable ( Chess)
The recoverability of a problem plays an important role in determining the
complexity of the control structure necessary for the problem’s solution.
•Ignorable problems can be solved using a simple control structure that never
backtracks
•Recoverable problems can be solved by a slightly more complicated control
strategy that does sometimes make mistakes
•Irrecoverable problems will need to be solved by systems that expends a great
deal of effort making each decision since decision must be final.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
8

Is the universe Predictable?
•Certain Outcome ( ex: 8-puzzle)
•Uncertain Outcome ( ex: Bridge)
•For solving certain outcome problems, open loop approach
( without feedback) will work fine.
•For uncertain-outcome problems, planning can at best
generate a sequence of operators that has a good
probability of leading to a solution. We need to allow for a
process of plan revision to take place.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 3
9

Is a good solution absolute or
relative?
•Any path problem
•Best path problem
•Any path problems can often be solved in a reasonable
amount of time by using heuristics that suggest good
paths to explore.
•Best path problems are computationally harder.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
0

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
1

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
2

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
3

Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
4

Is the solution a state or a
path?
Finding a consistent interpretation
For the sentence “The bank president ate a dish of pasta salad with
the fork”.
We need to find the interpretation but not the record of the
processing.
Water jug : Here it is not sufficient to report that we have
solved , but the path that we found to the state (2,0). Thus a
statement of a solution to this problem must be a sequence of
operations ( Plan) that produces the final state.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
5

Is the solution a state or a
path?
A path solution problem can be reformulated as a state –
solution problem by describing a state as a partial path to a
solution.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
6

What is the role of
knowledge?
Two examples:
•Playing Chess: Knowledge is required to constrain the
search for a solution
•Newspaper story understanding: Lot of knowledge is
required even to be able to recognize a solution.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
7

What is the role of
knowledge?
Consider a problem of scanning daily newspapers
“to decide which are supporting the democrats and which are
supporting the republicans in some upcoming election”.
We need lots of knowledge to answer such questions as:
•The names of the candidates in each party
•The facts that if the major thing you want to see done is have taxes lowered, you
are probably supporting the republicans
•The fact that if the major thing you want to see done is improved education for
minority students, you are probably supporting the democrats.
•etc
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
8

Does the task require Interaction
with a person?
The programs require intermediate interaction with people
for additional inputs and to provided reassurance to the user.
There are two types of problems:
•Solitary
•Conversational
Decision on using one of these approaches will be important
in the choice of problem solving method.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 4
9

Does the task require Interaction
with a person?
Solitary Problem: in which there is no intermediate
communication and no demand for an explanation of the
reasoning process.
Conversational Problem: In which intermediate
communication is to provide either additional assistance to
the computer or additional information to the user.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
0

Problem Classification
•There are several broad classes into which the problems
fall.
•These classes can each be associated with generic control
strategy that is appropriate for solving the problems:
•Most diagnostic task : ex: medical diagnostics, diagnosis of
faults in mechanical devices
•Propose and Refine: ex: design and planning
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
1

Production System
Characteristics
Production Systems are good way to describe the operations that
can be performed in a search for a solution to a problem.
1.Can production systems, like problems, be described by a set of
characteristics that shed some light on how they can easily be
implemented?
2.If so, what relationships are there between problem types and
the types of production systems best suited to solving the
problems?
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
2

Production System
Characteristics
To answer to the first question is yes. Consider the following
definitions of Classes of Production systems:
•Monotonic Production System
•Non-Monotonic Production system
•Partially commutative Production system:
•Commutative Production system- both monotonic and
partially commutative.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
3

Monotonic Production
Systems
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 applied.
i.e., rules are independent.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
4

Commutative Production
system
A partially Commutative production system has a property
that if the application of a particular sequence of rules
transform state x into state y, then any permutation of those
rules that is allowable, also transforms state x into state y.
A Commutative production system is a production system
that is both monotonic and partially commutative.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
5

Four Categories of Production
System
Monotonic NonMonotonic
Partially
Commutative
Theorem provingRobot Navigation
Not Partially
Commutative
Chemical
Synthesis
Bridge
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
6

Partially Commutative,
Monotonic
These production systems are useful for solving ignorable
problems.
Example: Theorem Proving
They can be implemented without the ability to backtrack to
previous states when it is discovered that an incorrect path
has been followed.
This often results in a considerable increase in efficiency,
particularly because since the database will never have to be
restored, It is not necessary to keep track of where in the
search process every change was made.
They are good for problems where things do not change; new
things get created.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
7

Non Monotonic, Partially
Commutative
•Useful for problems in which changes occur but can
be reversed and in which order of operations is not
critical.
•Example: Robot Navigation, 8-puzzle, blocks world
•Suppose the robot has the following ops: go North
(N), go East (E), go South (S), go West (W). To reach its
goal, it does not matter whether the robot executes the
N-N-E or N-E-N.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
8

Not partially Commutative
Problems in which irreversible change occurs
Example: chemical synthesis
The ops can be :Add chemical x to the pot, Change the temperature
to t degrees.
These ops may cause irreversible changes to the potion being
brewed.
The order in which they are performed can be very important in
determining the final output.
(X+y) +z is not the same as (z+y) +x
Non partially commutative production systems are less likely to
produce the same node many times in search process.
When dealing with ones that describe irreversible processes, it is
partially important to make correct decisions the first time, although
if the universe is predictable, planning can be used to make that less
important.
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 5
9

Issues in the design of search
programs
•The direction in which to conduct the search
( forward versus backward reasoning).
•How to select applicable rules ( Matching)
•How to represent each node of the search process
( knowledge representation problem)
Ravi Kumar B N, Asst.Prof,CSE,BMSIT 6
0
Tags