Lecture 5 - Local Search GRASP
Lecture 5 - Local Search GRASP
Lecture 5
Heuristic Optimization Methods:
Local Search, GRASP
Slides prepared by Nina Skorin-Kapov
GRASP
Zavod za telekomunikacije 2
Optimization methods
University of Zagreb, Croatia
Exact Approximate
A*
methods methods
Simplex- Constraint
based for LP programming Approximation
algorithms
Heuristic
Branch and Bound, Dynamic
Cut , Price (B&B, programming algorithms
B&C, B&P)
Improvement (meta)heuristics
Constructive heuristics
• Local search
• Greedy algorithms
•Nature inspired
• Tabu search, Genetic
Hybrid methods
algorithms, Simmulated
• GRASP Annealing, Ant colony
•Problem specific
heuristics
Zavod za telekomunikacije 3
Basic Local Search elements
University of Zagreb, Croatia
Zavod za telekomunikacije 4
General Local search procedure
University of Zagreb, Croatia
Zavod za telekomunikacije 5
Neighborhood
University of Zagreb, Croatia
N(s)
s
S
Zavod za telekomunikacije 6
Continuous neighborhood
University of Zagreb, Croatia
The neighborhood
of a continuous
N(s) problem in 2
s
dimensions
Zavod za telekomunikacije 7
Discrete neighborhood
University of Zagreb, Croatia
101
111
3 binary variables
100
110
Neighbors are
adjacent nodes in
the hypercube
001 011 representing all
solutions
000 010
0 0 1 1 0
1 1 1 1 0 n neighbors
1 0 0 1 0
1 0 1 0 0
1 0 1 1 1
Zavod za telekomunikacije 9
Example: TSP
University of Zagreb, Croatia
1 2 4 Fitness:
Evaluation: 2
A B C D A F(s)=9
A 1 B
4 4 3 2
D C
2
Zavod za telekomunikacije 10
Example: TSP
University of Zagreb, Croatia
4 4 3 2
B→A→C→D
C→B→A→D D C
2
Neighborhood D→B→C→A n(n − 1)
N(s)
neighbors
A→C→B→D 2
n is the number of cities
A→D→C→B
4(4 − 1)
A→B→D→C = 6 neighbors
2
Zavod za telekomunikacije 11
TSP: Evaluation of neighborhood
University of Zagreb, Croatia
Current solution s:: Fitness:
1 2 2 4 F(s)=9
A B C D A
Neighborhood N(s):
1 3 2 4 F(s)=10
B A C D B
2 1 4 2 F(s)=9
C B A D C
4 2 3 4 F(s)=13
D B C A D
3 2 4 4 F(s)=13
A C B D A
4 2 2 1 F(s)=9
A D C B A
1 4 2 3 F(s)=10
A B D C A
Zavod za telekomunikacije 12
Neighborhood size
University of Zagreb, Croatia
2 main strategies:
Random – fast, but may take longer to
converge
Greedy – takes somewhat longer to
generate, but often leads to better quality
solutions (local optima)
Neighbor
selection
Neighborhood N(s) f(s)
Initial Best improving:
solution s f(s) 0 0 1 1 0 12 f(s’)=14
1 1 1 1 0 10 First
1 0 1 1 0 10 1 0 0 1 0 14 improving:
1 0 1 0 0 9 f(s’)=12
1 0 1 1 1 11
Random
Reduced improving:
neighborhood: Best: f(s’)=14 f(s’)=12, 14 or 11
or random: f(s’)=14 or 11
Zavod za telekomunikacije 16
Classical LS: steepest descent method
University of Zagreb, Croatia
Start LocalSearch
Generateinitialsolutions 0
s s0
do
GenerateN( s)
Find s ' N ( s ) where f ( s ' ) f ( s ' ' ) , s'' N (s)
If f ( s ' ) f ( s )
s s'
Else stop
while s was updated
return s
End
Zavod za telekomunikacije 17
Local optimum
University of Zagreb, Croatia
This is not
Obtained LS necessarily
solution: the first globally
local optimum optimal!
Zavod za telekomunikacije 18
Impact of size of neighborhood
University of Zagreb, Croatia
Initial solution
Small
Large neighborhood
neighborhood
Obtained local
Obtained local optimum with
optimum with larger small
neighborhood neighborhood
Zavod za telekomunikacije 19
Example
University of Zagreb, Croatia
1 0 0 1 1 f(s)=2349
Zavod za telekomunikacije 20
Example: neighborhood
University of Zagreb, Croatia
Current solution:
s 1 0 0 1 1 f(s)=2349
Neighborhood “1 flip”
ITERATION 1:
f(s)
0 0 0 1 1 2237 Best improving:
1 1 0 1 1 293 f(s’)=2923
N(s) New current
1 0 1 1 1 1177
1 0 0 0 1 2923 solution
1 0 0 1 0 2642
Zavod za telekomunikacije 21
Example: neighborhood
University of Zagreb, Croatia
Zavod za telekomunikacije 22
Example: neighborhood
University of Zagreb, Croatia
Already
found!
Still not
1st found local
2nd found local The best seen necessarily
solution is the optimum globally
optimum
final one optimal…
Zavod za telekomunikacije 25
Outline
University of Zagreb, Croatia
GRASP
Zavod za telekomunikacije 26
2
7
GRASP
University of Zagreb, Croatia
Zavod za telekomunikacije 27
2
8
GRASP Pseudo-code
University of Zagreb, Croatia
Start GRASP
Input : MaxIterations, seed
for k = 1,...MaxIterations
s Constructi on _ Phase ( seed )
s´ Local _ Search _ Phase ( s )
Update solution ( s best , s´);
end
return s best ;
End GRASP
Zavod za telekomunikacije 28
2
9
GRASP: Construction Phase
University of Zagreb, Croatia
Zavod za telekomunikacije 29
3
0
GRASP: Construction Phase
University of Zagreb, Croatia
Zavod za telekomunikacije 30
3
1
GRASP Construction Phase Pseudocode
University of Zagreb, Croatia
Zavod za telekomunikacije 31
3
2
Restricted Candidate List (RCL)
University of Zagreb, Croatia
The size of the RCL can be limited either by the number of elements
(cardinality-based) or by their quality with respect to the best candidate
element (value-based)
Cardinality-based criteria
The RCL is composed of the n best elements in terms of incremental cost
(i.e. the greedy evaluation function)
Value-based criteria (more commonly used)
All candidate elements (eϵC) whose incremental cost (c(e)) is better than a
threshold value enter the RCL
The threshold is calculated as (assuming a minimization problem and
greedy function)
c min + (c max − c min ), where c min = min{c(e) | e C}, c max = max{c(e) | e C}
Solutions that enter the RCL are:
Zavod za telekomunikacije 33
Case study: DCMR problem
University of Zagreb, Croatia
(3) e
b
(4)
(3) (1) (3)
h
a d (2) f
(1) (2)
(4) (1) (2)
c
(4)
g
Zavod za telekomunikacije 35
Recall the Minimum Steiner Tree Problem
University of Zagreb, Croatia
Zavod za telekomunikacije 36
Example
(3, 4) University of Zagreb, Croatia
x x x
(3, 2)
(2, 2)
z
z z
x d. x
(2, 2)
(2, 1)
z z
Zavod za telekomunikacije 39
The reduced graph
(3, 4) University of Zagreb, Croatia
a (4, 2)' c
(2, 1)
(3, 1) (4,2)
k (4, 5)'
(3, 1)
f (5, 2) g (1, 3)
(1, 4) (3, 2) o
(2, 5)
n
(1, 1)
(2, 1)
s
(4, 3)
(3, 3)
q
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
Zavod za telekomunikacije t 40
The reduced graph
(3, 4) University of Zagreb, Croatia
a (4, 2)' c
(2, 1)
(3, 1) (4,2)
k (4, 5)'
(3, 1)
f (5, 2) g (1, 3)
(1, 4) (3, 2) o
(2, 5)
Non-terminal n
nodes: [f k s r] (1, 1)
Representation: (2, 1)
s
s = [1 1 1 1] (4, 3)
1: included in solution (3, 3)
0: removed from graph q
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
Zavod za telekomunikacije t 41
4
2
Fitness decoder function
University of Zagreb, Croatia
(2, 1)
Non-terminal s
(4, 3)
nodes: [f k r s] (3, 3)
q
(4, 1) (6, 1) (2, 1)
Initial solution: r
u (4, 2)
s = [1 1 1 1] t
Fitness = 26
Zavod za telekomunikacije 42
4
3
Solving the problem using GRASP
University of Zagreb, Croatia
source (3, 4)
(1, 4) (3, 2) o
(2, 5)
n
(1, 1)
(2, 1)
s
(4, 3)
(3, 3)
q
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
t
Zavod za telekomunikacije 43
GRASP Construction Phase
University of Zagreb, Croatia
source
(3, 4) Δ=6
a (4, 2)' c Unconnected
delay from
destination cost
(2, 1) source
nodes
(3, 1) (4,2)
k (4, 5)'
c 3 4
f (5, 2) g
(3, 1)
(1, 3)
g 4 2
o 3 4
(1, 4) (3, 2)
(2, 5)
o
n 4 5
n
(1, 1) t 6 6
(2, 1)
s
q 6 6 44
(4, 3)
q
(3, 3) u 13
10 76
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
t 44
Zavod za telekomunikacije
GRASP Construction Phase
University of Zagreb, Croatia
unconnected
destination cost
delay from RCL
source
nodes
c 3 4
cmin= 3, cmax= 13
g 4 2 α = 0.25 →
o 3 4 Threshold for RCL:
cmin+ α(cmax-cmin)=
n 4 5
3 + 2.5 = 5.5
t 6 6
q 6 6
u 13 6
Zavod za telekomunikacije 45
GRASP Construction Phase
University of Zagreb, Croatia
(2, 1)
unconnected
delay from
destination cost
(3, 1) (4,2) source
nodes
k (4, 5)'
(3, 1) c 3 4
f (5, 2) g (1, 3)
3 2
g 4 2
(1, 4) (3, 2) o
(2, 5) n 4 5
n
3 6
(1, 1) t 6 6
(2, 1)
s
(4, 3) q 6 6
(3, 3)
q 12 6
(4, 1) (6, 1) (2, 1) u 13 6
r
u (4, 2)
t
Zavod za telekomunikacije 46
GRASP Construction Phase
University of Zagreb, Croatia
unconnected
destination cost
delay from RCL
source
nodes
c 3 4 cmin= 3, cmax= 12
g 3 2 α = 0.25 →
Threshold for RCL:
t 3 6
cmin+ α(cmax-cmin)=
n 4 5 3 + 2.25 = 5.25
q 6 6 Procedure
continues until a
u 12 6 feasible solution
is built…
Zavod za telekomunikacije 47
4
8
GRASP Construction Phase
University of Zagreb, Croatia
(3, 4)
Note, there is a
a (4, 2)' c
cycle (this is not
(2, 1) an MST)
Cost=25
(3, 1) (4,2)
k (4, 5)'
(3, 1)
f (5, 2) g (1, 3)
(1, 4) (3, 2) o
(2, 5)
n
(1, 1)
(2, 1)
s
(4, 3)
(3, 3)
q
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
t
Zavod za telekomunikacije 48
Local Search Phase
University of Zagreb, Croatia
(3, 4)
Representation: set of Steiner (non-
a (4, 2)' c
terminal) nodes S represented by a
binary vector of size |V/D|: (2, 1)
1: included in solution (3, 1) (4,2)
0: excluded from solution k (4, 5)'
(3, 1)
f (5, 2) g (1, 3)
Non-terminal nodes: [f k r s]
Solution from GRASP construction (1, 4) (3, 2) o
phase: [1 1 0 1] (2, 5)
n
(1, 1)
(3, 4)
Δ=6
Solution from construction (4, 2)' c
a
phase:
(2, 1)
f(s)=24 (2, 1)
s
(4, 3)
(3, 3)
q
(4, 1) (6, 1) (2, 1)
Note: cycle was u
r
(4, 2)
removed in t
decoding function
Zavod za telekomunikacije 50
5
1
Local Search Phase
University of Zagreb, Croatia
Current incumbent
N(s)
Selected solution
Current
nbr.
Solution: Current
Iteration Cost solution
s Nbr. incumbent Cost:
of s´
sol. Solution: c(sbest)
MST
sbest
Initialization: 1101 24
0101 21
1001 ∞
1 1101
1111 30
0101 0101 21
1100 ∞
1101 24
0001 ∞
2 0101
0111 27
1101 0101 21
0100 ∞
(3, 4)
Δ=6
a (4, 2)' c
(2, 1)
(3, 1) (4,2)
Non-terminal nodes: [f k r s] k (4, 5)'
(3, 1)
Solution Representation f (5, 2) g (1, 3)
s = [0 1 0 1]
(1, 4) (3, 2) o
Solution: (2, 5)
the DCST shown n
(1, 1)
Fitness function: (2, 1)
s
f(s)=21 (4, 3)
(3, 3)
q
(4, 1) (6, 1) (2, 1)
r
u (4, 2)
t
Zavod za telekomunikacije 52