Informed search algorithms

Similar documents
Heuristic search, A* CS171, Winter 2018 Introduction to Artificial Intelligence Prof. Richard Lathrop. Reading: R&N

Heuris'c search, A* CS171, Fall 2016 Introduc'on to Ar'ficial Intelligence Prof. Alexander Ihler. Reading: R&N

Game Programming. Bing-Yu Chen National Taiwan University

Approximating the position of a hidden agent in a graph

Controllability of Complex Networks. Yang-Yu Liu, Jean-Jacques Slotine, Albert-Laszlo Barbasi Presented By Arindam Bhattacharya

CS108L Computer Science for All Module 7: Algorithms

Cat Swarm Optimization

Dynamic Programming for Linear Time Incremental Parsing

LABORATORY EXERCISE 7: CLADISTICS I

A Column Generation Algorithm to Solve a Synchronized Log-Truck Scheduling Problem

Biology 164 Laboratory

Genetics Worksheet # 1 Answers name:

Lab 10: Color Sort Turtles not yet sorted by color

Virtual Genetics Lab (VGL)

THE PIGEONHOLE PRINCIPLE AND ITS APPLICATIONS

Design of 32 bit Parallel Prefix Adders

Lecture 4: Controllability and observability

Comparative Analysis of Adders Parallel-Prefix Adder for Their Area, Delay and Power Consumption

PROGRESS REPORT for COOPERATIVE BOBCAT RESEARCH PROJECT. Period Covered: 1 April 30 June Prepared by

Optimizing Phylogenetic Supertrees Using Answer Set Programming

Chapter VII Non-linear SSI analysis of Structure-Isolated footings -soil system

Nathan A. Thompson, Ph.D. Adjunct Faculty, University of Cincinnati Vice President, Assessment Systems Corporation

Code Documentation MFA (Movable Finite Automata) Eric Klemchak CS391/CS392

Rules and Course Requirements by Level/Title. Barn Hunt Instinct (RATI)

Lecture 1: Turtle Graphics. the turtle and the crane and the swallow observe the time of their coming; Jeremiah 8:7

BioSci 110, Fall 08 Exam 2

Recurrent neural network grammars. Slide credits: Chris Dyer, Adhiguna Kuncoro

Functions Introduction to Functions 7.2 One-to-One, Onto, Inverse functions. mjarrar Watch this lecture and download the slides

Bell Ringer. Which features do you have that match your mother? Your father? Which of the following features do you have?

PARADE COLLEGE Mathematics Methods 3&4-CAS Probability Analysis SAC 2

These small issues are easily addressed by small changes in wording, and should in no way delay publication of this first- rate paper.

NATURA CAGE-FREE. Modern aviary system for barn and free range egg production

Shepherding Behaviors with Multiple Shepherds

LAB. NATURAL SELECTION

Part One: Introduction to Pedigree teaches students how to use Pedigree tools to create and analyze pedigrees.

DOGS SEEN PER KM MONITORING OF A DOG POPULATION MANAGEMENT INTERVENTION

Numeracy Practice Tests

INFO 1103 Homework Project 2

UK HOUSE MARTIN SURVEY 2015

The Kaggle Competitions: An Introduction to CAMCOS Fall 2015

Answers to Questions about Smarter Balanced 2017 Test Results. March 27, 2018

The courses are divided into sections or exercises: Pen or sheepfold Difficult passages Handling and maneuvering Stopping the flock

24 The Pigeonhole Principle

EVOLUTIONARY GENETICS (Genome 453) Midterm Exam Name KEY

Design of a High Speed Adder

Population Dynamics: Predator/Prey Teacher Version

Challenges and opportunities for rapidly advancing reporting and improving inpatient antibiotic use in the U.S.

Implementation and Estimation of Delay, Power and Area for Parallel Prefix Adders

Shepherding Behaviors with Multiple Shepherds

Phenotypic and Genetic Variation in Rapid Cycling Brassica Parts III & IV

Population Dynamics: Predator/Prey Teacher Version

Design and Estimation of delay, power and area for Parallel prefix adders

Modeling and Control of Trawl Systems

Building Rapid Interventions to reduce antimicrobial resistance and overprescribing of antibiotics (BRIT)

A Discrete-Event Simulation Study of the Re-emergence of S. vulgaris in Horse Farms Adopting Selective Therapy

TOPIC CLADISTICS

The City School. Learn Create Program

World Animal awareness Society Wa2s.org

Analysis of Sampling Technique Used to Investigate Matching of Dorsal Coloration of Pacific Tree Frogs Hyla regilla with Substrate Color

Machine Learning.! A completely different way to have an. agent acquire the appropriate abilities to solve a particular goal is via machine learning.

Lesson 1.3. One Way Use compatible numbers. Estimate Sums Essential Question How can you use compatible numbers and rounding to estimate sums?

Yes, heterozygous organisms can pass a dominant allele onto the offspring. Only one dominant allele is needed to have the dominant genotype.

Hiking Shoes OR, HOW EQUIPMENT MATTERS

January 30, Genetics.notebook

Lab 7: Experimenting with Life and Death

Genetics Lab #4: Review of Mendelian Genetics

Name: Period: Student Exploration: Mouse Genetics (One Trait)

Integrated Math 1 Honors Module 2 Honors Systems of Equations and Inequalities

LABORATORY EXERCISE 6: CLADISTICS I

Dogs and More Dogs PROGRAM OVERVIEW

Scratch Lesson Plan. Part One: Structure. Part Two: Movement

LONG RANGE PERFORMANCE REPORT. Study Objectives: 1. To determine annually an index of statewide turkey populations and production success in Georgia.

SEDAR31-DW30: Shrimp Fishery Bycatch Estimates for Gulf of Mexico Red Snapper, Brian Linton SEDAR-PW6-RD17. 1 May 2014

Dogs and More Dogs PROGRAM OVERVIEW

Games! June Seven Mathematical Games. HtRaMTC Paul Zeitz,

Progress Report. Okavango Crocodile Monitoring Programme.

Virtual Lab: Sex-Linked Traits Worksheet. 1. Please make sure you have read through all of the information in the

GENETIC DRIFT Carol Beuchat PhD ( 2013)

alternatives to intake

KOOTENAI / SHOSHONE 4-H DOG PROGRAM AGILITY TRAINING RESOURCE GUIDE & EXHIBITION RULES

Comparison of Parallel Prefix Adders Performance in an FPGA

A Novel Approach For Error Detection And Correction Using Prefix-Adders

Genotypes, Phenotypes, Genetics, Oh my!

Design of 16-Bit Adder Structures - Performance Comparison

BBC LEARNING ENGLISH 6 Minute English Water burial

muscles (enhancing biting strength). Possible states: none, one, or two.

5 State of the Turtles

2. Stress analysis in the pair sled - flat insert for bi-condylar endoprosthesis by W.LINK

Age structured models

Dog ecology studies oral vaccination of dogs Burden of rabies

Development of the New Zealand strategy for local eradication of tuberculosis from wildlife and livestock

LONG RANGE PERFORMANCE REPORT. Study Objectives: 1. To determine annually an index of statewide turkey populations and production success in Georgia.

Write down, in figures, how much money Sam and Pat each had.

Z Purlins C Sections Eaves Beams

Design of Low Power and High Speed Carry Select Adder Using Brent Kung Adder

Genetics Lab #4: Review of Mendelian Genetics

Phenotype Observed Expected (O-E) 2 (O-E) 2 /E dotted yellow solid yellow dotted blue solid blue

Mathematical models for dog rabies that include the curtailing effect of human intervention

E. H. Federer and W. T. Federer. Abstract. Some aspects of record keeping and data collection are

All Dogs Parkour Exercises (Interactions) updated to October 6, 2018

Transcription:

Revised by Hankui Zhuo, March 12, 2018 Informed search algorithms Chapter 4 Chapter 4 1

Outline Best-first search A search Heuristics Hill-climbing Simulated annealing Genetic algorithms (briefly) Local search in continuous spaces (very briefly) Chapter 4 2

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 Chapter 4 3

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 Chapter 4 4

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

Greedy search Evaluation function h(n) (heuristic) =estimateofcostfromn 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 Chapter 4 6

Greedy search example 366 71 Neamt 87 75 151 Iasi 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 7

Greedy search example Sibiu Timisoara 253 329 374 71 Neamt 87 75 151 Iasi 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 8

Greedy search example Sibiu Timisoara 329 374 Fagaras Rimnicu Vilcea 366 176 380 193 71 Neamt 87 75 151 Iasi 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 9

Greedy search example Sibiu Timisoara 329 374 Fagaras Rimnicu Vilcea 366 380 193 Sibiu Bucharest 253 0 71 Neamt 87 75 151 Iasi 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 10

Properties of greedy search Complete?? Chapter 4 11

Properties of greedy search Complete?? No can get stuck in loops, e.g., with as goal, Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time?? Chapter 4 12

Properties of greedy search Complete?? No can get stuck in loops, e.g., 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?? Chapter 4 13

Properties of greedy search Complete?? No can get stuck in loops, e.g., 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?? Chapter 4 14

Properties of greedy search Complete?? No can get stuck in loops, e.g., 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 Chapter 4 15

A search Idea: avoid expanding paths that are already expensive Evaluation function f(n) =g(n)+h(n) g(n) =costsofartoreachn 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, soh(g) =0for any goal G.) E.g., h SLD (n) never overestimates the actual road distance Theorem: A search is optimal Chapter 4 16

A search example 366=0+366 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 17

A search example Sibiu 393=140+253 Timisoara 447=118+329 449=75+374 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 18

A search example Sibiu Timisoara 447=118+329 449=75+374 Fagaras Rimnicu Vilcea 646=280+366 415=239+176 671=291+380 413=220+193 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 19

A search example Sibiu Timisoara 447=118+329 449=75+374 Fagaras 646=280+366 415=239+176 671=291+380 Rimnicu Vilcea Craiova Pitesti Sibiu 526=366+160 417=317+100 553=300+253 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 20

A search example Sibiu Timisoara 447=118+329 449=75+374 646=280+366 Fagaras 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 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 21

A search example Sibiu Timisoara 447=118+329 449=75+374 646=280+366 Fagaras 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 71 Neamt 87 75 151 Iasi 140 92 Sibiu 99 Fagaras 118 Vaslui 80 Rimnicu Vilcea Timisoara 142 111 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 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 374 Chapter 4 22

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 Chapter 4 23

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,wheref 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 Chapter 4 24

Optimality of A (more useful) Lemma: A expands nodes in order of increasing f value Homework: prove it?? Gradually adds f-contours of nodes (cf. breadth-first adds layers) Contour i has all nodes with f = f i,wheref 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 Chapter 4 25

Properties of A Complete?? Chapter 4 26

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Chapter 4 27

Properties of A Complete?? Yes, unless there are infinitely many nodes with f f(g) Time?? Exponential in [relative error in h length of soln.] Space?? Chapter 4 28

Properties of A Complete?? 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?? Chapter 4 29

Properties of A Complete?? 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) <C A expands some nodes with f(n) =C A expands no nodes with f(n) >C Chapter 4 30

A heuristic is consistent if Proofoflemma: Consistency 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 Chapter 4 31

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) =totalmanhattan 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) =?? Chapter 4 32

E.g., for the 8-puzzle: Admissible heuristics h 1 (n) = number of misplaced tiles h 2 (n) =totalmanhattan 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 Chapter 4 33

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 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 Chapter 4 34

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 Chapter 4 35

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 Chapter 4 36

Summary 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 Chapter 4 37

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 Chapter 4 38

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 Chapter 4 39

Example: n-queens Put n queens on an n n boardwithnotwoqueensonthesame 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 Chapter 4 40

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, aproblem 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 Chapter 4 41

Hill-climbing contd. 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 Chapter 4 42

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, aproblem 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 =0then 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 Chapter 4 43

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. Chapter 4 44

Local beam search 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! Chapter 4 45

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 Chapter 4 46

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! Chapter 4 47

Continuous state spaces Suppose we want to site three airports in Romania: 6-D state space defined by (x 1,y 2 ), (x 2,y 2 ), (x 3,y 3 ) objective function f(x 1,y 2,x 2,y 2,x 3,y 3 ) = sum of squared distances from each city to nearest airport Discretization methods turn continuous space into discrete space, e.g., empirical gradient considers ±δ change in each coordinate Gradient methods compute f = f, f, f, f, f, f x 1 y 1 x 2 y 2 x 3 y 3 to increase/reduce f, e.g., by x x + α f(x) Sometimes can solve for f(x) =0exactly (e.g., with one city). Newton Raphson (1664, 1690) iterates x x H 1 f (x) f(x) to solve f(x) =0,whereH ij = 2 f/ x i x j Chapter 4 48

End of Chapter 4 Thanks & Questions! Chapter 4 49