Beyond Classical Search (Local Search) R&N III: Chapter 4

Slides:



Advertisements
Similar presentations
Informed search algorithms
Advertisements

Local Search and Optimization
Local Search Algorithms
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.
Informed Search Methods Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 4 Spring 2008.
Informed Search Methods Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 4 Spring 2005.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
Trading optimality for speed…
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.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 5 Jim Martin.
Informed Search Next time: Search Application Reading: Machine Translation paper under Links Username and password will be mailed to class.
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.
When A* fails – Hill climbing, simulated annealing Genetic algorithms
Search CSE When you can’t use A* Hill-climbing Simulated Annealing Other strategies 2 person- games.
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.
B EYOND C LASSICAL S EARCH Instructor: Kris Hauser 1.
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.
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.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
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.
A General Introduction to Artificial Intelligence.
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.
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.
Chapter 4 (Section 4.3, …) 2 nd Edition or Chapter 4 (3 rd Edition) Local Search and Optimization.
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.
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"
Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Department of Computer Science
Informed Search Chapter 4 (b)
Local Search Algorithms
Artificial Intelligence (CS 370D)
Local Search and Optimization
Informed Search Chapter 4 (b)
Informed search algorithms
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.
Local Search Algorithms
Local Search Algorithms
Presentation transcript:

Beyond Classical Search (Local Search) R&N III: Chapter 4

Local Search Light-memory search method No search tree; only the current state is represented! Only applicable to problems where the path is irrelevant (e.g., 8-queen), unless the path is encoded in the state Many similarities with optimization techniques

Hill-climbing search “is a loop that continuously moves in the direction of increasing value” It terminates when a peak is reached. Hill climbing does not look ahead of the immediate neighbors of the current state. Basic Hill-climbing – “Like climbing Everest in a thick fog with amnesia” 17 april 2017 AI 1

(Steepest Ascent) Hill-climbing search “is a loop that continuously moves in the direction of increasing value” It terminates when a peak is reached. Hill climbing does not look ahead of the immediate neighbors of the current state. Hill-climbing chooses randomly among the set of best successors, if there is more than one. Hill-climbing a.k.a. greedy local search 17 april 2017 AI 1

Steepest Ascent 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 17 april 2017 AI 1

Hill-climbing example 8-queens problem (complete-state formulation). Successor function: move a single queen to another square in the same column. Heuristic function h(n): the number of pairs of queens that are attacking each other (directly or indirectly). 17 april 2017 AI 1

Hill-climbing example a) shows a state of h=17 and the h-value for each possible successor. b) A local minimum in the 8-queens state space (h=1). AI 1 17 april 201717 april 2017

Drawbacks Ridge = sequence of local maxima difficult for greedy algorithms to navigate Plateaux = an area of the state space where the evaluation function is flat. Gets stuck 86% of the time. AI 1 17 april 201717 april 2017

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 cfr. stochastic hill climbing by generating successors randomly until a better one is found. Random-restart hill-climbing Tries to avoid getting stuck in local maxima. 17 april 2017 AI 1

Steepest Descent S  initial state Repeat: Similar to: S’  arg minS’SUCCESSORS(S) {h(S’)} if GOAL?(S’) return S’ if h(S’)  h(S) then S  S’ else return failure Similar to: - hill climbing with –h - gradient descent over continuous space

Random Restart Application: 8-Queen Repeat n times: Pick an initial state S at random with one queen in each column Repeat k times: If GOAL?(S) then return S Pick an attacked queen Q at random Move Q it in its column to minimize the number of attacking queens is minimum  new S [min-conflicts heuristic] Return failure 1 2 3 2

Application: 8-Queen Why does it work ??? There are many goal states that are well-distributed over the state space If no solution has been found after a few steps, it’s better to start it all over again. Building a search tree would be much less efficient because of the high branching factor Running time almost independent of the number of queens Repeat n times: Pick an initial state S at random with one queen in each column Repeat k times: If GOAL?(S) then return S Pick an attacked queen Q at random Move Q it in its column to minimize the number of attacking queens is minimum  new S 1 2 3 2

Steepest Descent S  initial state Repeat: S’  arg minS’SUCCESSORS(S) {h(S’)} if GOAL?(S’) return S’ if h(S’)  h(S) then S  S’ else return failure may easily get stuck in local minima Random restart (as in n-queen example) Monte Carlo descent

Simulated annealing Escape local maxima by allowing “bad” moves. Idea: but gradually decrease their size and frequency. Origin; metallurgical annealing Bouncing ball analogy: Shaking hard (= high temperature). Shaking less (= lower the temperature). If T decreases slowly enough, best state is reached. Applied for VLSI layout, airline scheduling, etc. 17 april 2017 AI 1

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 17 april 2017 AI 1

Local beam search Keep track of k states instead of one Initially: k random 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 variant: choose k successors at proportionally to state success. 17 april 2017 AI 1

Genetic algorithms Variant of local beam search with sexual recombination. AI 1 17 april 201717 april 2017

Genetic algorithms Variant of local beam search with sexual recombination. AI 1 17 april 201717 april 2017

Genetic algorithm 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 17 april 2017 AI 1

Exploration problems Until now all algorithms were offline. Offline= solution is determined before executing it. Online = interleaving computation and action Online search is necessary for dynamic and semi-dynamic environments It is impossible to take into account all possible contingencies. Used for exploration problems: Unknown states and actions. e.g. any robot in a new environment, a newborn baby,… 17 april 2017 AI 1

Online search problems Agent knowledge: ACTION(s): list of allowed actions in state s C(s,a,s’): step-cost function (! After s’ is determined) GOAL-TEST(s) An agent can recognize previous states. Actions are deterministic. Access to admissible heuristic h(s) e.g. manhattan distance AI 1 17 april 201717 april 2017

Online search problems Objective: reach goal with minimal cost Cost = total cost of travelled path Competitive ratio=comparison of cost with cost of the solution path if search space is known. Can be infinite in case of the agent accidentally reaches dead ends AI 1 17 april 201717 april 2017

The adversary argument Assume an adversary who can construct the state space while the agent explores it Visited states S and A. What next? Fails in one of the state spaces No algorithm can avoid dead ends in all state spaces. AI 1 17 april 201717 april 2017

Online search agents The agent maintains a map of the environment. Updated based on percept input. This map is used to decide next action. Note difference with e.g. A* An online version can only expand the node it is physically in (local order) 17 april 2017 AI 1

Online DF-search 17 april 2017 AI 1 function ONLINE_DFS-AGENT(s’) return an action input: s’, a percept identifying current state static: result, a table indexed by action and state, initially empty unexplored, a table that lists for each visited state, the action not yet tried unbacktracked, a table that lists for each visited state, the backtrack not yet tried s,a, the previous state and action, initially null if GOAL-TEST(s’) then return stop if s’ is a new state then unexplored[s’]  ACTIONS(s’) if s is not null then do result[a,s]  s’ add s to the front of unbackedtracked[s’] if unexplored[s’] is empty then if unbacktracked[s’] is empty then return stop else a  an action b such that result[b, s’]=POP(unbacktracked[s’]) else a  POP(unexplored[s’]) s  s’ return a 17 april 2017 AI 1

Online DF-search, example Assume maze problem on 3x3 grid. s’ = (1,1) is initial state Result, unexplored (UX), unbacktracked (UB), … are empty S,a are also empty AI 1 17 april 201717 april 2017

Online DF-search, example GOAL-TEST((,1,1))? S not = G thus false (1,1) a new state? True ACTION((1,1)) -> UX[(1,1)] {RIGHT,UP} s is null? True (initially) UX[(1,1)] empty? False POP(UX[(1,1)])->a A=UP s = (1,1) Return a S’=(1,1) AI 1 17 april 201717 april 2017

Online DF-search, example GOAL-TEST((2,1))? S not = G thus false (2,1) a new state? True ACTION((2,1)) -> UX[(2,1)] {DOWN} s is null? false (s=(1,1)) result[UP,(1,1)] <- (2,1) UB[(2,1)]={(1,1)} UX[(2,1)] empty? False A=DOWN, s=(2,1) return A S’=(2,1) S AI 1 17 april 201717 april 2017

Online DF-search, example GOAL-TEST((1,1))? S not = G thus false (1,1) a new state? false s is null? false (s=(2,1)) result[DOWN,(2,1)] <- (1,1) UB[(1,1)]={(2,1)} UX[(1,1)] empty? False A=RIGHT, s=(1,1) return A S’=(1,1) S AI 1 17 april 201717 april 2017

Online DF-search, example GOAL-TEST((1,2))? S not = G thus false (1,2) a new state? True, UX[(1,2)]={RIGHT,UP,LEFT} s is null? false (s=(1,1)) result[RIGHT,(1,1)] <- (1,2) UB[(1,2)]={(1,1)} UX[(1,2)] empty? False A=LEFT, s=(1,2) return A S’=(1,2) S AI 1 17 april 201717 april 2017

Online DF-search, example GOAL-TEST((1,1))? S not = G thus false (1,1) a new state? false s is null? false (s=(1,2)) result[LEFT,(1,2)] <- (1,1) UB[(1,1)]={(1,2),(2,1)} UX[(1,1)] empty? True UB[(1,1)] empty? False A= b for b in result[b,(1,1)]=(1,2) B=RIGHT A=RIGHT, s=(1,1) … S’=(1,1) S AI 1 17 april 201717 april 2017

Online DF-search Worst case each node is visited twice. An agent can go on a long walk even when it is close to the solution. An online iterative deepening approach solves this problem. Online DF-search works only when actions are reversible. AI 1 17 april 201717 april 2017

Online local search Hill-climbing is already online One state is stored. Bad performance due to local maxima Random restarts impossible. Solution: Random walk introduces exploration (can produce exponentially many steps) AI 1 17 april 201717 april 2017

Online local search Solution 2: Add memory to hill climber Store current best estimate H(s) of cost to reach goal H(s) is initially the heuristic estimate h(s) Afterward updated with experience (see below) Learning real-time A* (LRTA*) AI 1 17 april 201717 april 2017