Informed Search Methods n n How can we

  • Slides: 42
Download presentation
Informed Search Methods n n How can we make use of other knowledge about

Informed Search Methods n n How can we make use of other knowledge about the problem to improve searching strategy? Map example: n n Heuristic: Expand those nodes closest in “as the crow flies” distance to goal 8 -puzzle: n Heuristic: Expand those nodes with the most tiles in place

Best-First Search n n Create evaluation function which returns estimated “value” of expanding node

Best-First Search n n Create evaluation function which returns estimated “value” of expanding node Greedy search n n Estimate cost of cheapest path from node n to goal h(n) = “as the crow flies distance”

Greedy Search h(n)=374 h(n)=366 Arad h(n)=253 Zerind Arad h(n)=366 h(n)=329 Timisoara Sibiu Oradea h(n)=380

Greedy Search h(n)=374 h(n)=366 Arad h(n)=253 Zerind Arad h(n)=366 h(n)=329 Timisoara Sibiu Oradea h(n)=380 Fagaras Riminicu h(n)=178 h(n)=193 Sibiu Bucharest h(n)=253 h(n)=0

Greedy Search n n Expand the node with smallest h Why is it called

Greedy Search n n Expand the node with smallest h Why is it called greedy? n n Similar to depth-first search n n Follows single path all the way to goal, backs up when dead end Worst case time: n n Expands node that appears closest to goal O(bm), m = depth of search space Worst case memory: n O(bm), needs to store all nodes in memory to see which one to expand next

Greedy Search n Complete and/or optimal? n n n No – same problems as

Greedy Search n Complete and/or optimal? n n n No – same problems as depth first search Can get lost down an incorrect path How can you (help) to prevent it from getting lost? n Look at shortest total path, not just path to goal

A* search (another Best-First Search) n Greedy search minimizes n n Uniform cost search

A* search (another Best-First Search) n Greedy search minimizes n n Uniform cost search mininizes n n n h(n) = estimated cost to goal g(n) = cost to node n Example of each on map A* search minimizes n n f(n) = g(n) + h(n) f(n) = best estimate of cost for complete solution through n

A* search n Under certain conditions: n n n Complete Terminates to produce best

A* search n Under certain conditions: n n n Complete Terminates to produce best solution Conditions: n h(n) must never overestimate cost to goal n n admissible heuristic “optimistic” “Crow flies” heuristic is admissible Heuristic is monotone n n Never decreases along any path from root Can always generate a monotone heuristic from a nonmonotone

A* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646

A* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646 f(n) = 366 f(n) = 447 Timisoara Sibiu Oradea Fagaras f(n) = 526 f(n) = 417 Riminicu f(n) = 413 Craiova Pitesti Sibiu f(n) = 526 f(n) = 415 f(n) = 553

A* Search Arad f(n) = 646 Oradea Fagaras f(n) = 526 f(n) = 417

A* Search Arad f(n) = 646 Oradea Fagaras f(n) = 526 f(n) = 417 Riminicu f(n) = 413 Craiova Pitesti Sibiu f(n) = 526 f(n) = 415 f(n) = 553 Riminicu Craiova Bucharest f(n) = 607 f(n) = 615 f(n) = 418

A* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646

A* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646 f(n) = 366 Timisoara Sibiu Oradea f(n) = 526 f(n) = 447 Fagaras f(n) = 417 Riminicu f(n) = 413 Sibiu Bucharest f(n) = 591 f(n) = 450

A* terminates with optimal solution n A* stops when you try to expand a

A* terminates with optimal solution n A* stops when you try to expand a goal state n n n . . . and declares this the best solution How does it know this is the best? Suppose you try to expand a non-optimal goal state n n n A* always expands node with smallest f Since heuristic is admissible, f is an underestimate If there is a better goal state available, with a smaller f, there must be a node on graph with smaller f than current – so you would be expanding that instead!

More about A* n Completeness n n A* expands nodes in order of increasing

More about A* n Completeness n n A* expands nodes in order of increasing f Must find goal state unless n infinitely many nodes with f(n) < f* n n n infinite branching factor OR finite path cost with infinite nodes on it Complexity n n Time: Depends on h, can be exponential Memory: O(bm), stores all nodes

Valuing heuristics n Example: 8 -puzzle n n n h 1 = # of

Valuing heuristics n Example: 8 -puzzle n n n h 1 = # of tiles in wrong position h 2 = sum of distances of tiles from goal position (1 -norm, or Manhattan distance) Which heuristic is better for A*? n Obvious that h 2(n) >= h 1(n) for any n n n A* will expand less nodes with h 2 than with h 1 n n n h 2 dominates h 1 Since h 2 >= h 1, any node that A* expands with h 2 it will certainly expand with h 1 But A* may be able to avoid expanding some nodes with h 2 (larger than goal state f) Better to use larger heuristic (if not overestimate)

Inventing heuristics n h 1 and h 2 are exact path lengths for simpler

Inventing heuristics n h 1 and h 2 are exact path lengths for simpler problems n n h 1 = path length if you could transport each tile to right position h 2 = path length if you could just move each tile to right position, irrelevant of blank space Relaxed problem: less restrictive problem than original Can generate heuristics as exact cost estimates to relaxed problems

Today n n Remainder of informed search Assignment 3: 8 -puzzle On Friday: Chapter

Today n n Remainder of informed search Assignment 3: 8 -puzzle On Friday: Chapter 5 (Game playing) Question of the day: n Is chess episodic?

Heuristics in Constraint Satisfaction Problems n CSP: Find values for a set of variables,

Heuristics in Constraint Satisfaction Problems n CSP: Find values for a set of variables, subject to a set of constraints n n Example: Place as many knights as possible on a chessboard so that none attack another Easier example: Map coloring

Color this map. . . n . . . using only red, green, and

Color this map. . . n . . . using only red, green, and blue: n no adjacent regions have same color

Color this map. . . n . . . using only red, green, and

Color this map. . . n . . . using only red, green, and blue: n no adjacent regions have same color

Strategies n Variable: n Choose variable with fewest possible choices n n Choose variable

Strategies n Variable: n Choose variable with fewest possible choices n n Choose variable that limits other choices the most n n most-constrained-variable heuristic most-constraining-variable heuristic Values: n Choose value that leaves most options available n least-constraining-value heuristic

Memory Bounded Search n n Can A* be improved to use less memory? Iterative

Memory Bounded Search n n Can A* be improved to use less memory? Iterative deepening A* search (IDA*) n n n Each iteration is a depth-first search, just like regular iterative deepening Each iteration is not an A* iteration: otherwise, still O(bm) memory Use limit on cost (f), instead of depth limit as in regular iterative deepening

IDA* Search f(n) = 449 Zerind Arad f-Cost limit = 366 f(n) = 393

IDA* Search f(n) = 449 Zerind Arad f-Cost limit = 366 f(n) = 393 Sibiu f(n) = 447 Timisoara

IDA* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646

IDA* Search Arad f(n) = 449 f(n) = 393 Zerind Arad f(n) = 646 f-Cost limit = 393 f(n) = 366 Timisoara Sibiu Oradea f(n) = 526 f(n) = 447 Fagaras f(n) = 417 Riminicu f(n) = 415

IDA* Analysis n Time complexity n If cost value for each node is distinct,

IDA* Analysis n Time complexity n If cost value for each node is distinct, only adds one state per iteration n n If only a few choices (like 8 -puzzle) for cost, works really well Memory complexity n n BAD! Can improve by increasing cost limit by a fixed amount each time Approximately O(bd) (like depth-first) Completeness and optimality same as A*

Simplified Memory-Bounded A* (SMA*) n n Uses all available memory Basic idea: n n

Simplified Memory-Bounded A* (SMA*) n n Uses all available memory Basic idea: n n Do A* until you run out of memory Throw away node with highest f cost n n Store f-cost in ancestor node Expand node again if all other nodes in memory are worse

SMA* Example: Memory of size 3 A f = 12

SMA* Example: Memory of size 3 A f = 12

SMA* Example: Memory of size 3 A B Expand to the left f =

SMA* Example: Memory of size 3 A B Expand to the left f = 15 f = 12

SMA* Example: Memory of size 3 A B f = 15 Expand node A,

SMA* Example: Memory of size 3 A B f = 15 Expand node A, since f smaller f = 12 C f = 13

SMA* Example: Memory of size 3 A f = 12 forgotten f = 15

SMA* Example: Memory of size 3 A f = 12 forgotten f = 15 C D Expand node C, since f smaller f = 18 f = 13

SMA* Example: Memory of size 3 A f = 12 forgotten f = 15

SMA* Example: Memory of size 3 A f = 12 forgotten f = 15 C f = 13 forgotten f = infinity E f = 24 Node D not a solution, no more memory: so expand C again

SMA* Example: Memory of size 3 A B f = 15 f = 12

SMA* Example: Memory of size 3 A B f = 15 f = 12 C f = 13 Forgotten f = 24 (right) Re-expand A; record new f for C

SMA* Example: Memory of size 3 A f = 12 forgotten = 24 B

SMA* Example: Memory of size 3 A f = 12 forgotten = 24 B F f = 15 f = 25 Expand left B: not a solution, so useless

SMA* Example: Memory of size 3 A f = 12 Forgotten f = 24

SMA* Example: Memory of size 3 A f = 12 Forgotten f = 24 B f = 15 forgotten f = inf G f = 20 Expand right B: find solution

SMA* Properties n n Complete if can store at least one solution path in

SMA* Properties n n Complete if can store at least one solution path in memory Finds best solution (and recognizes it) if path can be stored in memory n Otherwise, finds best that can fit in memory

Iterative Improvement Algorithms n n n For some problems, path to solution is irrelevant:

Iterative Improvement Algorithms n n n For some problems, path to solution is irrelevant: just want solution itself Start with an initial state, and change it iteratively to improve it Examples: n n n Placing queens on a chessboard How many airline flights to have to where If you know the function, can take derivative: solve derivative = 0

Hill-climbing search (or gradient descent) n Example: Allocating professors to departments n n M&CS:

Hill-climbing search (or gradient descent) n Example: Allocating professors to departments n n M&CS: 10 Physics: 5 English: 7 Goal: Maximize majors in 3 departments n n For a given configuration of profs, I know (by simulation or something) how many money college will make (tuition for majors – salary) Assume profs make $10 k / year Start adding profs, end up in local maximum Show on blackboard

Hill-climbing in general n Move in direction of increasing value n n Drawbacks: n

Hill-climbing in general n Move in direction of increasing value n n Drawbacks: n n Useful when path to solution is irrelevant Local maxima Plateaux Ridges Can get around this some with randomrestart hill climbing

Simulated Annealing n n Technique inspired by engineering practice of cooling liquid At each

Simulated Annealing n n Technique inspired by engineering practice of cooling liquid At each iteration make a random move n n n If position is better than current, do it Over time, slowly drop “temperature” T If position is worse, do it with probability P n n P becomes smaller as T drops P = exp(change in value / T) Eventually, algorithm reverts to hill climbing Popular in VLSI layout

Iterative Improvement for CSPs n n Start with an initial configuration (like queens on

Iterative Improvement for CSPs n n Start with an initial configuration (like queens on a chessboard) Min-conflicts heuristic n n Choose a new value that results in minimum number of conflicts with other variables Queens example