Ch2-4-Problem Solving by Searching
Ch2-4-Problem Solving by Searching
[email protected]
http://faculty.ksu.edu.sa/YAlohali
Problem Solving by Searching
Search Methods :
Local Search for
Optimization Problems
Heuristic Functions
A heuristic function is a function f(n) that gives an estimation on the
“cost” of getting from node n to the goal state – so that the node with
the least cost among all possible choices can be selected for expansion
first.
f measures the estimated cost of getting to the goal from the current state:
f(n) = h(n) where h(n) = an estimate of the cost to get from
n to a goal
f measures the estimated cost of getting to the goal state from the current
state and the cost of the existing path to it. Often, in this case, we
decompose f:
f(n) = g(n) + h(n) where g(n) = the cost to get to n (from
initial state) 3
Approach 1: f Measures the Value of
the Current State
Chess
5
Traveling Salesman Person
A Solution: Exhaustive Search
(Generate and Test) !!
566573983193072464833325668761600000000
7
2-opt mutation for TSP
8
2-opt mutation for TSP
9
2-opt mutation for TSP
Remove them
10
2-opt mutation for TSP
11
Optimization Problems
14
Local Search Algorithms
Basic idea: Local search algorithms operate on a single state – current
state – and move to one of its neighboring states.
Two advantages
Use little memory.
More applicable in searching large/infinite search space. They find
reasonable solutions in this case.
15
Local Search Algorithms for
optimization Problems
Local search algorithms are
very useful for optimization
problems
16
Local Search Algorithms
Hill Climbing,
Simulated Annealing,
Tabu Search
Local Search: State Space
A state space landscape is a graph of states associated with their
costs
18
Hill Climbing
• "Like climbing Everest in thick fog with amnesia"
19
Steepest Ascent Version
Steepest ascent version
20
Hill Climbing: Neighborhood
Consider the 8-queen problem:
The objective function h(s) = number of queens that attack each other in
state s.
Local minimum
• Cure
+ Random restart
22
+ Good for Only few local maxima
Hill Climbing
Cost
States
23
Hill Climbing
Current
Solution
24
Hill Climbing
Current
Solution
25
Hill Climbing
Current
Solution
26
Hill Climbing
Current
Solution
27
Hill Climbing
Best
28
Local Search Algorithms
Simulated Annealing
(Stochastic hill climbing …)
Simulated Annealing
Key Idea: escape local maxima by allowing some "bad" moves
but gradually decrease their frequency
32
Simulated Annealing
33
Simulated Annealing
Temperature T
Used to determine the probability
High T : large changes
Low T : small changes
Cooling Schedule
Determines rate at which the temperature T is lowered
Lowers T slowly enough, the algorithm will find a global
optimum
States
35
Simulated Annealing
Cost Best
States
36
Simulated Annealing
Cost Best
States
37
Simulated Annealing
Cost Best
States
38
Simulated Annealing
Cost Best
States
39
Simulated Annealing
Cost Best
States
40
Simulated Annealing
Cost Best
States
41
Simulated Annealing
Cost Best
States
42
Simulated Annealing
Cost Best
States
43
Simulated Annealing
Cost Best
States
44
Simulated Annealing
Cost Best
States
45
Simulated Annealing
Cost Best
States
46
Simulated Annealing
Cost Best
States
47
Simulated Annealing
Cost Best
States
48
Simulated Annealing
Cost Best
States
49
Simulated Annealing
Cost Best
States
50
Simulated Annealing
Cost Best
States
51
Simulated Annealing
Cost Best
States
52
Simulated Annealing
Cost Best
States
53
Simulated Annealing
Cost Best
States
54
Simulated Annealing
Cost Best
States
55
Simulated Annealing
Cost Best
States
56
Simulated Annealing
Cost Best
States
57
Local Search Algorithms
Tabu Search
(hill climbing with small memory)
Tabu Search
The basic concept of Tabu Search as described by
Glover (1986) is "a meta-heuristic superimposed on
another heuristic.
59
Tabu Search: TS
Cost
States
60
Tabu Search: TS
Best
61
Tabu Search: TS
Best
62
Tabu Search: TS
Best
63
Tabu Search: TS
Best
64
Tabu Search: TS
Best
65
Tabu Search: TS
Best
66
Tabu Search: TS
Best
67
Tabu Search: TS
Best
68
Tabu Search: TS
Best
69
Tabu Search: TS
Best
70
Tabu Search: TS
Best
71
Tabu Search: TS
Best
72
Tabu Search: TS
Best
73
Tabu Search: TS
Best
74
Tabu Search: TS
Best
75
Tabu Search: TS
Best
76
Tabu Search: TS
Best
77
Tabu Search: TS
Best
78
Tabu Search: TS
Best
79
Tabu Search: TS
Best
80
Tabu Search: TS
Best
81
Tabu Search: TS
Best
82
Optimization Problems
At each step, all the successors of all the states are generated.
States
87
Local Beam Search
88
Local Beam Search
89
Local Beam Search
90
Local Beam Search
91
Local Beam Search
92
Local Beam Search
93
Local Beam Search
94
Local Beam Search
95
Local Beam Search
96
Local Beam Search
97
Local Beam Search
98
Local Beam Search
99
Local Beam Search
100
Local Beam Search
101
Local Beam Search
102
Population based Algorithms
Genetic Algorithms
Genetic programming
Stochastic Search: Genetic Algorithms
105
Stochastic Search: Genetic Algorithms
Fitness Function
• Each state is rated by the evaluation function called fitness
function. Fitness function should return higher values for better
states:
Fitness(X) should be greater than Fitness(Y) !!
[Fitness(x) = 1/Cost(x)]
Cost
States
106
X Y
Stochastic Search: Genetic Algorithms
Selection
How are individuals selected ?
0 Rnd[0..18] = 7 Rnd[0..18] = 12 18
Chromosome4 Chromosome6
107
Stochastic Search: Genetic Algorithms
Cross-Over and Mutation
108
Stochastic Search: Genetic Algorithms
Crossover - Recombination
Crossover
single point - With some high probability (crossover
random rate) apply crossover to the parents.
(typical values are 0.8 to 0.95)
109
Stochastic Search: Genetic Algorithms mutate
Mutation
Iterative process
Algorithm:
4. Update P with Ps
5. Evaluate: for each h compute its fitness.
113
Stochastic Search: Genetic Algorithms
114
Genetic Algorithms
Cost
States
115
Genetic Algorithms
Mutation
Cross-Over
116
Genetic Algorithms
117
Genetic Algorithms
118
Genetic Algorithms
119
Genetic Algorithms
120
Genetic Algorithms
121
Genetic Algorithms
122
Genetic Algorithms
123
Genetic Algorithms
124
Genetic Algorithms
125
Genetic Algorithms
126
Genetic Algorithms
127
Genetic Algorithms
128
Genetic Algorithms
129
Genetic Algorithms
130
Genetic Algorithms
131
Genetic Algorithms
132
Genetic Algorithms
133
Optimization Problems
Genetic programming: GP
Genetic Programming
Programming of Computers
by Means of Simulated
Evolution
Genetic Programming is
Genetic Algorithms where
solutions are programs …
135
Genetic programming
When the chromosome encodes an entire
program or function itself this is called
genetic programming (GP)
136
Genetic programming
Red Spiral
Blue Spiral
138
Genetic programming
Inter-twined Spirals: Classification Problem
139
Optimization Problems
New Algorithms
ACO, PSO, QGA …
Anything to be Learnt from
Ant Colonies?
Fairly simple units generate complicated
global behaviour.
141
Shortest path discovery
142
Shortest path discovery
Ants get to find the shortest path after few minutes …
143
Ant Colony Optimization
Each artificial ant is a probabilistic mechanism that constructs a
solution to the problem, using:
• Artificial pheromone deposition
• Heuristic information: pheromone trails, already
visited cities memory …
144
TSP Solved using ACO
145
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.