TDT4136 Logic and Reasoning Systems

Similar documents
Artificial Intelligence

Informed search algorithms

Artificial Intelligence: Search Part 2: Heuristic search

Informed Search and Exploration

Informed search algorithms

Informed Search Algorithms. Chapter 4

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

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

Informed search algorithms. Chapter 4, Sections 1 2 1

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

Introduction to Artificial Intelligence. Informed Search

Robot Programming with Lisp

CS:4420 Artificial Intelligence

Planning, Execution & Learning 1. Heuristic Search Planning

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

Informed search algorithms. Chapter 4

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

Problem solving and search

Artificial Intelligence

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

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

Informed Search and Exploration

Problem solving and search

COSC343: Artificial Intelligence

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

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

Informed Search and Exploration

CS 380: Artificial Intelligence Lecture #4

Artificial Intelligence. Informed search methods

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

Informed search algorithms

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

Artificial Intelligence. 2. Informed Search

Informed search algorithms. Chapter 4

CS414-Artificial Intelligence

Solving Problems using Search

Informed Search and Exploration

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

ARTIFICIAL INTELLIGENCE. Informed search

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

Problem Solving: Informed Search

Artificial Intelligence

Informed Search and Exploration

Foundations of Artificial Intelligence

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

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

CS:4420 Artificial Intelligence

Informed Search and Exploration for Agents

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Introduction to Computer Science and Programming for Astronomers

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

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

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. (Based on slides by Oren Etzioni, Stuart Russell)

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

Outline. Best-first search

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

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: Intelligent Search

Outline. Best-first search

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

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

Artificial Intelligence Informed search. Peter Antal

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

Foundations of Artificial Intelligence

Introduction to Artificial Intelligence (G51IAI)

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

Informed search algorithms

Informed search algorithms

Problem solving and search

Part I. Instructor: Dr. Wei Ding. Uninformed Search Strategies can find solutions to problems by. Informed Search Strategies

Informed Search and Exploration

Lecture 4: Informed/Heuristic Search

Searching and NetLogo

CS 771 Artificial Intelligence. Informed Search

Artificial Intelligence

Artificial Intelligence

Local Search and Optimization Chapter 4. Mausam (Based on slides of Padhraic Smyth, Stuart Russell, Rao Kambhampati, Raj Rao, Dan Weld )

Local Search and Optimization Chapter 4. Mausam (Based on slides of Padhraic Smyth, Stuart Russell, Rao Kambhampati, Raj Rao, Dan Weld )

Artificial Intelligence, CS, Nanjing University Spring, 2016, Yang Yu. Lecture 5: Search 4.

Local Search and Optimization Chapter 4. Mausam (Based on slides of Padhraic Smyth, Stuart Russell, Rao Kambhampati, Raj Rao, Dan Weld )

Solving Problems by Searching

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

Artificial Intelligence

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

Solving problems by searching

Informed/Heuristic Search

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

Informed search. Soleymani. CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2016

DFS. Depth-limited Search

Informed search algorithms

Contents. Foundations of Artificial Intelligence. General Algorithm. Best-First Search

Artificial Intelligence

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

4 INFORMED SEARCH AND EXPLORATION. 4.1 Heuristic Search Strategies

Informed search methods

Informed Search. Notes about the assignment. Outline. Tree search: Reminder. Heuristics. Best-first search. Russell and Norvig chap.

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

Problem solving and search

Transcription:

TDT4136 Logic and Reasoning Systems Chapter 3 & 4.1 - Informed Search and Exploration Lester Solbakken solbakke@idi.ntnu.no Norwegian University of Science and Technology 18.10.2011 1 Lester Solbakken TDT4136 Logic and Reasoning Systems

Outline 1 Best-first search 2 A* search 3 Heuristics 4 Hill-climbing 5 Simulated annealing 6 Genetic algorithms (briefly) 2 Lester Solbakken TDT4136 Logic and Reasoning Systems

Review: Tree search Best-first 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 3 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search 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 4 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Romania with step costs in km Oradea 71 Neamt 87 Zerind 75 151 Iasi Arad 140 92 Sibiu 99 Fagaras 118 80 Vaslui Timisoara Rimnicu Vilcea 111 142 211 Lugoj 97 Pitesti 70 98 146 Hirsova Mehadia 101 85 Urziceni 75 138 86 Bucharest 120 Dobreta 90 Craiova Eforie Giurgiu Straight line distance to Bucharest Arad 366 Bucharest 0 Craiova 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 5 Lester Solbakken TDT4136 Logic and Reasoning Systems

Greedy search Best-first 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 6 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Greedy search example Arad 366 7 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Greedy search example Arad Sibiu Timisoara Zerind 253 329 374 8 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 176 380 193 9 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Greedy search example Arad Sibiu Timisoara Zerind 329 374 Arad Fagaras Oradea Rimnicu Vilcea 366 380 193 Sibiu Bucharest 253 0 10 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Properties of greedy search Complete?? 11 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Properties of greedy search Complete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? 12 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Properties of greedy search Complete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? O(b m ), but a good heuristic can give dramatic improvement Space?? 13 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Properties of greedy search Complete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt Complete 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?? 14 Lester Solbakken TDT4136 Logic and Reasoning Systems

Best-first search Properties of greedy search Complete?? No can get stuck in loops, e.g., with Oradea as goal, Iasi Neamt Iasi Neamt Complete 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 15 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search 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 16 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search Arad 366=0+366 17 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search Arad Sibiu 393=140+253 Timisoara Zerind 447=118+329 449=75+374 18 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search 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 19 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad Fagaras Oradea 646=280+366 415=239+176 671=291+380 Rimnicu Vilcea Craiova Pitesti Sibiu 526=366+160 417=317+100 553=300+253 20 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad 646=280+366 Fagaras Oradea 671=291+380 Rimnicu Vilcea Sibiu Bucharest Craiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 417=317+100 553=300+253 21 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search example A* search Arad Sibiu Timisoara Zerind 447=118+329 449=75+374 Arad 646=280+366 Fagaras Oradea 671=291+380 Rimnicu Vilcea Sibiu Bucharest Craiova Pitesti Sibiu 591=338+253 450=450+0 526=366+160 553=300+253 Bucharest Craiova Rimnicu Vilcea 418=418+0 615=455+160 607=414+193 22 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search 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 23 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search 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) Contour 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 C 420 G B U H E 24 Lester Solbakken TDT4136 Logic and Reasoning Systems

Properties of A* A* search Complete?? 25 Lester Solbakken TDT4136 Logic and Reasoning Systems

Properties of A* A* search Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? 26 Lester Solbakken TDT4136 Logic and Reasoning Systems

Properties of A* A* search Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of solution.] Space?? 27 Lester Solbakken TDT4136 Logic and Reasoning Systems

Properties of A* A* search Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of solution.] Space?? Keeps all nodes in memory Optimal?? 28 Lester Solbakken TDT4136 Logic and Reasoning Systems

Properties of A* A* search Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of solution.] 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) < C A* expands some nodes with f(n) = C A* expands no nodes with f(n) > C A* is optimally efficient for any given consistent heuristic 29 Lester Solbakken TDT4136 Logic and Reasoning Systems

A* search Proof of lemma: Consistency / Monotonicity A heuristic is consistent / monotonous if 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) n c(n,a,n ) n h(n ) h(n) G I.e., f(n) is nondecreasing along any path (triangle inequality). 30 Lester Solbakken TDT4136 Logic and Reasoning Systems

Admissible heuristics Heuristics E.g., for the 8-puzzle: 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) =?? 31 Lester Solbakken TDT4136 Logic and Reasoning Systems

Admissible heuristics Heuristics E.g., for the 8-puzzle: 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) =?? 6 h 2 (S) =?? 4+0+3+3+1+0+2+1 = 14 32 Lester Solbakken TDT4136 Logic and Reasoning Systems

Dominance Heuristics 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 Given any admissible heuristics h a, h b, h(n) = max(h a (n),h b (n)) is also admissible and dominates h a, h b 33 Lester Solbakken TDT4136 Logic and Reasoning Systems

Relaxed problems Heuristics 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 34 Lester Solbakken TDT4136 Logic and Reasoning Systems

Hill-climbing 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 Constant space, suitable for online as well as offline search 35 Lester Solbakken TDT4136 Logic and Reasoning Systems

Hill-climbing Example: Travelling Salesperson Problem Start with any complete tour, perform pairwise exchanges Variants of this approach get within 1% of optimal very quickly with thousands of cities 36 Lester Solbakken TDT4136 Logic and Reasoning Systems

Example: n-queens Hill-climbing 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 h = 5 h = 2 h = 0 Almost always solves n-queens problems almost instantaneously for very large n, e.g., n=1million 37 Lester Solbakken TDT4136 Logic and Reasoning Systems

Hill-climbing Hill-climbing (or gradient ascent/descent) Like climbing Everest in thick fog with amnesia function Hill-Climbing( 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 38 Lester Solbakken TDT4136 Logic and Reasoning Systems

Hill-climbing contd. Hill-climbing Useful to consider state space landscape objective function global maximum shoulder local maximum "flat" local maximum current state state space Random-restart hill climbing overcomes local maxima trivially complete Random sideways moves escape from shoulders loop on flat maxima 39 Lester Solbakken TDT4136 Logic and Reasoning Systems

Simulated annealing 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 40 Lester Solbakken TDT4136 Logic and Reasoning Systems

Simulated annealing 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 x because e E(x ) kt /e E(x) kt = e E(x ) E(x) kt 1 for small T Is this necessarily an interesting guarantee?? Devised by Metropolis et al., 1953, for physical process modelling Widely used in VLSI layout, airline scheduling, etc. 41 Lester Solbakken TDT4136 Logic and Reasoning Systems

Local beam search Simulated annealing Idea: keep k states instead of 1; choose top k of all their successors Not the same as k searches run in parallel! Searches that find good states recruit other searches to join them Problem: quite often, all k states end up on same local hill Idea: choose k successors randomly, biased towards good ones Observe the close analogy to natural selection! 42 Lester Solbakken TDT4136 Logic and Reasoning Systems

Genetic algorithms (briefly) Genetic algorithms = stochastic local beam search + generate successors from pairs of states 24748552 24 31% 32752411 32748552 32748152 32752411 23 29% 24748552 24752411 24752411 24415124 20 26% 32752411 32752124 32252124 32543213 11 14% 24415124 24415411 24415417 Fitness Selection Pairs Cross Over Mutation 43 Lester Solbakken TDT4136 Logic and Reasoning Systems

Genetic algorithms (briefly) Genetic algorithms contd. GAs require states encoded as strings (GPs use programs) Crossover helps iff substrings are meaningful components + = GAs evolution: e.g., real genes encode replication machinery! 44 Lester Solbakken TDT4136 Logic and Reasoning Systems

Summary Genetic algorithms (briefly) Heuristic functions estimate costs of shortest paths Good heuristics can dramatically reduce search cost Greedy best-first search expands lowest h incomplete and not always optimal A* search expands lowest g +h complete and optimal also optimally efficient (up to tie-breaks, for forward search) Admissible heuristics can be derived from exact solution of relaxed problems Iterative improvement algorithms can be used when the path to the goal state is irrelevant 45 Lester Solbakken TDT4136 Logic and Reasoning Systems