Chapter 3 - Problem Solving by Searching - 2
Chapter 3 - Problem Solving by Searching - 2
L3 – SCI
Objectives
2
Plan
Introduction
Best first search
Greedy search
A*
Local search
Hill climbing algorithm
Stochastic search
Simulated annealing
Genetic algorithms
Summary 3
PROBLEM SOLVING BY SEARCHING (2)
5
PROBLEM SOLVING BY SEARCHING (2)
Implementation:
Special cases:
Greedy search
A* search
6
PROBLEM SOLVING BY SEARCHING (2)
Loop do
If Empty?(fringe) then return failure
node ← Remove-First(fringe)
If Goal-Test[ problem] applied to State[node] succeeds then
return Solution(node)
fringe ← Insert-all( Expand (node,problem),fringe)
sort fringe in ascending order of f-values
7
PROBLEM SOLVING BY SEARCHING (2)
Greedy search
8
PROBLEM SOLVING BY SEARCHING (2)
9
PROBLEM SOLVING BY SEARCHING (2)
10
PROBLEM SOLVING BY SEARCHING (2)
11
PROBLEM SOLVING BY SEARCHING (2)
12
PROBLEM SOLVING BY SEARCHING (2)
Greedy Search Properties
13
PROBLEM SOLVING BY SEARCHING (2)
A* search
14
PROBLEM SOLVING BY SEARCHING (2)
15
PROBLEM SOLVING BY SEARCHING (2)
16
PROBLEM SOLVING BY SEARCHING (2)
17
PROBLEM SOLVING BY SEARCHING (2)
18
PROBLEM SOLVING BY SEARCHING (2)
19
PROBLEM SOLVING BY SEARCHING (2)
A* search
h(n) h*(n)
20
PROBLEM SOLVING BY SEARCHING (part 2)
root
h(n) : Heuristic
(expected) minimum
cost to goal
Goal
21
PROBLEM SOLVING BY SEARCHING (2)
A* search
Theorem:
22
PROBLEM SOLVING BY SEARCHING (2)
A* search
n h(n)
c(n,n’) g
h(n’)
n’
Consistent heuristics are admissible. Not all admissible heuristics are consistent.
When a heuristic is consistent, the values of f(n) along any path are
nondecreasing.
A* with a consistent heuristic is optimal.
23
PROBLEM SOLVING BY SEARCHING (2)
A* search
Optimality: Yes.
Time: Exponential.
24
PROBLEM SOLVING BY SEARCHING (2)
8-Puzzle:
g(n): the path cost can be measured by the total
number of horizontal and vertical moves.
h(n): two different heuristics
25
PROBLEM SOLVING BY SEARCHING (2)
In some problems, one doesn’t care about a solution path but only the
final goal state. The solution is the goal state. Example: 8-queen
problem.
Local search algorithms are also useful for optimization problems where
the goal is to find a state such that an objective function is optimized.
For the 8-queen algorithm, the objective function may be the number of
attacks.
26
PROBLEM SOLVING BY SEARCHING (2)
Two advantages
Use little memory.
More applicable in searching large/infinite search space. They find
reasonable solutions in this case.
27
PROBLEM SOLVING BY SEARCHING (2)
Problem: local search can get stuck on a local maximum and not find
the optimal solution
28
Local Search: Hill Climbing
29
Local search
Steepest ascent version
30
Local search: steepest descent
version
minimum global
f(x)
x
What we should find 31
Local search: steepest descent
version
Initial solution
f(x)
x
32
Local search: steepest descent
version
Current solution
f(x)
x
33
Local search: steepest descent
version
Solution courante
f(x)
Solution voisine générée
x
34
Local search: steepest descent
version
Current solution
f(x)
x
35
Local search: steepest descent
version
Current solution
f(x)
New neighbor solution
x
36
Local search: steepest descent
version
Final solution
f(x)
x
37
Local Beam Search
38
Stochastic search: Simulated Annealing
Basic inspiration: What is annealing?
x
41
Simulated annealing
x
42
Simulated annealing
Best solution
x
43
Simulated annealing
x
44
Simulated annealing
x
45
Simulated annealing
Current Solution
x
46
Simulated annealing
x
47
Simulated annealing
Current Solution
x
48
Simulated annealing
Current Solution
x
49
Simulated annealing
Current Solution
x
50
Simulated annealing
Current Solution
x
51
Simulated annealing
Current Solution
x
52
Simulated annealing
Current Solution
x
53
Simulated annealing
Current solution
x
54
Simulated annealing
x
55
Simulated annealing
f(x)
Meilleure solution
Solution courante
x
56
Simulated annealing
x
57
Simulated annealing
x
58
Simulated annealing
f(x)
Best solution
Current Solution
x
59
Simulated annealing
f(x)
Best solution
Current Solution
x
60
Simulated annealing
f(x)
Best solution
Current Solution
x
61
Simulated annealing
x
62
Simulated Annealing
x
63
Stochastic search: Genetic algorithms
64
Stochastic search: Genetic
algorithms
• Genetic algorithms is a variant of local beam search.
• Successors in this case are generated by combining
two parent states rather than modifying a single state.
• Like local beam search, genetic algorithms starts with
a set of k randomly generated states called Population.
• Each state or individual is represented as a string over
a finite alphabet.
• Each state or individual is represented as a string over
a finite alphabet. It is also called chromosome.
65
Stochastic search: Genetic
algorithms
• Each state is rated by the evaluation function called fitness
function.
66
Stochastic search: Genetic
algorithms
67
Stochastic search: Genetic algorithms
68
Stochastic search: Genetic algorithms
Repeat
New population ← empty set;
for i from 1 to SizePopulation do
{x ← random-Selection (population, fitness-Fn);
y ← random-Selection (population, fitness-Fn);
Child ← Reproduce (x,y);
If (small random probability) then child ← mutate(child)
Add child to new population }
69
Genetic Algorithms
Cost
States
70
Genetic Algorithms
Mutation
Cross-Over
71
Genetic Algorithms
72
Genetic Algorithms
73
Genetic Algorithms
74
Genetic Algorithms
75
Genetic Algorithms
76
Genetic Algorithms
77
Genetic Algorithms
78
Genetic Algorithms
79
Genetic Algorithms
80
Genetic Algorithms
81
Genetic Algorithms
82
Genetic Algorithms
83
Genetic Algorithms
84
Genetic Algorithms
85
Genetic Algorithms
86
Genetic Algorithms
87
Genetic Algorithms
88
PROBLEM SOLVING BY SEARCHING (2)
Summary
89
PROBLEM SOLVING BY SEARCHING (2)
Summary
Local search methods keep small number of nodes in memory. They are
suitable for problems where the solution is the goal state itself and not the
path.