Chapter 4 (Section 4.3, …) 2 nd Edition or Chapter 4 (3 rd Edition) Local Search and Optimization.

Slides:



Advertisements
Similar presentations
Informed search algorithms
Advertisements

Local Search and Optimization
Local Search Algorithms
LOCAL SEARCH AND CONTINUOUS SEARCH. Local search algorithms  In many optimization problems, the path to the goal is irrelevant ; the goal state itself.
CSC344: AI for Games Lecture 5 Advanced heuristic search Patrick Olivier
Local search algorithms
Local search algorithms
Two types of search problems
Iterative improvement algorithms Prof. Tuomas Sandholm Carnegie Mellon University Computer Science Department.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
CS 4700: Foundations of Artificial Intelligence
Trading optimality for speed…
Introduction to Artificial Intelligence Heuristic Search Ruth Bergman Fall 2002.
Review Best-first search uses an evaluation function f(n) to select the next node for expansion. Greedy best-first search uses f(n) = h(n). Greedy best.
CSC344: AI for Games Lecture 4: Informed search
Informed Search Chapter 4 Adapted from materials by Tim Finin, Marie desJardins, and Charles R. Dyer CS 63.
Beyond Classical Search (Local Search) R&N III: Chapter 4
Informed Search Next time: Search Application Reading: Machine Translation paper under Links Username and password will be mailed to class.
Optimization via Search CPSC 315 – Programming Studio Spring 2008 Project 2, Lecture 4 Adapted from slides of Yoonsuck Choe.
1 CS 2710, ISSP 2610 R&N Chapter 4.1 Local Search and Optimization.
Local Search and Optimization
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Informed Search Chapter 4 (b)
1 Local search and optimization Local search= use single current state and move to neighboring states. Advantages: –Use very little memory –Find often.
Search CSE When you can’t use A* Hill-climbing Simulated Annealing Other strategies 2 person- games.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
An Introduction to Artificial Life Lecture 4b: Informed Search and Exploration Ramin Halavati In which we see how information.
Local Search Algorithms This lecture topic Chapter Next lecture topic Chapter 5 (Please read lecture topic material before and after each lecture.
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
Informed search algorithms
Informed search algorithms
1 Shanghai Jiao Tong University Informed Search and Exploration.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
1 CS 2710, ISSP 2610 Chapter 4, Part 2 Heuristic Search.
Iterative Improvement Algorithm 2012/03/20. Outline Local Search Algorithms Hill-Climbing Search Simulated Annealing Search Local Beam Search Genetic.
Artificial Intelligence for Games Online and local search
Local Search Algorithms
Local Search Pat Riddle 2012 Semester 2 Patricia J Riddle Adapted from slides by Stuart Russell,
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
For Wednesday Read chapter 5, sections 1-4 Homework: –Chapter 3, exercise 23. Then do the exercise again, but use greedy heuristic search instead of A*
Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1.
Local Search and Optimization Presented by Collin Kanaley.
When A* doesn’t work CIS 391 – Intro to Artificial Intelligence A few slides adapted from CS 471, Fall 2004, UBMC (which were adapted from notes by Charles.
4/11/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 4, 4/11/2005 University of Washington, Department of Electrical Engineering Spring 2005.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
Local search algorithms In many optimization problems, the state space is the space of all possible complete solutions We have an objective function that.
Optimization Problems
Announcement "A note taker is being recruited for this class. No extra time outside of class is required. If you take clear, well-organized notes, this.
Local Search. Systematic versus local search u Systematic search  Breadth-first, depth-first, IDDFS, A*, IDA*, etc  Keep one or more paths in memory.
Lecture 6 – Local Search Dr. Muhammad Adnan Hashmi 1 24 February 2016.
Local Search Algorithms and Optimization Problems
Heuristic Search  Best First Search –A* –IDA* –Beam Search  Generate and Test  Local Searches –Hill Climbing  Simple Hill Climbing  Steepest Ascend.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 5 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
Department of Computer Science Lecture 5: Local Search
Local Search and Optimization Chapter 4 Mausam (Based on slides of Padhraic Smyth, Stuart Russell, Rao Kambhampati, Raj Rao, Dan Weld…) 1.
Local Search Algorithms CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Constraints Satisfaction Edmondo Trentin, DIISM. Constraint Satisfaction Problems: Local Search In many optimization problems, the path to the goal is.
Local search algorithms In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution State space = set of "complete"
Department of Computer Science
Informed Search Chapter 4 (b)
Local Search Algorithms
Artificial Intelligence (CS 370D)
Local Search and Optimization
Artificial Intelligence
More on HW 2 (due Jan 26) Again, it must be in Python 2.7.
More on HW 2 (due Jan 26) Again, it must be in Python 2.7.
First Exam 18/10/2010.
Local Search Algorithms
Local Search Algorithms
Presentation transcript:

Chapter 4 (Section 4.3, …) 2 nd Edition or Chapter 4 (3 rd Edition) Local Search and Optimization

Local Search 2 Outline Local search techniques and optimization –Hill-climbing –Gradient methods –Simulated annealing –Genetic algorithms –Issues with local search

Local Search 3 Local search and optimization Previously: systematic exploration of search space. –Path to goal is solution to problem YET, for some problems path is irrelevant. –E.g 8-queens Different algorithms can be used –Local search

Local Search 4 Local search and optimization Local search –Keep track of single current state –Move only to neighboring states –Ignore paths Advantages: –Use very little memory –Can often find reasonable solutions in large or infinite (continuous) state spaces. “Pure optimization” problems –All states have an objective function –Goal is to find state with max (or min) objective value –Does not quite fit into path-cost/goal-state formulation –Local search can do quite well on these problems.

Local Search 5 “Landscape” of search

Local Search 6 Hill-climbing search function HILL-CLIMBING( problem) return a state that is a local maximum input: 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

Local Search 7 Hill-climbing search “a loop that continuously moves in the direction of increasing value” –terminates when a peak is reached –Aka greedy local search Value can be either –Objective function value –Heuristic function value (minimized) Hill climbing does not look ahead of the immediate neighbors of the current state. Can randomly choose among the set of best successors, if multiple have the best value Characterized as “trying to find the top of Mount Everest while in a thick fog”

Local Search 8 Hill climbing and local maxima When local maxima exist, hill climbing is suboptimal Simple (often effective) solution –Multiple random restarts

Local Search 9 Hill-climbing example 8-queens problem, complete-state formulation –All 8 queens on the board in some configuration Successor function: –move a single queen to another square in the same column. Example of a heuristic function h(n): –the number of pairs of queens that are attacking each other (directly or indirectly) –(so we want to minimize this)

Local Search 10 Hill-climbing example Current state: h=17 Shown is the h-value for each possible successor in each column

Local Search 11 A local minimum for 8-queens A local minimum in the 8-queens state space (h=1)

Local Search 12 Other drawbacks Ridge = sequence of local maxima difficult for greedy algorithms to navigate Plateau = an area of the state space where the evaluation function is flat.

Local Search 13 Performance of hill-climbing on 8-queens Randomly generated 8-queens starting states… 14% the time it solves the problem 86% of the time it get stuck at a local minimum However… –Takes only 4 steps on average when it succeeds –And 3 on average when it gets stuck –(for a state space with ~17 million states)

Local Search 14 Possible solution…sideways moves If no downhill (uphill) moves, allow sideways moves in hope that algorithm can escape –Need to place a limit on the possible number of sideways moves to avoid infinite loops For 8-queens –Now allow sideways moves with a limit of 100 –Raises percentage of problem instances solved from 14 to 94% –However…. 21 steps for every successful solution 64 for each failure

Local Search 15 Hill-climbing variations Stochastic hill-climbing –Random selection among the uphill moves. –The selection probability can vary with the steepness of the uphill move. First-choice hill-climbing –stochastic hill climbing by generating successors randomly until a better one is found –Useful when there are a very large number of successors Random-restart hill-climbing –Tries to avoid getting stuck in local maxima.

Local Search 16 Hill-climbing with random restarts Different variations –For each restart: run until termination v. run for a fixed time –Run a fixed number of restarts or run indefinitely Analysis –Say each search has probability p of success E.g., for 8-queens, p = 0.14 with no sideways moves –Expected number of restarts? –Expected number of steps taken?

Local Search 17 Expected number of restarts Probability of Success = p Number of restarts = 1 / p This means 1 successful iteration after (1/p – 1) failed iterations Let avg. number of steps in a failure iteration = f and avg. number of steps in a successful iteration = s Therefore, expected number of steps in random-restart hill climbing = 1 * s + (1/p – 1) f So for 8-queens, p = 14%, s = 4, f = 3, Expected no of moves = 1 * 4 + (1/ ) * 3 = 22 With sideways moves, p = 94%, s = 21, f = 64 Expected no of moves = 1 * 21 + (1/ ) * 64 = 25

Local Search 18 Local beam search Keep track of k states instead of one –Initially: k randomly selected states –Next: determine all successors of k states –If any of successors is goal  finished –Else select k best from successors and repeat. Major difference with random-restart search –Information is shared among k search threads. Can suffer from lack of diversity. –Stochastic beam search choose k successors proportional to state quality.

Local Search 19 Gradient Descent Assume we have some cost-function: and we want minimize over continuous variables X1,X2,..,Xn 1. Compute the gradient : 2. Take a small step downhill in the direction of the gradient: 3. Check if 4. If true then accept move, if not reject. 5. Repeat.

Local Search 20 Learning as optimization Many machine learning problems can be cast as optimization Example: –Training data D = {(x 1,c 1 ),………(x n, c n )} where x i = feature or attribute vector and c i = class label (say binary-valued) –We have a model (a function or classifier) that maps from x to c e.g., sign( w. x’ )  {-1, +1} –We can measure the error E(w) for any settig of the weights w, and given a training data set D –Optimization problem: find the weight vector that minimizes E(w) (general idea is “empirical error minimization”)

Local Search 21 Learning a minimum error decision boundary

Local Search 22 Search using Simulated Annealing Simulated Annealing = hill-climbing with non-deterministic search Basic ideas: –like hill-climbing identify the quality of the local improvements –instead of picking the best move, pick one randomly –say the change in objective function is  –if  is positive, then move to that state –otherwise: move to this state with probability proportional to  thus: worse moves (very large negative ) are executed less often –however, there is always a chance of escaping from local maxima –over time, make it less likely to accept locally bad moves –(Can also make the size of the move random as well, i.e., allow “large” steps in state space)

Local Search 23 Physical Interpretation of Simulated Annealing A Physical Analogy: imagine letting a ball roll downhill on the function surface –this is like hill-climbing (for minimization) now imagine shaking the surface, while the ball rolls, gradually reducing the amount of shaking –this is like simulated annealing Annealing = physical process of cooling a liquid or metal until particles achieve a certain frozen crystal state simulated annealing: – free variables are like particles – seek “low energy” (high quality) configuration –get this by slowly reducing temperature T, which particles move around randomly

Local Search 24 Simulated annealing function SIMULATED-ANNEALING( problem, schedule) return a solution state input: problem, a problem schedule, a mapping from time to temperature local variables: current, a node. next, a node. T, a “temperature” controlling the probability 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

Local Search 25 More Details on Simulated Annealing –Lets say there are 3 moves available, with changes in the objective function of d1 = -0.1, d2 = 0.5, d3 = -5. (Let T = 1). –pick a move randomly: if d2 is picked, move there. if d1 or d3 are picked, probability of move = exp(d/T) move 1: prob1 = exp(-0.1) = 0.9, –i.e., 90% of the time we will accept this move move 3: prob3 = exp(-5) = 0.05 –i.e., 5% of the time we will accept this move –T = “temperature” parameter high T => probability of “locally bad” move is higher low T => probability of “locally bad” move is lower typically, T is decreased as the algorithm runs longer –i.e., there is a “temperature schedule”

Local Search 26 Simulated Annealing in Practice –method proposed in 1983 by IBM researchers for solving VLSI layout problems (Kirkpatrick et al, Science, 220: , 1983). theoretically will always find the global optimum (the best solution) –useful for some problems, but can be very slow –slowness comes about because T must be decreased very gradually to retain optimality In practice how do we decide the rate at which to decrease T? (this is a practical problem with this method)

Local Search 27 Genetic algorithms Different approach to other search algorithms –A successor state is generated by combining two parent states A state is represented as a string over a finite alphabet (e.g. binary) –8-queens State = position of 8 queens each in a column => 8 x log(8) bits = 24 bits (for binary representation) Start with k randomly generated states (population) Evaluation function (fitness function). –Higher values for better states. –Opposite to heuristic function, e.g., # non-attacking pairs in 8-queens Produce the next generation of states by “simulated evolution” –Random selection –Crossover –Random mutation

Local Search 28 Genetic algorithms Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28) 24/( ) = 31% 23/( ) = 29% etc 4 states for 8-queens problem 2 pairs of 2 states randomly selected based on fitness. Random crossover points selected New states after crossover Random mutation applied

Local Search 29 Genetic algorithms Has the effect of “jumping” to a completely different new part of the search space (quite non-local)

Local Search 30 Genetic algorithm pseudocode function GENETIC_ALGORITHM( population, FITNESS-FN) return an individual input: population, a set of individuals FITNESS-FN, a function which determines the quality of the individual repeat new_population  empty set loop for i from 1 to SIZE(population) do x  RANDOM_SELECTION(population, FITNESS_FN) y  RANDOM_SELECTION(population, FITNESS_FN) child  REPRODUCE(x,y) if (small random probability) then child  MUTATE(child ) add child to new_population population  new_population until some individual is fit enough or enough time has elapsed return the best individual

Local Search 31 Comments on genetic algorithms Positive points –Random exploration can find solutions that local search can’t (via crossover primarily) –Appealing connection to human evolution E.g., see related area of genetic programming Negative points –Large number of “tunable” parameters Difficult to replicate performance from one problem to another –Lack of good empirical studies comparing to simpler methods –Useful on some (small?) set of problems but no convincing evidence that GAs are better than hill-climbing w/random restarts in general

Local Search 32 Summary Local search techniques and optimization –Hill-climbing –Gradient methods –Simulated annealing –Genetic algorithms –Issues with local search