SlideShare a Scribd company logo
1 of 80
Download to read offline
Dr. Imen Boudali
Department of ICT- ENIT
imen.boudali@gmail.com
Imen.Boudali@enit.utm.tn
Chapter 2
2023-2024
◦ Introduction
◦ Problem Representation
◦ State Graph
◦ Search Methods
◦ Blind Search Algorithms
◦ Heuristic Algorithms
 Solve a problem : Find a path from the
initial state to a final state (goal)
Initial
State
Final
State
Path??
 Solving Approach: Decompose the problem into
sub-problems and then break them down, etc.,
 Stop condition: Get problems with immediate
solution without decomposing them.
 Representation of the decomposition through a
sub-problem graph
 Solving the problem
⇕
Finding a sub-graph from the sub-problem graph
 Sub-problem Graph
The top-node indicate the initial problem
AND
OR
AND
OR
Tree AND/OR
• Nodes indicate:
- either a conjunction of sub-problems
- or a disjunction of possible decompositions
 Example : Puzzle Game
◦ State : a configuration
of table 4x4
◦ Two types of states are
defined:
 Initial State
 One or more final state
1 3 14 5
9 11 4 12
6 10 2 8
7 13 15
Initial State
7
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15
Final States
 Components to define:
• Problem States : set of real states (initial, final and
intermediate states)
• Goal to attain: set of path-solutions
• Processing Operators : combination of real actions
4 Elements to specify:
◦ Initial state
◦ operators (or succeeding_function S(x))
◦ Test-goal: function for assessing a given state as
a final one.
◦ Cost-path: determine the best path to the
solution if many paths exist.
⇒ A solution : a sequence of operators from the
initial state to the final state (solution)
 Example : Automatic Assembly
 Initial state: coordinates of the robot joints and parts
to be assembled
 Operators: continuous movements of the robotic arm
 Test-goal: assembly completed, robot in rest position
 Cost-path: execution time
 Initial state : positions of the 8 sheets into the 9 boxes
 Operators: move the empty box
 Test-goal: current state = final state
 Cost_path: each sheet moving costs 1,
⇒ Total_cost = number of sheet movings
 Example : PUZZLE Game
Initial Configuration
Initial State
Final Configuration
Final State
 An operator transforms a state into another
 Here, four operators are defined:
◦ Move the blank to the top
◦ Move the blank to the bottom
◦ Move the blank to the left
◦ move the blank to the right
 Applying operators to the states by starting from the
initial state leads to the construction of a Tree
 What a state ?
 What a node ?
 State: representation of a physical configuration
 Node: element of a data structure (graph or tree). It
is characterized by:
◦ parent,
◦ children,
◦ depth,
◦ Cost_path g(x)
 Four actors : the farmer (f), the wolf (l), the goat (g) and the
cabbage (C) are on the left side of a river.
 We consider:
◦ A boat that can transport the farmer alone or with one of the
remaining three players from left to right
◦ A boat that can transport the farmer alone or with one of the
remaining three players from right to left
◦ The wolf can eat the goat without the presence of the farmer
◦ The goat can eat the cabbage without the presence of the farmer
 Problem : How to pass the 4 actors to the other side ???
 Basic Idea: simulating the exploration of state space by generating
successors of already-explored states ( or expanding states)
function Tree-Search (problem, strategy) returns a solution, or failure
initialize the search tree using the initial state of problem
loop do
if there are no candidates for expansion then return failure
else choose a child node for expansion according to strategy
if the node contains a goal state then return the corresponding solution
else expand the node and add the resulting nodes to the search tree
end loop
end
 A state is a physical configuration
 A node is a data structure : a part of a search tree which is
defined by a parent, children, depth, path cost g(x)
 States do not have parents, children, depth, or path cost!
7 8 3
2 1
4 5 6
State Node
Depth = 3
Path_Cost = 3
Children
Parent
 Expand Function : creates new nodes, filling in the various
fields and using the Successor_Function of the problem to
create the corresponding new states
function Tree-Search (problem) returns a solution, or failure
List_toExplore ← Insert(Make-Node (Initial_State[problem]))
loop do
if List_toExplore is empty then return failure
else node ← Remove(List_toExplore)
if Goal-Test(problem, State(node)) then return node
else List_toExplore ←InsertAll(Expand(node, problem), List_toExplore)
EndLoop
function Expand( node, problem) returns a set of nodes
successors← 
for each (action, result) in Successor-Function (problem, State[node]) do
N← new Node
Parent [N] ← node;
Action[N]←action;
State[N]←result
Path_Cost[N]←Path-Cost[node] + Step_Cost(State[node], (action, result))
Depth[N]←Depth[node] + 1
add N to successors
return successors
 A strategy : defines the choice order of node expansion
 Two types of exploration strategies
◦ Uninformed Explorations: Blind Search Methods
◦ Informed Explorations: Heuristic Search Methods
 Evaluation Criteria: search methods are evaluated
according to the following criteria:
Completeness: Does the method always find a solution if
one exists?
Complexity in time: How long does it take to find the
solution? ⇨ Number of expanded nodes
Complexity in space: Which memory size does it take to
perform the search? ⇨ Maximum Number of nodes in
memory
Optimality: Does the method always find the best
solution with the least cost?
 Time and space complexities are measured in terms of:
◦ b = maximum branching factor of the search tree
◦ d = depth level of the best (or least cost) solution
node
◦ m = maximum depth level of the search space (state
space or search tree) → can be infinite
 Uninformed strategies use only the information
available in the problem definition
 Breadth-first search
 Depth-first search
 Depth-limited search
 Iterative deepening search
 Basic Idea: Priority to expand the least recently
(shallowest) generated nodes
 Implementation : List_toExplore is implemented as
a FIFO queue : new successor go at end
List_toExplore : A List_toExplore : B C
List_toExplore : C D E List_toExplore : D E F G
Expanding Order : A B C D E F G
 Complete ??
 Time ??
 Space ??
 Optimal ??
 Complete ? Yes (if b is finite)
 Time ?? 1 + b + b2 + b3 + … + bd = O(bd) (exp.
In d)
 Space ?? O(bd) (each expanded node must be
kept in memory)
 Optimal ?? Yes (if cost = 1 per step); not optimal
in general
⇨Space is the big problem;
 Apply the Breadth First strategy to solve the
following problem
Initial Configuration Final Configuration
1 3
2
6
5
8
4
7
1 3
2
4
8
6 5
7
30
1 2
8 6
3
7 5 4
1 2
3
8 6
7 5 4
1 2
4
8 6
3
7 5
1 2
6
8
3
7 5 4
1
3
8 6
2
7 5 4
1 2
4
8 6
2
7 5
1
6
8 2
3
7 5 4
1 2
6
8 5
2
7 4
1 2
6
8
2
7 5 4
1 6
3
8
2
7 5 4
1
3
8 6
2
7 5 4
1 2
8 4
3
7 6 5
Initial State
(0)
Goal State
(1) (2) (3)
(4) (5) (6) (7) (8)
(11)
(10)
(9)
 Basic Idea : Expand the deepest unexpanded
node
 Implementation: List_toExplore is LIFO queue,
i.e., put successors at front
Warning : for infinite cycles!
• The search space must be finite and non-cyclic
⇨ Already expanded nodes must be eliminated to
avoid cycles
……………..
 Nodes in this example are indicated according to
visit order
 Complete ??
 Time ??
 Space ??
 Optimal ??
 Complete ?? No: fails in infinite-depth spaces,
spaces with loops
Modify to avoid repeated states along path
⇒ complete in finite spaces
 Time ?? O(bm): terrible if m is much larger than d
but if solutions are shallower, may be much faster
than breadth-first
 Space ?? O(b * m), i.e., linear space!
 Optimal ?? No
⇨ Modest requirement for a memory space
 For instance : if b = 10, d = 12 and the space of
100 octets/node
◦ Depth Search requires 12 Kbyte
◦ Breadth Search requires 111 Tera-byte
* 1010 !!!
 Basic Idea : it corresponds to a depth-first search
with a depth limit l ,
⇨ i.e., nodes at depth l have no successors
 Recursive Implementation
 Complete ??
 Time ??
 Space ??
 Optimal ??
 Complete ?? Yes if L ≥ d
 Time ?? O(bL)
 Space ?? O(b * L)
 Optimal ?? No
 Apply the Depth Limited Search strategy to the
solve the following problem with L =3
Initial Configuration Final Configuration
1 3
2
6
5
8
4
7
1 3
2
4
8
6 5
7
1 2
8 6
3
7 5 4
Initial State
(0)
(3)
1 2
3
8 6
7 5 4
1 2
4
8 6
3
7 5
1
3
8 6
2
7 5 4
1 2
4
8 6
2
7 5
1 6
3
8
2
7 5 4
1
3
8 6
2
7 5 4
1 2
8 4
3
7 6 5
Goal State
(1) (5)
(2)
(6)
(7)
(4)
 Basic Idea :
The problem of Depth Limited Search is : How to define
the good value of L ?
Solution : Iterative Deepening : trying every value of L
from 0 with iterative increment
 Combine avantages of Breadth First Search and
Depth First Search
◦ optimal and complete as the Breadth First Search
◦ Economic in memory space as the Depth First Search
 This strategy is convenient for problems with
◦ Great search space
◦ Deepth of the solution is unknown
 Implementation
Visit Order :
 Complete ??
 Time ??
 Space ??
 Optimal ??
 Complete ?? Yes
 Time ?? (d+1)b0 + db1 + (d-1)b2 + … + bd =
O(bd)
 Space ?? O(b * d)
 Optimal ?? Yes if cost = 1 per step
⇨ Uninformed methods have practical limits in
terms of time and space to be applied for a wide
category of problems
 Informed or guided methods achieve better
performances in terms of :
◦ Space and/or
◦ Time
⇨The search is guided by using a heuristic
 Basic Idea: use an evaluation function for each
node
◦ To estimate its promising level (or desirability)
◦ To Expand most promising unexpanded node
 Implementation: List_toExplore is a queue sorted
in decreasing order of desirability
 Special cases:
◦ greedy search
◦ A∗ search
 Use of a criterion to reorder any nodes to be
explored
⇨ Heuristic
 A certain measure must be established to evaluate
the "promise" of a node.
⇨ Evaluation Function f
 The search is guided by the the best node
according to the evaluation function
 Centered on the node with the best
chance of reaching the goal
 A heuristic function h is integrated in the
evaluation function f
 h(u) : heuristic that estimates the cost of moving
from one state u to the final state.
 h(n) = 0 if n is a goal state.
 This function defines an order in the exploration
process
 Expand the states that seem closest to a goal
state, in order to achieve a solution more
quickly.
 In this case, f(n) = h(n)
 Assume the following configurations
Initial Configuration
Initial State
Final Configuration
Final State
1 3
2
6
5
8
4
7
1 3
2
4
8
6 5
7
 f(n)=h(n)
h ???
 h: number of misplaced tokens
1 2
8 6
3
7 5 4
1 2
3
8 6
7 5 4
1 2
4
8 6
3
7 5
1 2
6
8
3
7 5 4
f(n)= h(n) = 3
f(n)= h(n) =4
(2) (3)
1 2
4
8 6
2
7 5
1 2
8 4
3
7 6 5
Goal State
Initial State
f(n)= h(n) =2 f(n)= h(n) =3
f(n)= h(n) =1
f(n)= h(n) =0
 Find the shortest path from the initial state to
the final goal.
 In this case, f(n) = h(n) + g(n)
I
B
n
f*(n)
g*(n)
h*(n)
f*(n) = g*(n) + h*(n)
Initial
State
Goal
State
Node n
⇨ f*(n) represents the ideal cost (best cost) of the path crossing a
node n to reach the goal
 g*(n): the cost of the best path already
crossed from the initial state to the state n
 The choice of g depends on the studied field
 Example : Puzzle
g(n) : the number of moved tokens
→ the length of path from the root to n
 By using A* Algo. f(n)=g(n) +h(n)
with :
◦ g : number of moved tokens de jetons déplacés
◦ h: number of misplaced tokens
Initial Configuration
Initial State
Final Configuration
Final State
1 3
2
6
5
8
4
7
1 3
2
4
8
6 5
7
1 2
8 6
3
7 5 4
1 2
3
8 6
7 5 4
1 2
4
8 6
3
7 5
1 2
6
8
3
7 5 4
f(n)=(0+3)
(1+4) (1+2) (1+3)
1 2
4
8 6
2
7 5
1 2
8 4
3
7 6 5
Goal State
(2+1)
(3+0)
Initial State
64
Initial Configuration Final Configuration
2 3
8
6
5
1 4
7
1 3
2
4
8
6 5
7
Path ???
65
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
66
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
67
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
68
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
69
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
70
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
71
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
72
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
73
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
74
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
75
puzzle with A* Algorithm
A, ..., N: states
m = misplaced tokens
d = depth or number
of moved tokens
f(x) = m(x) + d(x)
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
d(x)
= 0
d(x)
= 1
d(x)
= 2
d(x)
= 3
m(B)
= 5
m(A)
= 4
m(C)
= 3
m(D)
= 5
1
2 3
4
5
6
7
8 1
2 3
4
5
6
7
8
1
2 3
4
5
6
7
8
m(E)
= 3
m(F)
= 3
m(G)
= 4
1
2 3
4
5
6
7
8
m(J)
= 2
1
2 3
4
5
6
7
8
m(K)
= 4
m(H)
= 3
m(I)
= 4
1
2 3
4
5
6
7
8
1
2
3
4
5
6
7
8
d(x)
= 4
1 2 3
4
5
6
7
8
m(L)
= 1
d(x)
= 5
1 2 3
4
5
6
7
8
m(M)
= 0
1 2 3
4
5
6
7 8
m(N)
= 2
Final
State
 Assume a postman initially in the city of Arad in
Romania
 the goal is to attain Bucharest with the minimal
cost path
 The shortest path ???
 Greedy Search ?
 A* Algorithm ?
Straight-line
distance to
Bucharest
Romania Step
Cost in Km
problem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , probloms
problem solve and resolving in ai domain , probloms

More Related Content

Similar to problem solve and resolving in ai domain , probloms

Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AIAmey Kerkar
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search StrategiesAmey Kerkar
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxRatnakar Mikkili
 
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchJarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchPalGov
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxRaviKiranVarma4
 
Chapter3 Search
Chapter3 SearchChapter3 Search
Chapter3 SearchKhiem Ho
 
SP14 CS188 Lecture 2 -- Uninformed Search.pptx
SP14 CS188 Lecture 2 -- Uninformed Search.pptxSP14 CS188 Lecture 2 -- Uninformed Search.pptx
SP14 CS188 Lecture 2 -- Uninformed Search.pptxAnimeGuru1
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial IntelligenceJay Nagar
 
Search-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfSearch-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfMrRRThirrunavukkaras
 
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdfAmirMohamedNabilSale
 
AI-04 Production System - Search Problem.pptx
AI-04 Production System - Search Problem.pptxAI-04 Production System - Search Problem.pptx
AI-04 Production System - Search Problem.pptxPankaj Debbarma
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and SearchHitesh Mohapatra
 

Similar to problem solve and resolving in ai domain , probloms (20)

Control Strategies in AI
Control Strategies in AIControl Strategies in AI
Control Strategies in AI
 
Informed and Uninformed search Strategies
Informed and Uninformed search StrategiesInformed and Uninformed search Strategies
Informed and Uninformed search Strategies
 
Artificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptxArtificial Intelligence_Searching.pptx
Artificial Intelligence_Searching.pptx
 
Searching
SearchingSearching
Searching
 
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearchJarrar.lecture notes.aai.2011s.ch3.uniformedsearch
Jarrar.lecture notes.aai.2011s.ch3.uniformedsearch
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptxPPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
PPT ON INTRODUCTION TO AI- UNIT-1-PART-2.pptx
 
Chapter3 Search
Chapter3 SearchChapter3 Search
Chapter3 Search
 
SP14 CS188 Lecture 2 -- Uninformed Search.pptx
SP14 CS188 Lecture 2 -- Uninformed Search.pptxSP14 CS188 Lecture 2 -- Uninformed Search.pptx
SP14 CS188 Lecture 2 -- Uninformed Search.pptx
 
Lecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptxLecture 3 Problem Solving.pptx
Lecture 3 Problem Solving.pptx
 
AI Lesson 04
AI Lesson 04AI Lesson 04
AI Lesson 04
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
c4.pptx
c4.pptxc4.pptx
c4.pptx
 
Search-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfSearch-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdf
 
Search 1
Search 1Search 1
Search 1
 
Chap11 slides
Chap11 slidesChap11 slides
Chap11 slides
 
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
 
state-spaces29Sep06.ppt
state-spaces29Sep06.pptstate-spaces29Sep06.ppt
state-spaces29Sep06.ppt
 
AI-04 Production System - Search Problem.pptx
AI-04 Production System - Search Problem.pptxAI-04 Production System - Search Problem.pptx
AI-04 Production System - Search Problem.pptx
 
State Space Representation and Search
State Space Representation and SearchState Space Representation and Search
State Space Representation and Search
 

Recently uploaded

办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceSapana Sha
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...ThinkInnovation
 

Recently uploaded (20)

办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
Call Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts ServiceCall Girls In Dwarka 9654467111 Escorts Service
Call Girls In Dwarka 9654467111 Escorts Service
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Decoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in ActionDecoding Loan Approval: Predictive Modeling in Action
Decoding Loan Approval: Predictive Modeling in Action
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
Predictive Analysis - Using Insight-informed Data to Determine Factors Drivin...
 

problem solve and resolving in ai domain , probloms

  • 1. Dr. Imen Boudali Department of ICT- ENIT imen.boudali@gmail.com Imen.Boudali@enit.utm.tn Chapter 2 2023-2024
  • 2. ◦ Introduction ◦ Problem Representation ◦ State Graph ◦ Search Methods ◦ Blind Search Algorithms ◦ Heuristic Algorithms
  • 3.  Solve a problem : Find a path from the initial state to a final state (goal) Initial State Final State Path??
  • 4.  Solving Approach: Decompose the problem into sub-problems and then break them down, etc.,  Stop condition: Get problems with immediate solution without decomposing them.
  • 5.  Representation of the decomposition through a sub-problem graph  Solving the problem ⇕ Finding a sub-graph from the sub-problem graph
  • 6.  Sub-problem Graph The top-node indicate the initial problem AND OR AND OR Tree AND/OR • Nodes indicate: - either a conjunction of sub-problems - or a disjunction of possible decompositions
  • 7.  Example : Puzzle Game ◦ State : a configuration of table 4x4 ◦ Two types of states are defined:  Initial State  One or more final state 1 3 14 5 9 11 4 12 6 10 2 8 7 13 15 Initial State 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Final States
  • 8.  Components to define: • Problem States : set of real states (initial, final and intermediate states) • Goal to attain: set of path-solutions • Processing Operators : combination of real actions
  • 9. 4 Elements to specify: ◦ Initial state ◦ operators (or succeeding_function S(x)) ◦ Test-goal: function for assessing a given state as a final one. ◦ Cost-path: determine the best path to the solution if many paths exist. ⇒ A solution : a sequence of operators from the initial state to the final state (solution)
  • 10.  Example : Automatic Assembly  Initial state: coordinates of the robot joints and parts to be assembled  Operators: continuous movements of the robotic arm  Test-goal: assembly completed, robot in rest position  Cost-path: execution time
  • 11.  Initial state : positions of the 8 sheets into the 9 boxes  Operators: move the empty box  Test-goal: current state = final state  Cost_path: each sheet moving costs 1, ⇒ Total_cost = number of sheet movings  Example : PUZZLE Game Initial Configuration Initial State Final Configuration Final State
  • 12.  An operator transforms a state into another  Here, four operators are defined: ◦ Move the blank to the top ◦ Move the blank to the bottom ◦ Move the blank to the left ◦ move the blank to the right
  • 13.  Applying operators to the states by starting from the initial state leads to the construction of a Tree  What a state ?  What a node ?
  • 14.  State: representation of a physical configuration  Node: element of a data structure (graph or tree). It is characterized by: ◦ parent, ◦ children, ◦ depth, ◦ Cost_path g(x)
  • 15.  Four actors : the farmer (f), the wolf (l), the goat (g) and the cabbage (C) are on the left side of a river.  We consider: ◦ A boat that can transport the farmer alone or with one of the remaining three players from left to right ◦ A boat that can transport the farmer alone or with one of the remaining three players from right to left ◦ The wolf can eat the goat without the presence of the farmer ◦ The goat can eat the cabbage without the presence of the farmer  Problem : How to pass the 4 actors to the other side ???
  • 16.  Basic Idea: simulating the exploration of state space by generating successors of already-explored states ( or expanding states) function Tree-Search (problem, strategy) returns a solution, or failure initialize the search tree using the initial state of problem loop do if there are no candidates for expansion then return failure else choose a child node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add the resulting nodes to the search tree end loop end
  • 17.  A state is a physical configuration  A node is a data structure : a part of a search tree which is defined by a parent, children, depth, path cost g(x)  States do not have parents, children, depth, or path cost! 7 8 3 2 1 4 5 6 State Node Depth = 3 Path_Cost = 3 Children Parent
  • 18.  Expand Function : creates new nodes, filling in the various fields and using the Successor_Function of the problem to create the corresponding new states
  • 19. function Tree-Search (problem) returns a solution, or failure List_toExplore ← Insert(Make-Node (Initial_State[problem])) loop do if List_toExplore is empty then return failure else node ← Remove(List_toExplore) if Goal-Test(problem, State(node)) then return node else List_toExplore ←InsertAll(Expand(node, problem), List_toExplore) EndLoop
  • 20. function Expand( node, problem) returns a set of nodes successors←  for each (action, result) in Successor-Function (problem, State[node]) do N← new Node Parent [N] ← node; Action[N]←action; State[N]←result Path_Cost[N]←Path-Cost[node] + Step_Cost(State[node], (action, result)) Depth[N]←Depth[node] + 1 add N to successors return successors
  • 21.  A strategy : defines the choice order of node expansion  Two types of exploration strategies ◦ Uninformed Explorations: Blind Search Methods ◦ Informed Explorations: Heuristic Search Methods
  • 22.  Evaluation Criteria: search methods are evaluated according to the following criteria: Completeness: Does the method always find a solution if one exists? Complexity in time: How long does it take to find the solution? ⇨ Number of expanded nodes Complexity in space: Which memory size does it take to perform the search? ⇨ Maximum Number of nodes in memory Optimality: Does the method always find the best solution with the least cost?
  • 23.  Time and space complexities are measured in terms of: ◦ b = maximum branching factor of the search tree ◦ d = depth level of the best (or least cost) solution node ◦ m = maximum depth level of the search space (state space or search tree) → can be infinite
  • 24.  Uninformed strategies use only the information available in the problem definition  Breadth-first search  Depth-first search  Depth-limited search  Iterative deepening search
  • 25.  Basic Idea: Priority to expand the least recently (shallowest) generated nodes  Implementation : List_toExplore is implemented as a FIFO queue : new successor go at end
  • 26. List_toExplore : A List_toExplore : B C List_toExplore : C D E List_toExplore : D E F G Expanding Order : A B C D E F G
  • 27.  Complete ??  Time ??  Space ??  Optimal ??
  • 28.  Complete ? Yes (if b is finite)  Time ?? 1 + b + b2 + b3 + … + bd = O(bd) (exp. In d)  Space ?? O(bd) (each expanded node must be kept in memory)  Optimal ?? Yes (if cost = 1 per step); not optimal in general ⇨Space is the big problem;
  • 29.  Apply the Breadth First strategy to solve the following problem Initial Configuration Final Configuration 1 3 2 6 5 8 4 7 1 3 2 4 8 6 5 7
  • 30. 30 1 2 8 6 3 7 5 4 1 2 3 8 6 7 5 4 1 2 4 8 6 3 7 5 1 2 6 8 3 7 5 4 1 3 8 6 2 7 5 4 1 2 4 8 6 2 7 5 1 6 8 2 3 7 5 4 1 2 6 8 5 2 7 4 1 2 6 8 2 7 5 4 1 6 3 8 2 7 5 4 1 3 8 6 2 7 5 4 1 2 8 4 3 7 6 5 Initial State (0) Goal State (1) (2) (3) (4) (5) (6) (7) (8) (11) (10) (9)
  • 31.  Basic Idea : Expand the deepest unexpanded node  Implementation: List_toExplore is LIFO queue, i.e., put successors at front Warning : for infinite cycles! • The search space must be finite and non-cyclic ⇨ Already expanded nodes must be eliminated to avoid cycles
  • 32.
  • 34.  Nodes in this example are indicated according to visit order
  • 35.  Complete ??  Time ??  Space ??  Optimal ??
  • 36.  Complete ?? No: fails in infinite-depth spaces, spaces with loops Modify to avoid repeated states along path ⇒ complete in finite spaces  Time ?? O(bm): terrible if m is much larger than d but if solutions are shallower, may be much faster than breadth-first  Space ?? O(b * m), i.e., linear space!  Optimal ?? No
  • 37. ⇨ Modest requirement for a memory space  For instance : if b = 10, d = 12 and the space of 100 octets/node ◦ Depth Search requires 12 Kbyte ◦ Breadth Search requires 111 Tera-byte * 1010 !!!
  • 38.  Basic Idea : it corresponds to a depth-first search with a depth limit l , ⇨ i.e., nodes at depth l have no successors
  • 40.  Complete ??  Time ??  Space ??  Optimal ??
  • 41.  Complete ?? Yes if L ≥ d  Time ?? O(bL)  Space ?? O(b * L)  Optimal ?? No
  • 42.  Apply the Depth Limited Search strategy to the solve the following problem with L =3 Initial Configuration Final Configuration 1 3 2 6 5 8 4 7 1 3 2 4 8 6 5 7
  • 43. 1 2 8 6 3 7 5 4 Initial State (0) (3) 1 2 3 8 6 7 5 4 1 2 4 8 6 3 7 5 1 3 8 6 2 7 5 4 1 2 4 8 6 2 7 5 1 6 3 8 2 7 5 4 1 3 8 6 2 7 5 4 1 2 8 4 3 7 6 5 Goal State (1) (5) (2) (6) (7) (4)
  • 44.  Basic Idea : The problem of Depth Limited Search is : How to define the good value of L ? Solution : Iterative Deepening : trying every value of L from 0 with iterative increment  Combine avantages of Breadth First Search and Depth First Search ◦ optimal and complete as the Breadth First Search ◦ Economic in memory space as the Depth First Search
  • 45.  This strategy is convenient for problems with ◦ Great search space ◦ Deepth of the solution is unknown
  • 48.  Complete ??  Time ??  Space ??  Optimal ??
  • 49.  Complete ?? Yes  Time ?? (d+1)b0 + db1 + (d-1)b2 + … + bd = O(bd)  Space ?? O(b * d)  Optimal ?? Yes if cost = 1 per step
  • 50. ⇨ Uninformed methods have practical limits in terms of time and space to be applied for a wide category of problems  Informed or guided methods achieve better performances in terms of : ◦ Space and/or ◦ Time ⇨The search is guided by using a heuristic
  • 51.  Basic Idea: use an evaluation function for each node ◦ To estimate its promising level (or desirability) ◦ To Expand most promising unexpanded node  Implementation: List_toExplore is a queue sorted in decreasing order of desirability  Special cases: ◦ greedy search ◦ A∗ search
  • 52.  Use of a criterion to reorder any nodes to be explored ⇨ Heuristic  A certain measure must be established to evaluate the "promise" of a node. ⇨ Evaluation Function f
  • 53.  The search is guided by the the best node according to the evaluation function  Centered on the node with the best chance of reaching the goal
  • 54.  A heuristic function h is integrated in the evaluation function f  h(u) : heuristic that estimates the cost of moving from one state u to the final state.  h(n) = 0 if n is a goal state.  This function defines an order in the exploration process
  • 55.  Expand the states that seem closest to a goal state, in order to achieve a solution more quickly.  In this case, f(n) = h(n)
  • 56.  Assume the following configurations Initial Configuration Initial State Final Configuration Final State 1 3 2 6 5 8 4 7 1 3 2 4 8 6 5 7
  • 57.  f(n)=h(n) h ???  h: number of misplaced tokens
  • 58. 1 2 8 6 3 7 5 4 1 2 3 8 6 7 5 4 1 2 4 8 6 3 7 5 1 2 6 8 3 7 5 4 f(n)= h(n) = 3 f(n)= h(n) =4 (2) (3) 1 2 4 8 6 2 7 5 1 2 8 4 3 7 6 5 Goal State Initial State f(n)= h(n) =2 f(n)= h(n) =3 f(n)= h(n) =1 f(n)= h(n) =0
  • 59.  Find the shortest path from the initial state to the final goal.  In this case, f(n) = h(n) + g(n)
  • 60. I B n f*(n) g*(n) h*(n) f*(n) = g*(n) + h*(n) Initial State Goal State Node n ⇨ f*(n) represents the ideal cost (best cost) of the path crossing a node n to reach the goal
  • 61.  g*(n): the cost of the best path already crossed from the initial state to the state n  The choice of g depends on the studied field  Example : Puzzle g(n) : the number of moved tokens → the length of path from the root to n
  • 62.  By using A* Algo. f(n)=g(n) +h(n) with : ◦ g : number of moved tokens de jetons déplacés ◦ h: number of misplaced tokens Initial Configuration Initial State Final Configuration Final State 1 3 2 6 5 8 4 7 1 3 2 4 8 6 5 7
  • 63. 1 2 8 6 3 7 5 4 1 2 3 8 6 7 5 4 1 2 4 8 6 3 7 5 1 2 6 8 3 7 5 4 f(n)=(0+3) (1+4) (1+2) (1+3) 1 2 4 8 6 2 7 5 1 2 8 4 3 7 6 5 Goal State (2+1) (3+0) Initial State
  • 64. 64 Initial Configuration Final Configuration 2 3 8 6 5 1 4 7 1 3 2 4 8 6 5 7 Path ???
  • 65. 65 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 66. 66 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 67. 67 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 68. 68 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 69. 69 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 70. 70 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 71. 71 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 72. 72 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 73. 73 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 74. 74 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2
  • 75. 75 puzzle with A* Algorithm A, ..., N: states m = misplaced tokens d = depth or number of moved tokens f(x) = m(x) + d(x) 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 0 d(x) = 1 d(x) = 2 d(x) = 3 m(B) = 5 m(A) = 4 m(C) = 3 m(D) = 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 m(E) = 3 m(F) = 3 m(G) = 4 1 2 3 4 5 6 7 8 m(J) = 2 1 2 3 4 5 6 7 8 m(K) = 4 m(H) = 3 m(I) = 4 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 d(x) = 4 1 2 3 4 5 6 7 8 m(L) = 1 d(x) = 5 1 2 3 4 5 6 7 8 m(M) = 0 1 2 3 4 5 6 7 8 m(N) = 2 Final State
  • 76.  Assume a postman initially in the city of Arad in Romania  the goal is to attain Bucharest with the minimal cost path  The shortest path ???  Greedy Search ?  A* Algorithm ?