Problem Solving - Search-Lect 3
Problem Solving - Search-Lect 3
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
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
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
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)
CISY 422
Time Complexity