SlideShare a Scribd company logo
1 of 39
Download to read offline
CSE 473: Artificial Intelligence
Autumn 2016
Local Search
With slides from
Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer
Dan Weld
Previous Search Methods
• Blind Search
• Depth first search
• Breadth first search
• Iterative deepening search
• Uniform cost search
• Informed Search
• Best First
• A*
• Beam Search
• Hill Climbing
Systematic
Local (Randomized)
Constraint Satisfaction (Factored)
© Daniel S. Weld
4
No
O(b^d)
O(b + N)
Beam Search
§ Idea
§ Best first but only keep N best items on
priority queue
§ Evaluation
§ Complete?
§ Time Complexity?
§ Space Complexity?
© Daniel S. Weld
5
Hill Climbing
§Idea
§ Always choose best child; no
backtracking
§ Beam search with |queue| = 1
§Problems?
§Coming soon
“Gradient ascent”
Goal State vs. Path
• Previously: Search to find best path to goal
§ Systematic exploration of search space.
§ Today: a state is solution to problem
§ For some problems path is irrelevant.
§ E.g., 8-queens
§ Different algorithms can be used
§ Systematic Search
§ Local Search
§ Constraint Satisfaction 6
Local search algorithms
§ State space = set of "complete" configurations
§ Find configuration satisfying constraints,
§ e.g., all n-queens on board, no attacks
§ In such cases, we can use local search algorithms
§ Keep a single "current" state, try to improve it.
§ Very memory efficient
§ duh - only remember current state
Goal
Satisfaction
Optimization
Constraint satisfaction
reach the goal node
guided by heuristic fn
Constraint Optimization
optimize(objective fn)
You can go back and forth between the two problems
Typically in the same complexity class
© Mausam 8
Local Search and Optimization
§ Local search
§ Keep track of single current state
§ Move only to “neighboring” state
Defined by operators
§ Ignore previous states, path taken
§ 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. 9
Trivial Algorithms
§ Random Sampling
§ Generate a state randomly
§ Random Walk
§ Randomly pick a neighbor of the current state
§ Why even mention these?
§ Both algorithms asymptotically complete.
§ http://projecteuclid.org/download/pdf_1/euclid.aop/1176996718 for Random Walk
© Mausam
10
Hill-climbing search
§ “a loop that continuously moves towards 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
§ Can randomly choose among the set of best successors
§ if multiple have the best value
§ “climbing Mount Everest in a thick fog with amnesia”
12
Example: n-Queens
Objective: Put n queens on an n x n board with no
two queens on the same row, column, or diagonal
Is this a satisfaction problem or optimization?
15
Our n-Queens (Local) Search Space
§ State
§ All N queens on the board in some configuration
§ But each in a different column
§ Successor function
§ Move single queen to another square in same column.
16
Need Heuristic Function
Convert to Optimization Problem
§ h = number of pairs of queens attacking each other
§ h = 17 for the above state 17
Hill-climbing search: 8-queens
A local minimum with h = 1
Result of hill-climbing
in this case…
19
Hill Climbing Drawbacks
• Local maxima
• Plateaus
• Diagonal ridges
20
• Not Complete
• Worst Case Exponential Time
• Simple, O(1) Space & Often Very Fast!
Hill Climbing Properties
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 8^8 =~17 million states)
21
Escaping Shoulders: Sideways Move
§ If no downhill (uphill) moves, allow sideways moves
in hope that algorithm can escape
§ Must limit the number of possible sideways moves to avoid
infinite loops
§ For 8-queens
§ Allow sideways moves with limit of 100
§ Raises percentage of problems solved from 14 to 94%
§ However….
§ 21 steps for every successful solution
§ 64 for each failure
22
Tabu Search
§ Prevent returning quickly to the same state
§ Keep fixed length queue (“tabu list”)
§ Add most recent state to queue; drop oldest
§ Never move to a tabu state
§ Properties:
§ As the size of the tabu list grows, hill-climbing will
asymptotically become “non-redundant” (won’t look at the
same state twice)
§ In practice, a reasonable sized tabu list (say 100 or so)
improves the performance of hill climbing in many problems
23
Escaping Local Optima - Enforced Hill Climbing
§ Perform breadth first search from a local optima
§ to find the next state with better h function
§ Typically,
§ prolonged periods of exhaustive search
§ bridged by relatively quick periods of hill-climbing
§ Middle ground b/w local and systematic search
© Mausam 24
Hill Climbing: Stochastic Variations
àWhen the state-space landscape has local minima, any
search that moves only in the greedy direction cannot be
complete
àRandom walk, on the other hand, is
asymptotically complete
Idea: Combine random walk & greedy hill-climbing
25
At each step do one of the following:
§ Greedy: With prob p move to the neighbor with largest value
§ Random: With prob 1-p move to a random neighbor
Hill-climbing with random restarts
§ If at first you don’t succeed, try, try again!
§ Different variations
§ For each restart: run until termination vs. 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? 26
Restarts 0 2 4 8 16 32 64
Success? 14% 36% 53% 74% 92% 99% 99.994%
Hill-Climbing with Both
Random Walk & Random Sampling
At each step do one of the three
– Greedy: move to the neighbor with largest value
– Random Walk: move to a random neighbor
– Random Restart: Start over from a new, random state
© Mausam 27
Simulated Annealing
written to find minimum value solutions
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 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 29
if ΔE<0 then current ß next
else current ß next only with probability e-ΔE/T
Physical Interpretation of Simulated Annealing
§ A Physical Analogy:
§ Imagine letting a ball roll downhill on the function surface
§ Now shake the surface, while the ball rolls,
§ Gradually reducing the amount of shaking
30
Physical Interpretation of Simulated Annealing
§ A Physical Analogy:
§ Imagine letting a ball roll downhill on the function surface
§ Now shake the surface, while the ball rolls,
§ Gradually reducing the amount of shaking
31
Physical Interpretation of Simulated Annealing
§ A Physical Analogy:
§ Imagine letting a ball roll downhill on the function surface
§ Now shake the surface, while the ball rolls,
§ Gradually reducing the amount of shaking
32
Physical Interpretation of Simulated Annealing
§ A Physical Analogy:
§ Imagine letting a ball roll downhill on the function surface
§ Now shake the surface, while the ball rolls,
§ Gradually reducing the amount of shaking
33
Physical Interpretation of Simulated Annealing
§ A Physical Analogy:
§ Imagine letting a ball roll downhill on the function surface
§ Now shake the surface, while the ball rolls,
§ Gradually reducing the amount of shaking
§ Annealing = physical process of cooling a liquid à frozen
§ simulated annealing:
§ free variables are like particles
§ seek “low energy” (high quality) configuration
§ slowly reducing temp. T with particles moving around randomly
34
Temperature T
§ 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”
35
Simulated Annealing in Practice
§ method proposed in 1983 by IBM researchers for
solving VLSI layout problems (Kirkpatrick et al,
Science, 220:671-680, 1983).
§ theoretically will always find the global optimum
§ Other applications: Traveling salesman, Graph
partitioning, Graph coloring, Scheduling, Facility
Layout, Image Processing, …
§ useful for some problems, but can be very slow
§ slowness comes about because T must be decreased
very gradually to retain optimality
36
Local beam search
§ Idea: Keeping only one node in memory is an
extreme reaction to memory problems.
§ 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
37
Local Beam Search (contd)
§ Not the same as k random-start 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: Stochastic beam search
§ Choose k successors randomly, biased towards good ones
§ Observe the close analogy to natural selection!
38
How to Make Search More … Exciting?
39
…And Be Scholarly!
40
Genetic algorithms
§ Local beam search, but…
§ A successor state is generated by combining two parent states
§ Start with k randomly generated states (population)
§ A state is represented as a string over a finite alphabet
(often a string of 0s and 1s)
§ Evaluation function (fitness function). Higher = better
§ Produce the next generation of states by selection,
crossover, and mutation
§ Fitness function: number of non-attacking pairs of
queens (min = 0, max = 8 7/2 = 28)
§ 24/(24+23+20+11) = 31%
§ 23/(24+23+20+11) = 29% etc
fitness:
#non-attacking queens
probability of being
regenerated
in next generation
Genetic algorithms
Has the effect of “jumping” to a completely different new
part of the search space (quite non-local)
43
Comments on Genetic Algorithms
§ Genetic algorithm is a variant of “stochastic beam search”
§ Positive points
§ Random exploration can find solutions that local search canʼt
§ (via crossover primarily)
§ Appealing connection to human evolution
§ “neural” networks, and “genetic” algorithms are metaphors!
§ 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
44

More Related Content

Similar to 04-local-search.pdf

UninformedSearch (2).pptx
UninformedSearch (2).pptxUninformedSearch (2).pptx
UninformedSearch (2).pptxSankarTerli
 
CS4700-LS_v6.pptx
CS4700-LS_v6.pptxCS4700-LS_v6.pptx
CS4700-LS_v6.pptxjpradha86
 
chapter 2 Problem Solving.pdf
chapter 2 Problem Solving.pdfchapter 2 Problem Solving.pdf
chapter 2 Problem Solving.pdfMeghaGupta952452
 
Search-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfSearch-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfMrRRThirrunavukkaras
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}FellowBuddy.com
 
Influence Landscapes - From Spatial to Conceptual Representations
Influence Landscapes - From Spatial to Conceptual RepresentationsInfluence Landscapes - From Spatial to Conceptual Representations
Influence Landscapes - From Spatial to Conceptual RepresentationsLuke Dicken
 
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekAIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekpavan402055
 
Artificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxArtificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxCCBProduction
 
1.1 1.4-introduction
1.1 1.4-introduction1.1 1.4-introduction
1.1 1.4-introductionatulg0213
 
Coordinate Descent method
Coordinate Descent methodCoordinate Descent method
Coordinate Descent methodSanghyuk Chun
 

Similar to 04-local-search.pdf (20)

UninformedSearch (2).pptx
UninformedSearch (2).pptxUninformedSearch (2).pptx
UninformedSearch (2).pptx
 
Hill climbing
Hill climbingHill climbing
Hill climbing
 
CS4700-LS_v6.pptx
CS4700-LS_v6.pptxCS4700-LS_v6.pptx
CS4700-LS_v6.pptx
 
l2.pptx
l2.pptxl2.pptx
l2.pptx
 
l2.pptx
l2.pptxl2.pptx
l2.pptx
 
chapter 2 Problem Solving.pdf
chapter 2 Problem Solving.pdfchapter 2 Problem Solving.pdf
chapter 2 Problem Solving.pdf
 
Search-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdfSearch-Beyond-Classical-no-exercise-answers.pdf
Search-Beyond-Classical-no-exercise-answers.pdf
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Influence Landscapes - From Spatial to Conceptual Representations
Influence Landscapes - From Spatial to Conceptual RepresentationsInfluence Landscapes - From Spatial to Conceptual Representations
Influence Landscapes - From Spatial to Conceptual Representations
 
M4 Heuristics
M4 HeuristicsM4 Heuristics
M4 Heuristics
 
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjekAIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
AIMA_ch3_L2-complement.ppt kjekfkjekjfkjefkjefkjek
 
Artificial Intelligence
Artificial IntelligenceArtificial Intelligence
Artificial Intelligence
 
Nature-inspired algorithms
Nature-inspired algorithmsNature-inspired algorithms
Nature-inspired algorithms
 
Sudoku
SudokuSudoku
Sudoku
 
Rai practical presentations.
Rai practical presentations.Rai practical presentations.
Rai practical presentations.
 
AI_HILL_CLIMBING.ppt
AI_HILL_CLIMBING.pptAI_HILL_CLIMBING.ppt
AI_HILL_CLIMBING.ppt
 
Artificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptxArtificial Intelligence_Anjali_Kumari_26900122059.pptx
Artificial Intelligence_Anjali_Kumari_26900122059.pptx
 
1.1 1.4-introduction
1.1 1.4-introduction1.1 1.4-introduction
1.1 1.4-introduction
 
Lecture 3 problem solving
Lecture 3   problem solvingLecture 3   problem solving
Lecture 3 problem solving
 
Coordinate Descent method
Coordinate Descent methodCoordinate Descent method
Coordinate Descent method
 

Recently uploaded

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

04-local-search.pdf

  • 1. CSE 473: Artificial Intelligence Autumn 2016 Local Search With slides from Dan Klein, Stuart Russell, Andrew Moore, Luke Zettlemoyer Dan Weld
  • 2. Previous Search Methods • Blind Search • Depth first search • Breadth first search • Iterative deepening search • Uniform cost search • Informed Search • Best First • A* • Beam Search • Hill Climbing Systematic Local (Randomized) Constraint Satisfaction (Factored)
  • 3. © Daniel S. Weld 4 No O(b^d) O(b + N) Beam Search § Idea § Best first but only keep N best items on priority queue § Evaluation § Complete? § Time Complexity? § Space Complexity?
  • 4. © Daniel S. Weld 5 Hill Climbing §Idea § Always choose best child; no backtracking § Beam search with |queue| = 1 §Problems? §Coming soon “Gradient ascent”
  • 5. Goal State vs. Path • Previously: Search to find best path to goal § Systematic exploration of search space. § Today: a state is solution to problem § For some problems path is irrelevant. § E.g., 8-queens § Different algorithms can be used § Systematic Search § Local Search § Constraint Satisfaction 6
  • 6. Local search algorithms § State space = set of "complete" configurations § Find configuration satisfying constraints, § e.g., all n-queens on board, no attacks § In such cases, we can use local search algorithms § Keep a single "current" state, try to improve it. § Very memory efficient § duh - only remember current state
  • 7. Goal Satisfaction Optimization Constraint satisfaction reach the goal node guided by heuristic fn Constraint Optimization optimize(objective fn) You can go back and forth between the two problems Typically in the same complexity class © Mausam 8
  • 8. Local Search and Optimization § Local search § Keep track of single current state § Move only to “neighboring” state Defined by operators § Ignore previous states, path taken § 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. 9
  • 9. Trivial Algorithms § Random Sampling § Generate a state randomly § Random Walk § Randomly pick a neighbor of the current state § Why even mention these? § Both algorithms asymptotically complete. § http://projecteuclid.org/download/pdf_1/euclid.aop/1176996718 for Random Walk © Mausam 10
  • 10. Hill-climbing search § “a loop that continuously moves towards 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 § Can randomly choose among the set of best successors § if multiple have the best value § “climbing Mount Everest in a thick fog with amnesia” 12
  • 11. Example: n-Queens Objective: Put n queens on an n x n board with no two queens on the same row, column, or diagonal Is this a satisfaction problem or optimization? 15
  • 12. Our n-Queens (Local) Search Space § State § All N queens on the board in some configuration § But each in a different column § Successor function § Move single queen to another square in same column. 16
  • 13. Need Heuristic Function Convert to Optimization Problem § h = number of pairs of queens attacking each other § h = 17 for the above state 17
  • 14. Hill-climbing search: 8-queens A local minimum with h = 1 Result of hill-climbing in this case…
  • 15. 19 Hill Climbing Drawbacks • Local maxima • Plateaus • Diagonal ridges
  • 16. 20 • Not Complete • Worst Case Exponential Time • Simple, O(1) Space & Often Very Fast! Hill Climbing Properties
  • 17. 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 8^8 =~17 million states) 21
  • 18. Escaping Shoulders: Sideways Move § If no downhill (uphill) moves, allow sideways moves in hope that algorithm can escape § Must limit the number of possible sideways moves to avoid infinite loops § For 8-queens § Allow sideways moves with limit of 100 § Raises percentage of problems solved from 14 to 94% § However…. § 21 steps for every successful solution § 64 for each failure 22
  • 19. Tabu Search § Prevent returning quickly to the same state § Keep fixed length queue (“tabu list”) § Add most recent state to queue; drop oldest § Never move to a tabu state § Properties: § As the size of the tabu list grows, hill-climbing will asymptotically become “non-redundant” (won’t look at the same state twice) § In practice, a reasonable sized tabu list (say 100 or so) improves the performance of hill climbing in many problems 23
  • 20. Escaping Local Optima - Enforced Hill Climbing § Perform breadth first search from a local optima § to find the next state with better h function § Typically, § prolonged periods of exhaustive search § bridged by relatively quick periods of hill-climbing § Middle ground b/w local and systematic search © Mausam 24
  • 21. Hill Climbing: Stochastic Variations àWhen the state-space landscape has local minima, any search that moves only in the greedy direction cannot be complete àRandom walk, on the other hand, is asymptotically complete Idea: Combine random walk & greedy hill-climbing 25 At each step do one of the following: § Greedy: With prob p move to the neighbor with largest value § Random: With prob 1-p move to a random neighbor
  • 22. Hill-climbing with random restarts § If at first you don’t succeed, try, try again! § Different variations § For each restart: run until termination vs. 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? 26 Restarts 0 2 4 8 16 32 64 Success? 14% 36% 53% 74% 92% 99% 99.994%
  • 23. Hill-Climbing with Both Random Walk & Random Sampling At each step do one of the three – Greedy: move to the neighbor with largest value – Random Walk: move to a random neighbor – Random Restart: Start over from a new, random state © Mausam 27
  • 24. Simulated Annealing written to find minimum value solutions 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 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 29 if ΔE<0 then current ß next else current ß next only with probability e-ΔE/T
  • 25. Physical Interpretation of Simulated Annealing § A Physical Analogy: § Imagine letting a ball roll downhill on the function surface § Now shake the surface, while the ball rolls, § Gradually reducing the amount of shaking 30
  • 26. Physical Interpretation of Simulated Annealing § A Physical Analogy: § Imagine letting a ball roll downhill on the function surface § Now shake the surface, while the ball rolls, § Gradually reducing the amount of shaking 31
  • 27. Physical Interpretation of Simulated Annealing § A Physical Analogy: § Imagine letting a ball roll downhill on the function surface § Now shake the surface, while the ball rolls, § Gradually reducing the amount of shaking 32
  • 28. Physical Interpretation of Simulated Annealing § A Physical Analogy: § Imagine letting a ball roll downhill on the function surface § Now shake the surface, while the ball rolls, § Gradually reducing the amount of shaking 33
  • 29. Physical Interpretation of Simulated Annealing § A Physical Analogy: § Imagine letting a ball roll downhill on the function surface § Now shake the surface, while the ball rolls, § Gradually reducing the amount of shaking § Annealing = physical process of cooling a liquid à frozen § simulated annealing: § free variables are like particles § seek “low energy” (high quality) configuration § slowly reducing temp. T with particles moving around randomly 34
  • 30. Temperature T § 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” 35
  • 31. Simulated Annealing in Practice § method proposed in 1983 by IBM researchers for solving VLSI layout problems (Kirkpatrick et al, Science, 220:671-680, 1983). § theoretically will always find the global optimum § Other applications: Traveling salesman, Graph partitioning, Graph coloring, Scheduling, Facility Layout, Image Processing, … § useful for some problems, but can be very slow § slowness comes about because T must be decreased very gradually to retain optimality 36
  • 32. Local beam search § Idea: Keeping only one node in memory is an extreme reaction to memory problems. § 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 37
  • 33. Local Beam Search (contd) § Not the same as k random-start 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: Stochastic beam search § Choose k successors randomly, biased towards good ones § Observe the close analogy to natural selection! 38
  • 34. How to Make Search More … Exciting? 39
  • 36. Genetic algorithms § Local beam search, but… § A successor state is generated by combining two parent states § Start with k randomly generated states (population) § A state is represented as a string over a finite alphabet (often a string of 0s and 1s) § Evaluation function (fitness function). Higher = better § Produce the next generation of states by selection, crossover, and mutation
  • 37. § Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 7/2 = 28) § 24/(24+23+20+11) = 31% § 23/(24+23+20+11) = 29% etc fitness: #non-attacking queens probability of being regenerated in next generation
  • 38. Genetic algorithms Has the effect of “jumping” to a completely different new part of the search space (quite non-local) 43
  • 39. Comments on Genetic Algorithms § Genetic algorithm is a variant of “stochastic beam search” § Positive points § Random exploration can find solutions that local search canʼt § (via crossover primarily) § Appealing connection to human evolution § “neural” networks, and “genetic” algorithms are metaphors! § 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 44