When A* fails – Hill climbing, simulated annealing Genetic algorithms

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
Optimization via Search CPSC 315 – Programming Studio Spring 2009 Project 2, Lecture 4 Adapted from slides of Yoonsuck Choe.
Trading optimality for speed…
Imagine that I am in a good mood Imagine that I am going to give you some money ! In particular I am going to give you z dollars, after you tell me the.
Adapted by Doug Downey from Bryan Pardo Fall 2007 Machine Learning EECS 349 Machine Learning Lecture 4: Greedy Local Search (Hill Climbing)
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
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.
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
Chapter 4.1 Beyond “Classic” Search. What were the pieces necessary for “classic” search.
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.
Local Search Algorithms
Local Search Pat Riddle 2012 Semester 2 Patricia J Riddle Adapted from slides by Stuart Russell,
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.
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.
Informed search algorithms Chapter 4 Slides derived in part from converted to powerpoint by Min-Yen.
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.
Chapter 5. Advanced Search Fall 2011 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
Lecture 6 – Local Search Dr. Muhammad Adnan Hashmi 1 24 February 2016.
Local Search Algorithms and Optimization Problems
CPSC 322, Lecture 16Slide 1 Stochastic Local Search Variants Computer Science cpsc322, Lecture 16 (Textbook Chpt 4.8) Oct, 11, 2013.
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 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"
1 Intro to AI Local Search. 2 Intro to AI Local search and optimization Local search: –use single current state & move to neighboring states Idea: –start.
Informed Search Chapter 4 (b)
Informed Search Chapter 4 (b)
CSCI 4310 Lecture 10: Local Search Algorithms
Department of Computer Science
Informed Search Chapter 4 (b)
Local Search Algorithms
Artificial Intelligence (CS 370D)
Informed Search II.
Local Search and Optimization
CSE 4705 Artificial Intelligence
Heuristics Local Search
Informed Search Chapter 4 (b)
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
Beyond Classical Search
Local Search Algorithms
Presentation transcript:

When A* fails – Hill climbing, simulated annealing Genetic algorithms Informed Search II When A* fails – Hill climbing, simulated annealing Genetic algorithms

When A* doesn’t work AIMA 4.1 A few slides adapted from CS 471, UBMC and Eric Eaton (in turn, adapted from slides by Charles R. Dyer, University of Wisconsin-Madison)......

Outline Local Search: Hill Climbing Escaping Local Maxima: Simulated Annealing Genetic Algorithms CIS 391 - Intro to AI

Local search and optimization Use single current state and move to neighboring states. Idea: start with an initial guess at a solution and incrementally improve it until it is one Advantages: Use very little memory Find often reasonable solutions in large or infinite state spaces. Useful for pure optimization problems. Find or approximate best state according to some objective function Optimal if the space to be searched is convex CIS 391 - Intro to AI

Hill Climbing

Hill climbing on a surface of states h(s): Estimate of distance from a peak (smaller is better) OR: Height Defined by Evaluation Function (greater is better) CIS 391 - Intro to AI

"Like climbing Everest in thick fog with amnesia" Hill-climbing search While ( uphill points): Move in the direction of increasing evaluation function f Let snext = , s a successor state to the current state n If f(n) < f(s) then move to s Otherwise halt at n Properties: Terminates when a peak is reached. Does not look ahead of the immediate neighbors of the current state. Chooses randomly among the set of best successors, if there is more than one. Doesn’t backtrack, since it doesn’t remember where it’s been a.k.a. greedy local search "Like climbing Everest in thick fog with amnesia" CIS 391 - Intro to AI

Hill climbing example I (minimizing h) 3 2 4 5 8 6 7 1 2 3 4 5 6 7 8 1 start hoop = 5 goal hoop = 4 hoop = 0 6 5 3 2 4 5 8 6 7 1 2 4 5 6 7 8 1 3 hoop = 1 hoop = 3 5 4 3 2 4 5 6 7 8 1 3 2 4 5 6 7 8 1 hoop = 2 4 CIS 391 - Intro to AI

Hill-climbing Example: n-queens n-queens problem: Put n queens on an n × n board with no two queens on the same row, column, or diagonal Good heuristic: h = number of pairs of queens that are attacking each other h=5 h=3 h=1 (for illustration) CIS 391 - Intro to AI

Hill-climbing example: 8-queens A state with h=17 and the h-value for each possible successor A local minimum of h in the 8-queens state space (h=1). h = number of pairs of queens that are attacking each other CIS 391 - Intro to AI

Search Space features CIS 391 - Intro to AI

Drawbacks of hill climbing Local Maxima: peaks that aren’t the highest point in the space Plateaus: the space has a broad flat region that gives the search algorithm no direction (random walk) Ridges: dropoffs to the sides; steps to the North, East, South and West may go down, but a step to the NW may go up. CIS 391 - Intro to AI

Toy Example of a local "maximum" 4 2 3 1 5 6 7 8 2 start goal 4 1 2 3 5 6 7 8 4 1 2 3 7 5 6 8 1 2 3 4 5 6 7 8 2 1 4 1 2 3 5 6 7 8 2 CIS 391 - Intro to AI

The Shape of an Easy Problem (Convex) CIS 391 - Intro to AI

Gradient ascent/descent Images from http://en.wikipedia.org/wiki/Gradient_descent •  Gradient descent procedure for finding the argx min f(x) –  choose initial x0 randomly repeat •  xi+1 ← xi – η f '(xi) –  until the sequence x0, x1, …, xi, xi+1 converges •  Step size η (eta) is small (perhaps 0.1 or 0.05) CIS 391 - Intro to AI

Gradient methods vs. Newton’s method •  A reminder of Newton's method from Calculus: xi+1 ← xi – η f '(xi) / f ''(xi) •  Newton,s method uses information (the second derivative, or, curvature) to take a more direct route to the minimum. 2nd order Contour lines of a function Gradient descent (green) Newton,s method (red) Image from http://en.wikipedia.org/wiki/Newton's_method_in_optimization •  The second-order information is more expensive to compute, but converges quicker. (this and previous slide from Eric Eaton) CIS 391 - Intro to AI

The Shape of a Harder Problem CIS 391 - Intro to AI

The Shape of a Yet Harder Problem CIS 391 - Intro to AI

One Remedy to Drawbacks of Hill Climbing: Random Restart In the end: Some problem spaces are great for hill climbing and others are terrible. CIS 391 - Intro to AI

Simulated Annealing

Simulated annealing (SA) Annealing: the process by which a metal cools and freezes into a minimum-energy crystalline structure (the annealing process) Conceptually SA exploits an analogy between annealing and the search for a minimum in a more general system. AIMA: Switch viewpoint from hill-climbing to gradient descent (But: AIMA algorithm hill-climbs & larger E is good…) SA hill-climbing can avoid becoming trapped at local maxima. SA uses a random search that occasionally accepts changes that decrease objective function f. SA uses a control parameter T, which by analogy with the original application is known as the system "temperature." T starts out high and gradually decreases toward 0. CIS 391 - Intro to AI

Simulated annealing (cont.) A "bad" move from A to B (f(B)<f(A)) is accepted with the probability P(moveA→B) = e The higher T, the more likely a bad move will be made. As T tends to zero, this probability tends to zero, and SA becomes more like hill climbing If T is lowered slowly enough, SA is complete and admissible. ( f (B) – f (A)) / T CIS 391 - Intro to AI

Applicability Discrete Problems where state changes are transforms of local parts of the configuration E.G. Travelling Salesman problem, where moves are swaps of the order of two cities visited: Pick an initial tour randomly Successors are all neighboring tours, reached by swapping adjacent cities in the original tour Search using simulated annealing.. CIS 391 - Intro to AI

AIMA Simulated Annealing Algorithm function SIMULATED-ANNEALING( problem, schedule) returns a solution state input: problem, a problem schedule, a mapping from time to “temperature” current  MAKE-NODE(problem.INITIAL-STATE) for t  1 to ∞ do T  schedule(t) if T = 0 then return current next  a randomly selected successor of current ∆E  next.VALUE – current.VALUE if ∆E > 0 then current  next else current  next only with probability e∆E /T Nice simulation on web page of travelling salesman approximations via simulated annealing: http://toddwschneider.com/posts/traveling-salesman-with-simulated-annealing-r-and-shiny/ CIS 391 - Intro to AI

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 proportionally to state success. CIS 391 - Intro to AI

Genetic Algorithms

Genetic algorithms Start with k random states (the initial population) New states are generated by either “Mutation” of a single state or “Sexual Reproduction”: (combining) two parent states (selected proportionally to their fitness) Encoding used for the “genome” of an individual strongly affects the behavior of the search Similar (in some ways) to stochastic beam search CIS 391 - Intro to AI

Representation: Strings of genes Each chromosome represents a possible solution made up of a string of genes Each gene encodes some property of the solution There is a fitness metric on phenotypes of chromosomes Evaluation of how well a solution with that set of properties solves the problem. New generations are formed by Crossover: sexual reproduction Mutation: asexual reproduction CIS 391 - Intro to AI

Encoding of a Chromosome The chromosome encodes characteristics of the solution which it represents, often as a string of binary digits. Chromosome 1 1101100100110110 Chromosome 2 1101111000011110 Each set of bits represents some dimension of the solution. CIS 391 - Intro to AI

Example: Genetic Algorithm for Drive Train Genes for: Number of Cylinders RPM: 1st -> 2nd RPM 2nd -> 3rd RPM 3rd -> Drive Rear end gear ratio Size of wheels A chromosome specifies a full drive train design CIS 391 - Intro to AI

Reproduction Reproduction by crossover selects genes from two parent chromosomes and creates two new offspring. To do this, randomly choose a crossover point (perhaps none). For child 1, everything before this point comes from the first parent and everything after from the second parent. Crossover looks like this ( | is the crossover point): Chromosome 1 11001 | 00100110110 Chromosome 2 10011 | 11000011110 Offspring 1 11001 | 11000011110 Offspring 2 10011 | 00100110110 CIS 391 - Intro to AI

Mutation Mutation randomly changes genes in the new offspring. For binary encoding we can switch randomly chosen bits from 1 to 0 or from 0 to 1. Original offspring 1101111000011110 Mutated offspring 1100111000001110 CIS 391 - Intro to AI

The Basic Genetic Algorithm Generate random population of chromosomes Until the end condition is met, create a new population by repeating following steps Evaluate the fitness of each chromosome Select two parent chromosomes from a population, weighed by their fitness With probability pc cross over the parents to form a new offspring. With probability pm mutate new offspring at each position on the chromosome. Place new offspring in the new population Return the best solution in current population CIS 391 - Intro to AI

Genetic algorithms:8-queens CIS 391 - Intro to AI

A Genetic Algorithm Simulation www.boxcar2d.com CIS 391 - Intro to AI

The Chromosome Layout Strengths: Weakness: Vector Angles and Magnitudes adjacent Adjacent vectors are adjacent Weakness: Wheel info (vertex, axle angles & wheel radiuses not linked to vector the wheel is associated with. CIS 391 - Intro to AI

Car from Gen 4: Score: 160 (max) CIS 391 - Intro to AI

Best from Generations 20-46: 594.7 CIS 391 - Intro to AI

The best (gen 26-37) of another series CIS 391 - Intro to AI

A variant finishes the course.... CIS 391 - Intro to AI