Artificial Intelligence
Radu Răzvan Slăvescu
Technical University of Cluj-Napoca
Department of Computer Science
(some slides adapted from A. Dragan, N. Kitaev, N. Lambert, S. Levine, S. Rao, S. Russell)
Outline
Local Search and Optimization Problems
Local Search
Goal
All I need is the final state; the path to get there is irrelevant
E.g.: 8-queens problem; generating a schedule
Local Search Algorithms
Start state ⇒ neighboring states. No track of the path kept.
Con: not systematic
Pros:
I little memory used
I can often find reasonable solutions
I can solve optimization problems: find the best state
according to an objective function
Local Search
Local Search Algorithms
I find a global maximum (=highest peak): hill climbing
I find a global minimum (=lowest valley): gradient descent
Local Search
State-space landscape
Hill climbing
Description
Keep one current state.
At each step, follow the steepest ascent
Terminates when it reaches a ”peak”
Hill climbing
Example: 8-queens problem
I work with complete state formulation : every state has all
components of a solution, some of which may be
misplaced (8 queens on the board, one per column)
I initial state chosen at random
I successors of a state: by moving one queen to another
square in the same column (→ 8 × 7)
I heuristic h: number of pairs of queens on the same row or
diagonal (=0 iff solution)
Hill climbing
Description
For the state to the right h =? successor = ?
Hill climbing
Description
I LOCAL MAXIMA: a pick higher than any neighbor, but
lower than the global maximum
I PLATEAU: flat area in the state-space landscape. Either flat
local maximum or shoulder (going up impossible / possible)
I RIDGE: sequence of local maxima; difficult for hill climbing
Hill climbing
Description
Ridge rises from left to right. For each local maximum, all
actions point downhill
Hill climbing
Example: 8-queens
Steepest-ascent hill climbing: successful on 14% of instances.
On average, 4 steps if success, 3 steps if failure
To improve: go on when on plateau (allow sideway moves, but
limit the number of consecutive sideway moves to, say, 100)
Successful on 94% of instances. On average, 21 steps if
success, 64 steps if failure
Hill climbing
Improvements for Hill Climbing HC
I Stochastic HC: choose at random from uphill moves,
probability of selection can vary with the steepness of the
uphill move
I First choice HC: generate successors at random, untill one
which is better than the current state is generated
I Random restart HC: does a series of HC searches from
randomly-generated initial states, until a goal is found.
Good if there are few local maxima and plateaus
Simulated annealing
Hill Climbing v. Random Walk
HC: no downhill moves → can get stuck in a local maximum
RW: move to a random successor state, with no focus on its
value → inefficient
Simulated annealing (for gradient descent): to get a ball in the
deepest crevice in a very bumpy surface, roll it till gets to a local
minimum, then shake the surface hard enough for the ball to
jump out of a local minimum, but not from a global one
Simulated Annealing
Description
Accepting a move with a probability: p = 1 if the situation
improves; otherwise p < 1 and decreased exponentially with
∆E (the amount by which the evaluation is worsened)
Beam Search
Beam Search: keep k states in memory
Start with k random states, generate their successors and keep
the top k succesors ofthe whole list, till the goal is reached
Stochastic Beam Search
Keep k states in memory, chosen with probability proportional
to the successor’s value (→ better diversity)
Evolutionary algorithms
EA types
EA = sort of stochastic beam search: a population of individual
(states), where the fittest individual produce offspring
Types: Genetic algorithms: individual = string of symbols (e.g.,
bits); Genetic programming: individual = computer program in
form of a tree
Evolutionary algorithms
Operations
I each individual actually represents a solution
I s/he is assessed by the fitness function, which evaluaes
the solution quality
I Selection: select individuals which will become parents,
e.g., proportional with their fitness score
I Recombination: randomly select a crossover point, split
the parent strings and recombine them to get the offspring
(first part from the first parent, second from the second
parent and vice versa)
I mutation: randomly flip a bit in the string
Genetic Algorithm
8-queens problem, 4 individuals
Individual: digit c=row number for queen in column c
Fitness: number of non-attacking pairs of queens, normalized
Genetic Algorithm
8-queens problem, 4 individuals
Solutions corresponding to the first 2 individuals
That’s all, folks!
Thanks for your attention...Questions?