Artificial Intelligence

Similar documents
Informed Search and Exploration

Informed search algorithms

TDT4136 Logic and Reasoning Systems

Informed search algorithms

Informed search algorithms. Chapter 4, Sections 1 2 1

Outline. Informed search algorithms. Best-first search. Review: Tree search. A search Heuristics. Chapter 4, Sections 1 2 4

Informed Search. Dr. Richard J. Povinelli. Copyright Richard J. Povinelli Page 1

Robot Programming with Lisp

Informed Search Algorithms. Chapter 4

Introduction to Artificial Intelligence. Informed Search

Artificial Intelligence: Search Part 2: Heuristic search

Planning, Execution & Learning 1. Heuristic Search Planning

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.

CS:4420 Artificial Intelligence

Problem solving and search

Lecture Plan. Best-first search Greedy search A* search Designing heuristics. Hill-climbing. 1 Informed search strategies. Informed strategies

Informed Search and Exploration

Informed search algorithms. Chapter 4

Informed Search and Exploration

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

Problem solving and search

Artificial Intelligence p.1/49. n-queens. Artificial Intelligence p.2/49. Initial state: the empty board or a board with n random

COSC343: Artificial Intelligence

Artificial Intelligence

CS 380: Artificial Intelligence Lecture #4

Artificial Intelligence

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

Informed Search. Best-first search. Greedy best-first search. Intelligent Systems and HCI D7023E. Romania with step costs in km

Informed search algorithms

Informed Search and Exploration

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Artificial Intelligence. Informed search methods

Problem Solving: Informed Search

Problem solving and search

ARTIFICIAL INTELLIGENCE. Informed search

Solving Problems using Search

Problem solving and search

Artificial Intelligence: Search Part 1: Uninformed graph search

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 2: Search 1.

Informed Search and Exploration

Chapter 3: Informed Search and Exploration. Dr. Daisy Tang

Informed search algorithms. (Based on slides by Oren Etzioni, Stuart Russell)

2006/2007 Intelligent Systems 1. Intelligent Systems. Prof. dr. Paul De Bra Technische Universiteit Eindhoven

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Informed Search and Exploration for Agents

CSE 473. Chapter 4 Informed Search. CSE AI Faculty. Last Time. Blind Search BFS UC-BFS DFS DLS Iterative Deepening Bidirectional Search

Informed search algorithms. Chapter 4

CS414-Artificial Intelligence

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Solving problems by searching

Outline. Best-first search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Outline. Best-first search

Problem-solving agents. Solving Problems by Searching. Outline. Example: Romania. Chapter 3

Foundations of Artificial Intelligence

Informed Search. Topics. Review: Tree Search. What is Informed Search? Best-First Search

Informed search algorithms. (Based on slides by Oren Etzioni, Stuart Russell)

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Artificial Intelligence

Outline for today s lecture. Informed Search. Informed Search II. Review: Properties of greedy best-first search. Review: Greedy best-first search:

Artificial Intelligence CS 6364

Solving Problems by Searching

CS486/686 Lecture Slides (c) 2015 P.Poupart

Artificial Intelligence Informed search. Peter Antal

CS486/686 Lecture Slides (c) 2014 P.Poupart

Artificial Intelligence

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Sina Institute, University of Birzeit

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on Artificial Intelligence,

A.I.: Informed Search Algorithms. Chapter III: Part Deux

CS:4420 Artificial Intelligence

Problem solving and search

DFS. Depth-limited Search

Planning and search. Lecture 1: Introduction and Revision of Search. Lecture 1: Introduction and Revision of Search 1

Chapter4. Tree Search (Reviewed, Fig. 3.9) Best-First Search. Search Strategies. Best-First Search (cont.-2) Best-First Search (cont.

Introduction to Artificial Intelligence (G51IAI)

Lecture 4: Informed/Heuristic Search

Artificial Intelligence

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Artificial Intelligence. Sina Institute, University of Birzeit

Problem Solving and Search. Chapter 3

Solving Problems: Intelligent Search

Artificial Intelligence. 2. Informed Search

TDDC17. Intuitions behind heuristic search. Recall Uniform-Cost Search. Best-First Search. f(n) =... + h(n) g(n) = cost of path from root node to n

Problem solving and search: Chapter 3, Sections 1 5

Problem solving and search: Chapter 3, Sections 1 5

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

CS 771 Artificial Intelligence. Informed Search

Informed/Heuristic Search

Foundations of Artificial Intelligence

Problem solving and search

Informed search algorithms

4. Solving Problems by Searching

Informed search algorithms

TDDC17. Intuitions behind heuristic search. Best-First Search. Recall Uniform-Cost Search. f(n) =... + h(n) g(n) = cost of path from root node to n

Informed search methods

AGENTS AND ENVIRONMENTS. What is AI in reality?

Problem-solving agents. Problem solving and search. Example: Romania. Reminders. Example: Romania. Outline. Chapter 3

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

Problem solving and search

Problem solving and search

Informed Search and Exploration

Transcription:

Artificial Intelligence hapter 1 hapter 1 1

Iterative deepening search function Iterative-Deepening-Search( problem) returns a solution inputs: problem, a problem for depth 0 to do result Depth-Limited-Search( problem, depth) if result cutoff then return result end hapter 1 2

Iterative deepening search l = 0 Limit = 0 A A hapter 1 3

Iterative deepening search l = 1 Limit = 1 A A A A B B B B hapter 1 4

Iterative deepening search l = 2 Limit = 2 A A A A B B B B D E F G D E F G D E F G D E F G A A A A B B B B D E F G D E F G D E F G D E F G hapter 1 5

Iterative deepening search l = 3 Limit = 3 A A A A B B B B D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O A A A A B B B B D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O A A A A B B B B D E F G D E F G D E F G D E F G H I J K L M N O H I J K L M N O H I J K L M N O H I J K L M N O hapter 1 6

omplete?? Properties of iterative deepening search hapter 1 7

Properties of iterative deepening search omplete?? Yes Time?? hapter 1 8

Properties of iterative deepening search omplete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? hapter 1 9

Properties of iterative deepening search omplete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? O(bd) Optimal?? hapter 1 10

Properties of iterative deepening search omplete?? Yes Time?? (d + 1)b 0 + db 1 + (d 1)b 2 +... + b d = O(b d ) Space?? O(bd) Optimal?? Yes, if step cost = 1 an be modified to explore uniform-cost tree Numerical comparison for b = 10 and d = 5, solution at far right: N(IDS) = 50 + 400 + 3, 000 + 20, 000 + 100, 000 = 123, 450 N(BFS) = 10 + 100 + 1, 000 + 10, 000 + 100, 000 + 999, 990 = 1, 111, 100 hapter 1 11

Summary of algorithms riterion Breadth- Uniform- Depth- Depth- Iterative First ost First Limited Deepening omplete? Yes Yes No Yes, if l d Yes Time b d+1 b /ɛ b m b l b d Space b d+1 b /ɛ bm bl bd Optimal? Yes Yes No No Yes hapter 1 12

Repeated states Failure to detect repeated states can turn a linear problem into an exponential one! A A B B B D hapter 1 13

Graph search function Graph-Search( problem, fringe) returns a solution, or failure closed an empty set fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test[problem](State[node]) then return node if State[node] is not in closed then add State[node] to closed fringe InsertAll(Expand(node, problem), fringe) end hapter 1 14

Summary Problem formulation usually requires abstracting away real-world details to define a state space that can feasibly be explored Variety of uninformed search strategies Iterative deepening search uses only linear space and not much more time than other uninformed algorithms Informed search algorithms hapter 4, Sections 1 2, 4 15

hapter 4, Sections 1 2, 4 hapter 4, Sections 1 2, 4 16

Outline Best-first search A search Heuristics Hill-climbing Simulated annealing hapter 4, Sections 1 2, 4 17

Review: Tree search function Tree-Search( problem, fringe) returns a solution, or failure fringe Insert(Make-Node(Initial-State[problem]), fringe) loop do if fringe is empty then return failure node Remove-Front(fringe) if Goal-Test[problem] applied to State(node) succeeds return node fringe InsertAll(Expand(node, problem), fringe) A strategy is defined by picking the order of node expansion hapter 4, Sections 1 2, 4 18

Best-first search Idea: use an evaluation function for each node estimate of desirability Expand most desirable unexpanded node Implementation: fringe is a queue sorted in decreasing order of desirability Special cases: greedy search A search hapter 4, Sections 1 2, 4 19

Romania with step costs in km Oradea 71 Neamt Zerind 75 151 Arad 140 118 Timisoara 111 Lugoj 70 Mehadia 75 120 Dobreta Sibiu 99 Fagaras 80 Rimnicu Vilcea 97 Pitesti 211 146 101 85 138 Bucharest 90 raiova Giurgiu 87 Iasi 92 142 98 Urziceni Vaslui Hirsova 86 Eforie Straight line distance to Bucharest Arad 366 Bucharest 0 raiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 hapter 4, Sections 1 2, 4 20

Greedy search Evaluation function h(n) (heuristic) = estimate of cost from n to the closest goal E.g., h SLD (n) = straight-line distance from n to Bucharest Greedy search expands the node that appears to be closest to goal hapter 4, Sections 1 2, 4 21

Greedy search example Arad 366 hapter 4, Sections 1 2, 4 22

Greedy search example Arad Sibiu Timisoara Zerind 253 329 374 hapter 4, Sections 1 2, 4 23

Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 176 380 193 hapter 4, Sections 1 2, 4 24

Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 380 193 Sibiu Bucharest 253 0 hapter 4, Sections 1 2, 4 25

Properties of greedy search omplete?? hapter 4, Sections 1 2, 4 26

Properties of greedy search omplete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt omplete in finite space with repeated-state checking Time?? hapter 4, Sections 1 2, 4 27

Properties of greedy search omplete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt omplete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? hapter 4, Sections 1 2, 4 28

Properties of greedy search omplete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt omplete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? O(b m ) keeps all nodes in memory Optimal?? hapter 4, Sections 1 2, 4 29

Properties of greedy search omplete?? No can get stuck in loops, e.g., Iasi Neamt Iasi Neamt omplete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? O(b m ) keeps all nodes in memory Optimal?? No hapter 4, Sections 1 2, 4 30

A search Idea: avoid expanding paths that are already expensive Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost to goal from n f(n) = estimated total cost of path through n to goal A search uses an admissible heuristic i.e., h(n) h (n) where h (n) is the true cost from n. (Also require h(n) 0, so h(g) = 0 for any goal G.) E.g., h SLD (n) never overestimates the actual road distance Theorem: A search is optimal hapter 4, Sections 1 2, 4 31

A search example Arad 366=0+366 hapter 4, Sections 1 2, 4 32

A search example Arad Sibiu 393=140+253 Timisoara Zerind 447=118+329 449=75+374 hapter 4, Sections 1 2, 4 33

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 415=239+176 671=291+380 413=220+193 hapter 4, Sections 1 2, 4 34

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras 646=280+366 415=239+176 Oradea 671=291+380 Rimnicu Vilcea raiova Pitesti Sibiu 526=366+160 417=317+100 553=300+253 hapter 4, Sections 1 2, 4 35

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 671=291+380 Sibiu Bucharest raiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 417=317+100 553=300+253 hapter 4, Sections 1 2, 4 36

A search example Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea Rimnicu Vilcea 646=280+366 671=291+380 Sibiu Bucharest raiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 553=300+253 Bucharest raiova Rimnicu Vilcea 418=418+0 615=455+160 607=414+193 hapter 4, Sections 1 2, 4 37

Optimality of A (standard proof) Suppose some suboptimal goal G 2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G 1. Start n G G 2 f(g 2 ) = g(g 2 ) since h(g 2 ) = 0 > g(g 1 ) since G 2 is suboptimal f(n) since h is admissible Since f(g 2 ) > f(n), A will never select G 2 for expansion hapter 4, Sections 1 2, 4 38

Optimality of A (more useful) Lemma: A expands nodes in order of increasing f value Gradually adds f-contours of nodes (cf. breadth-first adds layers) ontour i has all nodes with f = f i, where f i < f i+1 O Z N A I T 380 400 S R F V L P D M 420 G B U H E hapter 4, Sections 1 2, 4 39

Properties of A omplete?? hapter 4, Sections 1 2, 4 40

Properties of A omplete?? Yes, unless there are infinitely many nodes with f f(g) Time?? hapter 4, Sections 1 2, 4 41

Properties of A omplete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? hapter 4, Sections 1 2, 4 42

Properties of A omplete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Keeps all nodes in memory Optimal?? hapter 4, Sections 1 2, 4 43

Properties of A omplete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Keeps all nodes in memory Optimal?? Yes cannot expand f i+1 until f i is finished A expands all nodes with f(n) < A expands some nodes with f(n) = A expands no nodes with f(n) > hapter 4, Sections 1 2, 4 44

A heuristic is consistent if Proof of lemma: onsistency h(n) c(n, a, n ) + h(n ) If h is consistent, we have f(n ) = g(n ) + h(n ) = g(n) + c(n, a, n ) + h(n ) g(n) + h(n) = f(n) I.e., f(n) is nondecreasing along any path. n c(n,a,n ) n h(n ) h(n) G hapter 4, Sections 1 2, 4 45

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State h 1 (S) =?? h 2 (S) =?? hapter 4, Sections 1 2, 4 46

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) 7 2 4 51 2 3 5 6 4 5 6 8 3 1 7 8 Start State Goal State h 1 (S) =?? 7 h 2 (S) =?? 4+0+3+3+1+0+2+1 = 14 hapter 4, Sections 1 2, 4 47

Dominance If h 2 (n) h 1 (n) for all n (both admissible) then h 2 dominates h 1 and is better for search Typical search costs: d = 14 IDS = 3,473,941 nodes A (h 1 ) = 539 nodes A (h 2 ) = 113 nodes d = 24 IDS 54,000,000,000 nodes A (h 1 ) = 39,135 nodes A (h 2 ) = 1,641 nodes hapter 4, Sections 1 2, 4 48

Relaxed problems Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h 1 (n) gives the shortest solution If the rules are relaxed so that a tile can move to any adjacent square, then h 2 (n) gives the shortest solution Key point: the optimal solution cost of a relaxed problem is no greater than the optimal solution cost of the real problem hapter 4, Sections 1 2, 4 49

Relaxed problems contd. Well-known example: travelling salesperson problem (TSP) Find the shortest tour visiting all cities exactly once Minimum spanning tree can be computed in O(n 2 ) and is a lower bound on the shortest (open) tour hapter 4, Sections 1 2, 4 50

Iterative improvement algorithms In many optimization problems, path is irrelevant; the goal state itself is the solution Then state space = set of complete configurations; find optimal configuration, e.g., TSP or, find configuration satisfying constraints, e.g., timetable In such cases, can use iterative improvement algorithms; keep a single current state, try to improve it onstant space, suitable for online as well as offline search hapter 4, Sections 1 2, 4 51

Example: Travelling Salesperson Problem Start with any complete tour, perform pairwise exchanges hapter 4, Sections 1 2, 4 52

Example: n-queens Put n queens on an n n board with no two queens on the same row, column, or diagonal Move a queen to reduce number of conflicts hapter 4, Sections 1 2, 4 53

Hill-climbing (or gradient ascent/descent) Like climbing Everest in thick fog with amnesia function Hill-limbing( problem) returns a state that is a local maximum inputs: problem, a problem local variables: current, a node neighbor, a node current Make-Node(Initial-State[problem]) loop do neighbor a highest-valued successor of current if Value[neighbor] < Value[current] then return State[current] current neighbor end hapter 4, Sections 1 2, 4 54

Hill-climbing contd. Problem: depending on initial state, can get stuck on local maxima value global maximum local maximum states In continuous spaces, problems w/ choosing step size, slow convergence hapter 4, Sections 1 2, 4 55

Simulated annealing Idea: escape local maxima by allowing some bad moves but gradually decrease their size and frequency function Simulated-Annealing( problem, schedule) returns a solution state inputs: problem, a problem schedule, a mapping from time to temperature local variables: current, a node next, a node T, a temperature controlling prob. of downward steps current Make-Node(Initial-State[problem]) for t 1 to do T schedule[t] if T = 0 then return current next a randomly selected successor of current E Value[next] Value[current] if E > 0 then current next else current next only with probability e E/T hapter 4, Sections 1 2, 4 56

Properties of simulated annealing At fixed temperature T, state occupation probability reaches Boltzman distribution p(x) = αe E(x) kt T decreased slowly enough = always reach best state Is this necessarily an interesting guarantee?? Devised by Metropolis et al., 1953, for physical process modelling Widely used in VLSI layout, airline scheduling, etc. hapter 4, Sections 1 2, 4 57