Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,

Similar presentations


Presentation on theme: "CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,"— Presentation transcript:

1 CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday, 9/20 Autumn – Current Event Tuesday

2 Search Lecture 4

3 CS 484 – Artificial Intelligence3 What is search? Getting from Arad to Bucharest ? ? ? Arad Sibiu Timisoara Zerind

4 CS 484 – Artificial Intelligence4 Brute Force Search exhaustive - examines every node in the search tree. Generate and test is simplest: Generate possible solutions to the problem. Test if valid solution. Stop when a valid solution is found. The method used to generate possible solutions must be carefully chosen.

5 CS 484 – Artificial Intelligence5 Depth-First Search DFS - exhaustive search Follows each path to its deepest node, before backtracking to try the next path.

6 CS 484 – Artificial Intelligence6 Breadth-First Search BFS - exhaustive search Follows each path to a given depth before moving on to the next depth.

7 CS 484 – Artificial Intelligence7 Comparison of Depth-First and Breadth-First Search Choose search method wisely Depth first search may never find the answer. Why?

8 CS 484 – Artificial Intelligence8 Properties of Search Methods Complexity Time and memory Completeness Guaranteed to find a goal if one exists. Optimality & Admissibility Guaranteed to find the best path to the goal. Irrevocability Never back-tracks

9 CS 484 – Artificial Intelligence9 Implementations DSF implemented using a stack to store states Recursive function BFS implementations are almost identical to depth-first Difference: use queue rather than a stack.

10 CS 484 – Artificial Intelligence10 Depth-First Iterative Deepening Combo of DFS and BFS exhaustive search DFS to depth of 1, then to depth of 2, 3, … until a goal reached. Efficient in memory use Copes with infinitely long branches. Not as inefficient in time as it might appear, Only examines the largest row (the last one) once.

11 CS 484 – Artificial Intelligence11 Modified Traveling Salesman Problem Find shortest path from A to F Edges: length of roads A B C E F D A C B BCD D D D E E E E C F F F F F F F F B

12 CS 484 – Artificial Intelligence12 Heuristics Heuristic: a rule used to make search more efficient or effective. Use a heuristic evaluation function, f(n): f(n) is the approximate distance of a node, n, from a goal node. For two node m and n, if f(m) < f(n), than m is more likely to be on an optimal path f(n) may not be 100% accurate, but it should give better results than pure guesswork.

13 CS 484 – Artificial Intelligence13 Heuristics – how informed? The more informed a heuristic is, the better it will perform. Heuristic h is more informed than j, if: h(n)  j(n) for all nodes n. A search method using h will search more efficiently than one using j. A heuristic should reduce the number of nodes that need to be examined.

14 CS 484 – Artificial Intelligence14 Choosing Good Heuristics Right heuristic can have a significant impact in the time required to solve the problem Should reduce the number of nodes that need to be searched The heuristic cannot take too long to calculate

15 CS 484 – Artificial Intelligence15 8-puzzle States: location of each of the eight tiles and the blank one Initial State: Any state can be designated so Successor function: Generates legal states that result from trying 4 actions Goal test: Checks whether state matches goal state Path cost: Each step costs 1, total cost == length of path Start State Goal State

16 CS 484 – Artificial Intelligence16 8-puzzle Game Properties Typically 20 moves to get from random start to goal state Branching Factor: Search tree examines 3 20 states (3.5 billion) Use heuristics to reduce states that are searched How many states is a given state from the goal? Start State Goal State

17 CS 484 – Artificial Intelligence17 Admissible Heuristics Admissible heuristic: Possible 8-puzzle admissible heuristics

18 CS 484 – Artificial Intelligence18 Hill Climbing Think of it as finding the highest point in a three dimensional search space: Check the height one foot away from your current location in each direction; North, South, East and West. Find a higher position, move to that location, and restart the algorithm. An informed, irrevocable search method.

19 CS 484 – Artificial Intelligence19 Foothills Cause difficulties for hill-climbing methods. A foothill is a local maximum.

20 CS 484 – Artificial Intelligence20 Plateaus Cause difficulties for hill-climbing methods. Flat areas that make it hard to find where to go next.

21 CS 484 – Artificial Intelligence21 Ridges Cause difficulties for hill-climbing methods B is higher than A. n At C, the hill- climber can’t find a higher point North, South, East or West, so it stops.

22 CS 484 – Artificial Intelligence22 Hill Climbing Algorithm Function hill() { queue = []; state = root_node; while (true) { if is_goal(state) return SUCCESS; else { sort(successor(state)); add_to_front_of_queue (successor(state)); } if queue == [] return FAILURE; state = queue[0]; remove_first_item (queue); }

23 CS 484 – Artificial Intelligence23 Modified Traveling Salesman Problem Find shortest path from A to F Solve using hill climbing A B C E F D distance as the crow flies What happens now?

24 CS 484 – Artificial Intelligence24 Best-First Search Like hill-climbing: Picks the most likely path (based on heuristic value) from the partially expanded tree Tends to find a shorter 1 path than depth-first or breadth-first search, but does not guarantee to find the best path. 1 depends how shorter is defined

25 CS 484 – Artificial Intelligence25 Hill Climbing Algorithm Function hill() { queue = []; state = root_node; while (true) { if is_goal(state) return SUCCESS; else { sort(successor(state)); add_to_front_of_queue (successor(state)); } if queue == [] return FAILURE; state = queue[0]; remove_first_item (queue); }

26 CS 484 – Artificial Intelligence26 Best-Search Algorithm Function best() { queue = []; state = root_node; while (true) { if is_goal(state) return SUCCESS; else { add_to_front_of_queue (successor(state)); sort(queue); } if queue == [] return FAILURE; state = queue[0]; remove_first_item (queue); }

27 CS 484 – Artificial Intelligence27 Optimal Paths An optimal path - shortest possible path from root to goal (i.e lowest cost) not necessarily at the shallowest depth, if edges have costs The British Museum procedure finds an optimal path by examining every possible path, and selecting the one with the least cost. There are more efficient ways.

28 CS 484 – Artificial Intelligence28 A* Algorithms Uses the cost function: f(node) = g(node) + h(node). g(node) is the cost of the path so far leading to the node. h(node) is an underestimate of how far node is from a goal state. f is a path-based evaluation function. An A* algorithm expands paths from nodes that have the lowest f value.

29 CS 484 – Artificial Intelligence29 A* Algorithms (continued) A* algorithms are optimal: They are guaranteed to find the shortest path Provided h(node) is always an underestimate. (h is an admissible heuristic). A* methods are also optimally efficient – they expand the fewest possible paths to find the right one. If h is not admissible, the method is called A, rather than A*.

30 CS 484 – Artificial Intelligence30 Modified Traveling Salesman Problem Get from A to F using shortest path Solve using A* g(n) – cost so far h(n) – heuristic A B C E F D h(n) = distance as the crow flies

31 CS 484 – Artificial Intelligence31 Uniform Cost Search Also known as branch and bound. Like A*, but uses: f(node) = g(node). g(node) is the cost of the path leading up to node. Optimal as long as all paths have a positive weight

32 CS 484 – Artificial Intelligence32 Greedy Search Like A*, but uses: f(node) = h(node). Hence, always expands the node that appears to be closest to a goal, regardless of what has gone before. Not optimal, and not guaranteed to find a solution at all. Can easily be fooled into taking poor paths.

33 CS 484 – Artificial Intelligence33 Real World Search Problem Route-finding Problem States: represented by location and current time Initial State: Specified by problem Successor function: returns states resulting from taking any scheduled flight leaving later than current time plus transit time Goal test: arrived at destination by prescribed time Path cost: monetary cost, waiting time, flight time, seat quality, time of day, etc.


Download ppt "CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,"

Similar presentations


Ads by Google