1/12:problem solving (search)

22
1 CSE 415 1/12: Problem Solving (Search) • Administrative Assignment 1 due Friday Current reading: • Chapters 1-3, Rich & Knight • Chapters 1-3, Touretzky • Chapter 12, Rich & Knight • Today Search from Chapter #2

Upload: quemby-kent

Post on 30-Dec-2015

36 views

Category:

Documents


1 download

DESCRIPTION

1/12:Problem Solving (Search). Administrative Assignment 1 due Friday Current reading: Chapters 1-3, Rich & Knight Chapters 1-3, Touretzky Chapter 12, Rich & Knight Today Search from Chapter #2. Problem-Solving in AI. Stages of problem solving formulate the problem (subjective) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 1/12:Problem Solving (Search)

1 CSE 415

1/12: Problem Solving (Search)

• Administrative

– Assignment 1 due Friday

– Current reading:

• Chapters 1-3, Rich & Knight

• Chapters 1-3, Touretzky

• Chapter 12, Rich & Knight

• Today

– Search from Chapter #2

Page 2: 1/12:Problem Solving (Search)

2 CSE 415

Problem-Solving in AI

• Stages of problem solving– formulate the problem (subjective)

• goal formulation

• problem formulation

– solve the formulated problem (objective)

Page 3: 1/12:Problem Solving (Search)

3 CSE 415

The Classical AI Problem

• The agent– no observational power

• The environment– no exogenous events or other agents

– actions are deterministic transitions

– start state is known with certainty

• The reward– reach a goal state (sometimes at minimum cost)

– for a single trial

Page 4: 1/12:Problem Solving (Search)

4 CSE 415

To describe a problem

• Problem definition– Define the state space

– Define the actions and their transition functions• define action/path costs

– Define the initial state and goal region

• Some examples– Eight puzzle

– Missionaries and cannibals

– Tower of Hanoi (see with emacs “Esc-x hanoi”)

Page 5: 1/12:Problem Solving (Search)

5 CSE 415

Two example problems

1 2 7

6

85

34

1 2 3

6

87

54

MM

M

CC

C?

MM

M

CC

C

Page 6: 1/12:Problem Solving (Search)

6 CSE 415

Problem solving as graph search

• “Every problem is a graph search problem, as long as you can figure out the right graph to search”– Graph vertices = states

– Graph arcs = action transitions

– Initial vertex and goal vertices identified

– Objective: find any/cheapest path from the initial state to any goal state

• Note: this is taking us far afield from reactive/observable problems!

Page 7: 1/12:Problem Solving (Search)

7 CSE 415

Graph search in AI

• The size of the state space is such that the graph is infinite or at least too big to hold in memory– incremental construction of the graph is the name of the

game

Page 8: 1/12:Problem Solving (Search)

8 CSE 415

Graph Search in Theory and Practice

Page 9: 1/12:Problem Solving (Search)

9 CSE 415

Incremental Graph Search: Nondeterministic Version

• This is an abstract way to look at the search problem. It highlights where the crucial choice is, and thus where we want to apply “intelligence”– Set N initial state

– Loop• if N is a goal node, terminate with success

• choose an action A to apply in N

• if there are no such actions, fail

• set N A(N)

Page 10: 1/12:Problem Solving (Search)

10 CSE 415

Nondeterministic Search

• All the smarts is in choose• A variety of ways to implement the “algorithm”

– most common is to maintain a list of the “frontier” nodes

– a heuristic function ranks them according to how “promising” each looks

• promising means something like “how long is the shortest path from here to a goal”

– at each iteration the highest ranked node is removed from the frontier, checked for goal-hood, its successors generated

Page 11: 1/12:Problem Solving (Search)

11 CSE 415

Search: Lisp Implementation

(defun basic-search (initial-state final-state-checker state-generator state-comparator) (really-search (list initial-state) final-state-checker state-generator state-comparator))

Function Inputs Output

initial-state statefinal-state-checker state Booleanstate-generator state (list-of state)state-comparator state state Boolean

Page 12: 1/12:Problem Solving (Search)

12 CSE 415

Lisp Implementation (cont.)

(defun really-search (frontier final-state-checker state-generator state-comparator) (cond ((null frontier) NIL) (T (let ((next-state (car frontier))) (cond ((funcall final-state-checker next-state) next-state) (T (let ((new-states (funcall state-generator next-state))) (really-search (sort (append new-states (cdr frontier)) state-comparator) final-state-checker state-generator state-comparator))))))))

Page 13: 1/12:Problem Solving (Search)

13 CSE 415

Search Strategies

• Uninformed– breadth first

– depth first

– iterative deepening

– bi-directional

• Informed– greedy

– A*

• Memory bounded– IDA*

– SMA*

Page 14: 1/12:Problem Solving (Search)

14 CSE 415

Breadth-First Search

• Strategy: always prefer the shortest path– consider all solutions of length k before considering any

solution of length k+1

• Advantages• complete: will always find a solution if there is one

• Disadvantages• memory intensive: frontier grows exponentially with b and d

• always takes exponential time to find long solutions

Page 15: 1/12:Problem Solving (Search)

15 CSE 415

Depth-First Search

• Strategy: always prefer the longest path– exhaust a single node on the frontier before considering any of its siblings

• Advantages– space efficient: frontier grows only with d and not with b

– can find a long solution very quickly (if one chooses well)

• Disadvantages– can work on an arbitrary bad path for arbitrarily long

– prone to looping (exploring cycles in the graph)

– as a practical matter, incomplete

• Possible solutions: – loop detection

– depth limit

Page 16: 1/12:Problem Solving (Search)

16 CSE 415

Backward and Bi-Directional Search

• Search so far has started at initial and generated successors.

• Suppose instead we stared at goal and generated predecessors.– or suppose we started both at initial and at goal, and went in

both directions

• The argument: fan-out versus fan-in• Difficulties

– computing predecessors

– bookkeeping to determine when a bi-directional search succeeds

Page 17: 1/12:Problem Solving (Search)

17 CSE 415

Iterative-Deepening Search

• Strategy– use a bounded depth-first approach

– but incrementally increase the depth bound if no solution is found

1 62 313 1564 7815 39066 195317 976568 4882819 2441406

610348 expansions wasted

3051754 total expansions

depth frontier size

20% wasted effort(assuming proper depth were known)

Page 18: 1/12:Problem Solving (Search)

18 CSE 415

Informed Search Methods

• “Informed” is exactly the ranking function in the search code– except comparison versus ranking

• Usual interpretation:– h’(n) estimated cost of cheapest path from n to any goal

• Need to balance the cost so far with expected cost to goal:– g(n) actual minimum cost of getting to n

– h’(n) estimated minimum cost getting from n to goal

Page 19: 1/12:Problem Solving (Search)

19 CSE 415

A* Search

• An informed method for finding the minimum-cost path from initial to a goal

• The ranking function is simply– f’(n) = g(n) + h’(n) estimated minimum cost to a goal

– how does this limit the agent’s reward structure??

• What are the implications of getting h’ wrong?– if h’(n) = h(n) for all n

– if h’(n) h(n) for all n but strictly less than for some n

– if h’(n) > h(n) for some n

Page 20: 1/12:Problem Solving (Search)

20 CSE 415

A*: Properties of the Cost Estimate

• If h’(n) is exactly h(n) for all n, then the search immediately converges to the optimal solution.

• If h'(n)=0 for all n, the search is breadth-first.• If h' never overestimates h, and goal states are

“correctly identified” then the first goal node found will be optimal.

• (All provided that goal states are correctly identified.)• If h' sometimes overestimates h, then the goal node

found may be sub-optimal.

Page 21: 1/12:Problem Solving (Search)

21 CSE 415

A* Search: Concluded

• An h’ that never overestimates h is called an admissible search heuristic.

• A* search defined to be best-first with an admissible h• Graceful degradation: suppose h’ is not admissible,

but doesn’t miss by much?– If the probability that h'(s)>h(s) is less than , then the

probability that A* will return an answer that is sub-optimal by more than a factor of is small.

Page 22: 1/12:Problem Solving (Search)

22 CSE 415

IDA*

• IDA* combines Iterative Deepening and A*– recall ID did depth-first for increasing depth bounds d = 0,

1, ... until a solution was found

– IDA does depth-first search using f-bounds instead of depth bounds

• depth-first(fb) considers all nodes n such that f(n)<= fb

• when a node’s f value exceeds fb it is pruned, but

• the f-bound for the next iteration is the minimum over the f values for all the pruned states

• Problems when f values are closely spaced– alternative is to increment depth bound by some fixed or

adaptive