Heuristic Search

Heuristic Search
Blai Bonet
Hill climbing
Universidad Sim´
on Bol´ıvar, Caracas, Venezuela
c 2015 Blai Bonet
Goals for the lecture
Lecture 11
What to do with information?
Heuristic functions provide guidance information to reach the goal
• Hill climbing
Three approaches for using information:
• Enforced hill climbing
– Consider heuristic 100% accurate (hill climbing)
– Use it to order nodes for expansion (greedy best-first search)
– Combine with information gathered during search (best-first search)
c 2015 Blai Bonet
Lecture 11
c 2015 Blai Bonet
Lecture 11
Hill climbing
Hill climbing: pseudocode
1
2
3
% Hill climbing
Node hill-climbing(Heuristic h):
Node n = make-root-node(init())
4
Hill climbing is a local search algorithm
5
6
while true
if n.state.is-goal() return n
7
– Starting at the initial state,
% expansion
Succ = ∅
foreach <a,s> in n.state.successors()
if h(s) != ∞
Succ = Succ ∪ { make-node(n,a,s) }
if Succ == ∅ break
8
9
– Hill climbing always moves to best child
(the one closest to goal as measured by the heuristic)
10
11
12
13
14
% greedy selection of best child
n = select node from Succ minimizing h (random tie breaking)
15
16
17
18
c 2015 Blai Bonet
Lecture 11
return null
c 2015 Blai Bonet
Properties of hill climbing
Lecture 11
Local minima
– Complete: incomplete, it can loop forever trapped in local
minimum
h value
– Optimality: suboptimal
– Time complexity: it can loop forever
– Space complexity: constant space (more accurate: O(b))
states
c 2015 Blai Bonet
Lecture 11
c 2015 Blai Bonet
Lecture 11
Remarks on hill climbing
Enforced hill climbing
• Hill climbing is different from greedy best-first search
Variation on hill climbing in order to make it into complete algorithm
• GBFS maintains a queue and select best node in queue with
minimum heuristic
The idea is to wrap hill climbing into a breadth-first search
• With duplicate elimination, GBFS is complete
Given a node n, the breadth-first search looks for a successor node n0
with better heuristic value
• Variations on hill climbing include:
– Different tie-breaking strategies
Widely used algorithm when you are satisfied with any solution and
have a reasonable heuristic
– Random restarts
– Different mechanisms for escaping local minima
c 2015 Blai Bonet
Lecture 11
c 2015 Blai Bonet
Enforced hill climbing: pseudocode
1
2
3
4
5
Properties of enforced hill climbing
% Breadth-first search to improve h-value of node n0
Node improve(Node n0, Heuristic h):
Queue q
% FIFO queue
q.insert(n0)
set-color(n0.state,Gray) % Use a fresh hash table
6
7
8
9
10
11
12
13
14
15
while !q.empty()
Node n = q.pop()
if get-color(n.state) != Black
if h(n.state) < h(n0.state) return n
% expansion
foreach <a,s> in n.state.successors()
q.insert(make-node(n,a,s))
set-color(n.state,Black)
return null
% failure: node n0 can’t be improved
16
17
18
19
20
21
22
Lecture 11
– Complete: if connected space (e.g. undirected graphs) and
h(s) = 0 for all and only goal states
– Optimality: suboptimal
– Time complexity: O(S)
– Space complexity: O(S)
% Enforced hill climbing
Node enforced-hill-climbing(Heuristic h)
Node n = make-root-node(init())
while n != null && !is-goal(n.state)
n = improve(n, h)
return n
c 2015 Blai Bonet
Lecture 11
c 2015 Blai Bonet
Lecture 11
Summary
• Hill climbing
– Considers heuristic 100% accurate
– Incomplete and suboptimal
– Very fast and constant memory
• Enforced hill climbing
– Combines hill climbing with breadth-first search
– Complete but suboptimal
– Often used in hard combinatorial problems
c 2015 Blai Bonet
Lecture 11