symbolic ai: problem solving

42
May 12, 2013 Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM

Upload: carlo

Post on 09-Feb-2016

75 views

Category:

Documents


1 download

DESCRIPTION

E. Trentin, DIISM. Symbolic AI: Problem Solving. Example: Romania. On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal : be in Bucharest Formulate problem : states : various cities actions : drive between cities Find solution : - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Symbolic AI: Problem Solving

May 12, 2013 Problem Solving - Search

Symbolic AI: Problem Solving

E. Trentin, DIISM

Page 2: Symbolic AI: Problem Solving

Example: Romania On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal:

be in Bucharest Formulate problem:

states: various cities actions: drive between cities

Find solution: sequence of cities, e.g., Arad, Sibiu, Fagaras,

Bucharest

Page 3: Symbolic AI: Problem Solving

Example: Romania

Page 4: Symbolic AI: Problem Solving

Single-state problem formulation

A problem is defined by five items:

1. A set of discrete states (representing the “world”)2. initial state e.g., "at Arad"3. actions or successor function S(x) = set of action–state pairs

e.g., S(Arad) = {<Arad Zerind, Zerind>, … }4. goal test, can be

explicit, e.g., x = "at Bucharest" implicit, e.g., Checkmate(x)

5. path cost g(x) (additive) from the root to node x e.g., sum of distances, number of actions executed, etc. c(x,a,y) is the step cost (assumed to be ≥ 0) for expanding node y

from node x via action a

A solution is a sequence of actions leading from the initial state to a goal state

Page 5: Symbolic AI: Problem Solving

Example: The 8-puzzle

states? actions? goal test? path cost?

Page 6: Symbolic AI: Problem Solving

Example: The 8-puzzle

states? locations of tiles actions? move blank left, right, up, down goal test? = goal state (given) path cost? 1 per move

[Note: optimal solution of n-Puzzle family is NP-hard]

Page 7: Symbolic AI: Problem Solving

Example: robotic assembly

states?: coordinates of parts of the object to be assembled

actions?: motions of robot joints goal test?: complete assembly path cost?: time to execute

Page 8: Symbolic AI: Problem Solving

Tree search algorithms Basic idea:

offline, simulated exploration of state space by generating successors of already-explored states (a.k.a.~expanding states)

Page 9: Symbolic AI: Problem Solving

Tree search example

Page 10: Symbolic AI: Problem Solving

Tree search example

Page 11: Symbolic AI: Problem Solving

Tree search example

Page 12: Symbolic AI: Problem Solving

Implementation: states vs. nodes A state is a (representation of) a physical configuration A node is a data structure (part of a search tree) that

includes state, parent node, action, path cost g(x), depth

The Expand function creates new nodes, filling in the various fields and using the SuccessorFn of the problem to create the corresponding states.

Page 13: Symbolic AI: Problem Solving

Search strategies A search strategy is defined by picking the order of

node expansion Strategies are evaluated along the following

dimensions: completeness: does it always find a solution if one exists? time complexity: number of nodes generated space complexity: maximum number of nodes in memory optimality: does it always find a least-cost solution?

Time and space complexity are measured in terms of

b: maximum branching factor of the search tree d: depth of the least-cost solution m: maximum depth of the state space (may be ∞)

Page 14: Symbolic AI: Problem Solving

Uninformed search strategies

Uninformed search strategies use only the information available in the problem definition

Breadth-first search Uniform-cost search Depth-first search Depth-limited search Iterative deepening search

Page 15: Symbolic AI: Problem Solving

Breadth-first search Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 16: Symbolic AI: Problem Solving

Breadth-first search Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 17: Symbolic AI: Problem Solving

Breadth-first search Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 18: Symbolic AI: Problem Solving

Breadth-first search Expand shallowest unexpanded node Implementation:

fringe is a FIFO queue, i.e., new successors go at end

Page 19: Symbolic AI: Problem Solving

Properties of breadth-first search

Complete? Yes (if b is finite) Time? 1+b+b2+b3+… +bd = O(bd) Space? O(bd) (keeps every node in memory) Optimal? Yes (if cost = 1 per step)

Space may be the bigger problem (even bigger than time)

Page 20: Symbolic AI: Problem Solving

Uniform-cost search Expand least-cost unexpanded node Implementation:

fringe = queue ordered by path cost Equivalent to breadth-first if step costs all equal Complete? Yes, if step cost ≥ ε Time? # of nodes with g ≤ cost of optimal solution,

O(bceiling(C*/ ε)) where C* is the cost of the optimal solution

Space? # of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε))

Optimal? Yes – nodes expanded in increasing order of g(n)

Page 21: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 22: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 23: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 24: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 25: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 26: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 27: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 28: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 29: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 30: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 31: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 32: Symbolic AI: Problem Solving

Depth-first search Expand deepest unexpanded node Implementation:

fringe = LIFO queue, i.e., put successors at front

Page 33: Symbolic AI: Problem Solving

(kind of wobbling) properties of depth-first search

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 dense, may be much faster

than breadth-first Space? O(bm), i.e., linear space! Optimal? No

Page 34: Symbolic AI: Problem Solving

Depth-limited search (DLS)DLS = depth-first search with depth limit l,i.e., nodes at depth l are not expanded any further

Recursive implementation:

Page 35: Symbolic AI: Problem Solving

Iterative deepening search

Page 36: Symbolic AI: Problem Solving

Iterative deepening search l =0

Page 37: Symbolic AI: Problem Solving

Iterative deepening search l =1

Page 38: Symbolic AI: Problem Solving

Iterative deepening search l =2

Page 39: Symbolic AI: Problem Solving

Iterative deepening search l =3

Page 40: Symbolic AI: Problem Solving

Properties of iterative deepening search

Complete? Yes Time? O(bd) Space? O(bd) Optimal? Yes (if step cost = 1)

Page 41: Symbolic AI: Problem Solving

Repeated states Failure to detect repeated states can turn a

linear problem into an exponential one!

Page 42: Symbolic AI: Problem Solving

Graph search