csc3203: ai for games informed search (1) patrick olivier [email protected]

23
CSC3203: AI for Games Informed search (1) Patrick Olivier [email protected]

Upload: karin-houston

Post on 29-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

CSC3203: AI for Games

Informed search (1)

Patrick Olivier

[email protected]

Page 2: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Uninformed search: summaryBreadth-

firstDepth-first Iterative

deepening

Page 3: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Informed search strategies

• Best-first search

• Greedy best-first search

• A* search

• Local beam search

• Simulated annealing search

• Genetic algorithms

Page 4: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Best-first search

• Search strategy defined by: – order of node expansion

• Uniform cost search uses cost so far: g(n) • Best first search uses:

– evaluation function: f(n)– expand most desirable unexpanded node– implementation: order fringe by decreasing f(n)

• For example:– greedy best-first search– A* search

Page 5: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy best-first search

• Evaluation function f(n) = h(n) • Heuristics are rules-of-thumb that are likely (but

not guaranteed) to help in problem solving• For example:

– hSLD(n) = straight-line distance from n to Bucharest

• Greedy best-first search expands the node that appears to be closest to goal

Page 6: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy search: Arad BucharestStraight line distance to Bucharest

Page 7: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy search: Arad Bucharest

Page 8: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy search: Arad Bucharest

Page 9: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy search: Arad Bucharest

Page 10: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Greedy search: Arad Bucharest

Page 11: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Properties of greedy search

• Complete? – In finite space if modified for repeated states– (Consider Iasi to Fagaras: false start to Neamt rather than Vaslui, and

must prevent repeated states to avoid infinite Iasi/Neamt transitions.)

• Time: – O(bm): good heuristic dramatic improvement

• Space: – O(bm) keeps all nodes in memory

• Optimal? – No

Page 12: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search• Idea: don’t just use estimate of cost to the

goal, but the cost of paths so far

• Evaluation function: f(n) = g(n) + h(n)– g(n) = cost so far to reach n – h(n) = estimated cost from n to goal– f(n) is estimated cost of path through n to goal

Page 13: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Class exercise: Arad Bucharest using A* and the staight-line distance as hSLD(n)

SLD to Bucharest

Page 14: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 15: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 16: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 17: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 18: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 19: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

A* search: Arad Bucharest

Page 20: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Admissible heuristics

• A heuristic h(n) is admissible if for every node n,h(n) ≤ h*(n), where h*(n) is the true cost to

reach the goal state from n.• An admissible heuristic never overestimates the

cost to reach the goal, i.e. it is optimistic• Example: hSLD(n) (never overestimates the actual

road distance)• Theorem: If h(n) is admissible, A* using tree-

search is optimal

Page 21: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G.

f(G2) = g(G2) …since h(G2) = 0

g(G2) > g(G) …since G2 suboptimal

f(G) = g(G) …since h(G) = 0

f(G2) > f(G) …from above

Proof of A* optimality of A*

f(n) = g(n) + h(n)

Page 22: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

Suppose some suboptimal goal G2 has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G.

f(G2) > f(G) …from above

h(n) ≤ h*(n) ...since h is admissible

g(n) + h(n) ≤ g(n) + h*(n)

f(n) ≤ f(G)

Hence f(G2) > f(n), and A* will never select G2 for expansion

Proof of A* optimality of A*

Page 23: CSC3203: AI for Games Informed search (1) Patrick Olivier p.l.olivier@ncl.ac.uk

• Complete? – Yes – unless there are infinitely many nodes f(n) ≤ f(G)

• Time? – Exponential unless error in the heuristic grows no faster that

the logarithm of the actual path cost– A* is as optimally efficient (no other algorithm is guaranteed to

expand less nodes for the same heuristic)

• Space? – All nodes in memory (same as time complexity)

• Optimal? – Yes

Properties of A* search

)(log)()( ** nhOnhnh