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

Problem Solving - Search-Lect 3

Uploaded by

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

Problem Solving - Search-Lect 3

Uploaded by

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

PROBLEM SOLVING - SEARCHING

General introduction to searching


INTRODUCTION TO PROBLEM
SOLVING
 Search is an important aspect of AI because in many ways, problem solving in
AI is fundamentally a search.
 Artificial Intelligence is the study of building agents that act rationally. Most of
the time, these agents perform some kind of search algorithm in the
background in order to achieve their tasks.
 Search can be defined as a problem-solving technique that enumerates
a problem space from an initial position in search of a goal position
(or solution).
 The manner in which the problem space is searched is defined by the search
algorithm or strategy.
 As search strategies offer different ways to enumerate the search
space, how well a strategy works is based on the problem at hand.
 Learn to choose a search algorithm whose characteristics match that of the
problem at hand.
PROBLEM SOLVING – SEARCH
ALGORITHMS
 When solving a problem, think about the solution space in
terms of a number of actions that we can take, and the
new state of the environment as we perform those actions.
 As we take one of multiple possible actions (each have their own
cost), our environment changes and opens up alternatives for new
actions.
 As is the case with many kinds of problem solving, some paths
lead to dead-ends where others lead to solutions.
 And there may also be multiple solutions, some better than
others.
 The problem of search is to find a sequence of operators that
transition from the start to goal state. That sequence of
operators is the solution.
 How we avoid dead-ends and then select the best solution
available is a product of our particular search strategy.
WORKERS ARE ALWAYS SEARCHING

CISY 422
Brief info on Ants, http://www.winnipeg-bugline.com/ants.html,
http://www.boston.com/globe/magazine/2002/0623/frontiers.htm
SEARCH IN A PHYSICAL SPACE
 Let’s consider a simple search problem in physical space below.

CISY 422
 Our initial position is ‘A’ from which there are three
possible actions that lead to position ‘B,’ ‘C,’ or ‘D.’ Places,
or states, are marked by letters.

CISY 422
 At each place, there’s an opportunity for a decision,
or action.
 The action (also called an operator) is simply a legal move
between one place and another.
 The above physical space is also called a search space can
be reduced to a tree structure as shown below.
 Each node in the tree is a physical location and the
arcs between nodes are the legal moves.
 The depth of the tree is the distance from the initial position.
PROBLEM SOLVING TECHNIQUES IN
A.I
 Broad Approaches
 using search techniques
 e.g. in Games

CISY 422
 modeling
 using Knowledge Base Systems (KBS)
 using Machine Learning techniques e.g. Artificial Neural

Networks, Decision Trees, Case-base reasoning, Genetic


algorithms, ..
SEARCH IN A PUZZLE SPACE
 The “Towers of Hanoi” puzzle is an interesting example of a state space
for solving a puzzle problem.
 The object of this puzzle is to move a number of disks from one peg to
another (one at a time), with a number of constraints that must be

CISY 422
met.
 Each disk is of a unique size and it’s not legal for a larger disk to sit on
top of a smaller disk.
 The initial state of the puzzle is such that all disks begin on one peg in
increasing size order as shown below
 Our goal (the solution) is to move all disks to the last peg.

 References:
 https://www.youtube.com/watch?v=q6RicK1FCUs
 https://www.youtube.com/watch?v=boS4N1_TLBk
SEARCHING AS A PROBLEM SOLVING TECHNIQUE

 Searching is the process of looking for the solution of a


problem through a set of possibilities (state space).

CISY 422
 Search conditions include:
 Current state -where one is;
 Goal state – the solution reached; check whether it
has been reached;
 Cost of obtaining the solution.
 The solution is a path from the current state to the goal
state.
SEARCHING AS A PROBLEM SOLVING TECHNIQUE

Process of Searching
 Searching proceeds as follows:

CISY 422
 Check the current state;
 Execute allowable actions to move to the next state;
 Check if the new state is the solution state; if it is not,
then the new state becomes the current state and the
process is repeated until a solution is found or the
state space is exhausted.
SEARCH PROBLEM
 The search problem consists of finding a solution plan,
which is a path from the current state to the goal state.
 Representing search problems
 A search problem is represented using a directed graph.
The states are represented as nodes while the allowed
steps or actions are represented as arcs.
 A search problem is defined by specifying:
 State space;
 Start node;
 Goal condition, and a test to check whether the goal
condition is met;
 Rules giving how to change states.
 Path cost
PROBLEM DEFINITION - EXAMPLE, 8
PUZZLE
5 4 1 4
2 7
3
6 1 8 8
4
2 5 4
6
8
7 3 2 7
3 8
6 5

Initial State Goal State

References:
https://www.youtube.com/watch?v=1jjWL5C1l5Y
PROBLEM DEFINITION - EXAMPLE, 8
PUZZLE
 States
 A description of each of the eight tiles in each location
that it can occupy. It is also useful to include the blank
 Operators/Action
 The blank moves left, right, up or down
 Goal Test
 The current state matches a certain state (e.g. one of
the ones shown on previous slide)
 Path Cost
 Each move of the blank costs 1
PROBLEM DEFINITION - EXAMPLE, TIC-
TAC-TOE
x

CISY 422
ox ox ox
x x x x xo x
x x x x ox
o o ox x x

o
x
o
x ……….. xx
x x
x
x xx oo
o o
 References:
 https://www.youtube.com/watch?v=F4f7v_G_

CISY 422
Nf4

 https://www.youtube.com/watch?v=RYUBVSjp
li8
TREE/PATH EXAMPLE:

A 4 B 4 C
3

CISY 422
S 5 5
G
4 D E F 3
2 4
Implicit network of towns
 Two possible tasks:
 1. FIND a (the) path. = computational cost
 2. TRAVERSE the path. = travel cost
 2. relates to finding optimal paths
The associated loop-
free tree of partial
paths3 A 4 B 4 C
S 5 5
G
4 D 2 E F 3

CISY 422
4

3 S 4
4 A D
5 5 2
B D A E
4 5 2 4 5 4
C E E B B F
2 4 5 4 4 5 4 4 3
D F B F C E A C G
3 4 3 4
G C G F
3
G
PATHS:
 We are not interested in optimal paths here, so we can drop the costs.

Denotes: S
SA A Denotes:SD D

B D A A E

C E E B B F

D F B F C E A C G

G C G F Denotes
G :
SDEBA
 Nodes do not denote themselves, but denote the partial path
from the root to themselves!!
TERMINOLOGY:
S
A D

B D A E

CISY 422
C E E B B F

D F B F C E A C G

G C G F
G
 Node, link (or edge), branch, arc
 Parent, child, ancestor, descendant
 Root node, goal node
 Expand / Open node / Closed node / Branching factor
USING A TREE – THE OBVIOUS
SOLUTION?
 But
 It can be wasteful on space

CISY 422
 It can be difficult to implement, particularly if
there are varying number of children (as in
tic-tac-toe)
 It is not always obvious which node to
expand next. We may have to search the
tree looking for the best leaf node
(sometimes called the fringe or frontier
nodes). This can obviously be
computationally expensive
HOW GOOD IS A SOLUTION?
 Does our search method actually find a
solution?

CISY 422
 Is it a good solution?
 Path Cost
 Search Cost (Time and Memory)

 Does it find the optimal solution?


 But what is optimal?
EVALUATING A SEARCH
 Completeness
 Is the strategy guaranteed to find a solution?

CISY 422
 Time Complexity

 How long does it take to find a solution?


 Space Complexity

 How much memory does it take to perform


the search?
 Optimality

 Does the strategy find the optimal solution


where there are several solutions?
SEARCH TREES
 Some issues:
 Search trees grow very quickly
 The size of the search tree is governed by
the branching factor
 Even this simple game tic-tac-toe has a
complete search tree of 984,410 potential
nodes
 The search tree for chess has a branching
factor of about 35

You might also like