CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2018
“Artificial Intelligence: A Modern Approach”, 3rd Edition, Chapter 4 Some slides have been adopted from Klein and Abdeel, CS188, UC Berkeley.
Local Search & Optimization CE417: Introduction to Artificial - - PowerPoint PPT Presentation
Local Search & Optimization CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2018 Soleymani Artificial Intelligence: A Modern Approach , 3 rd Edition, Chapter 4 Some slides have been adopted from
“Artificial Intelligence: A Modern Approach”, 3rd Edition, Chapter 4 Some slides have been adopted from Klein and Abdeel, CS188, UC Berkeley.
2
3
Simple, general idea:
Start wherever Repeat: move to the best neighboring state If no neighbors better than current, quit
What’s bad about this approach?
Complete? Optimal?
What’s good about it?
6
Starting from X, where do you end up ? Starting from Y, where do you end up ? Starting from Z, where do you end up ?
8
States: 4 queens in 4 columns (44 = 256 states) Operators: move queen in column Goal test: no attacks Evaluation: h(n) = number of attacks
States: 8 queens on the board, one per column (88 ≈ 17 𝑛𝑗𝑚𝑚𝑗𝑝𝑜) Successors(s): all states resulted from 𝑡 by moving a single queen to
Cost function ℎ(s): number of queen pairs that are attacking each
Global minimum: ℎ 𝑡 = 0
successors objective values Red: best successors
11
Current node is replaced by the best successor (if it is better than current node)
12
Rapid progress toward a solution
Usually quite easy to improve a bad solution
13
14
on average, 4 steps for succeeding and 3 steps for getting stuck ℎ(𝑡) = 17 Five steps ℎ(𝑡) = 1
15
16
Variants of this approach get within 1% of optimal very quickly
Sideways moves Stochastic hill climbing
First-choice hill climbing
Random-restart hill climbing
17
Problem: infinite loop where flat local max
Solution: upper bound on the number of consecutive sideways moves
Limit = 100 for consecutive sideways moves
94% success instead of 14% success
on average, 21 steps when succeeding and 64 steps when failing
18
𝑄(𝑇’) is an increasing function of ℎ(𝑡’) − ℎ(𝑡)
Good when number of successors is high
19
Getting stuck on local max
Expected no of restarts = 1/𝑞
20
Few local max and platea: random-restart is quick Real problems land-scape is usually unknown a priori NP-Hard problems typically have an exponential number of
Reasonable solution can be obtained after a small no of restarts
21
More exploration at start and gradually hill-climbing become
22
23
24
Pick a random successor of
the current state
If
it is better than the current state go to it
Otherwise,
accept the transition with a probability
Badness of movement: worse movements get less probability Temperature
High temperature at start: higher probability for bad random moves Gradually reducing temperature: random bad movements become more
25
26
27
Like greedy hillclimbing search, but keep K states at all times: Variables: beam size, encourage diversity? The best choice in MANY practical settings
29
Passing information among parallel search threads
Solution: Stochastic beam search
Choose k successors at random with probability that is an increasing
30
Successors can be generated by combining two parent states
32
33
A state (solution) is represented as a string over a finite alphabet
Like a chromosome containing genes
Start with k randomly generated states (population) Evaluation function to evaluate states (fitness function)
Higher values for better states
Combining two parent states and getting offsprings (cross-over)
Cross-over point can be selected randomly
Reproduced states can be slightly modified (mutation) The next generation of states is produced by selection (based on fitness
34
35
2 4 7 4 8 5 5 2
24 for above figure
36
6 7 2 4 7 5 8 8 7 5 2 5 1 4 4 7 6 7 2 5 1 4 4 7
37
6 7 2 4 7 5 8 8 7 5 2 5 1 4 4 7 6 7 2 5 1 4 4 7
38
6 7 2 5 1 4 4 7 6 7 2 5 1 3 4 7
39
6 7 2 5 1 4 4 7 6 7 2 5 1 3 4 7
40
41
Stop Criteria? Solution Yes
6 7 2 4 7 5 8 8 3 1 2 8 2 5 6 6 8 1 4 2 5 3 7 1
min = 0, max = 8 × 7/2 = 28 Reproduction rate(i) = 𝑔𝑗𝑢𝑜𝑓𝑡𝑡(𝑗)/ 𝑙=1
𝑜
e.g., 24/(24+23+20+11) = 31% 42
min = 0, max = 8 × 7/2 = 28 Reproduction rate(i) = 𝑔𝑗𝑢𝑜𝑓𝑡𝑡(𝑗)/ 𝑙=1
𝑜
e.g., 24/(24+23+20+11) = 31% 43
Genetic algorithms use a natural selection metaphor
Keep best N hypotheses at each step (selection) based on a fitness function
Also have pairwise crossover operators, with optional mutation to give variety
Possibly the most misunderstood, misapplied (and even maligned) technique around
46
Initially, population individuals are diverse
Cross-over operation on different parent states can produce a state
More similar individuals gradually appear in the population
Ability to combine large blocks of genes evolved independently
Representation has an important role in benefit of incorporating
E.g., select locations for 3 airports such that sum of squared distances from
(𝑦1, 𝑧1) , (𝑦2, 𝑧2) , (𝑦3, 𝑧3) 𝐺(𝑦1, 𝑧1, 𝑦2, 𝑧2, 𝑦3, 𝑧3) = 𝑗=1
3
Just change variable by ±
E.g., 6×2 actions for airport example
𝛼𝑔 = 0 (only for simple cases) Gradient ascent
1
( )
t t t
f
x x x
1 2
, ,...,
d
f f f f x x x
48
1
t t t
Random restarts and simulated annealing can be useful Higher dimensions raises the rate of getting lost
49
Line search Newton-Raphson
1 1(
t t t t f
2 ij i j
50