Lecture 17: Tabu Search © J. Christopher Beck 2008 1

advertisement
Lecture 17: Tabu Search
© J. Christopher Beck 2008
1
Outline

Review:



Tabu Search
Tabu & 1-machine JSP


Local Search & Crystal Maze
Example C.5.4
Tabu & JSP

N1 neighborhood
© J. Christopher Beck 2008
2
Readings

P Ch C.5
© J. Christopher Beck 2008
3
Core Ideas of Local Search




Start with some (random?) assignment
of variables
Look in “neighborhood” formed by
making a small change to the
assignment
Choose best neighbor
Repeat
© J. Christopher Beck 2008
4
Crystal Maze

Place the numbers 1 through 8 in the
nodes such that:
Each number appears exactly once
– No connected
?
?
nodes have
consecutive
numbers
?
?
?

© J. Christopher Beck 2008
?
?
?
5
Random Initial Solution
1?
© J. Christopher Beck 2008
2?
5?
3?
6?
4?
7?
8?
6
Random Initial Solution
1?
2?
5?
3?
6?
4?
7?
8?
“Broken” constraint
Cost = # of broken constraints
© J. Christopher Beck 2008
7
What Should We Do Now?

Move:


Swap two numbers
Which two numbers?


Randomly pick a pair
The pair that will lead to the biggest
decrease in cost

Cost: number of broken constraints
© J. Christopher Beck 2008
8
What Should We Do Now?

Move:


Swap two numbers
Which two numbers?


Randomly pick a pair
The pair that will lead to the biggest
decrease in cost

Cost: number of broken constraints
© J. Christopher Beck 2008
9
Random Initial Solution
1?
© J. Christopher Beck 2008
2?
5?
3?
6?
4?
7?
8?
10
Cost Difference Table
1
2
3
4
5
6
7
8
1
0
2
0
0
© J. Christopher Beck 2008
3
0
-1
0
4
-1
1
0
0
5
0
-1
0
0
0
6
-2
-2
0
0
0
0
7
-3
-1
-1
-1
1
-1
0
8
-2
-3
0
0
-1
0
0
0
11
Cost Difference Table
1
2
3
4
5
6
7
8
1
0
2
0
0
© J. Christopher Beck 2008
3
0
-1
0
4
-1
1
0
0
5
0
-1
0
0
0
6
-2
-2
0
0
0
0
7
-3
-1
-1
-1
1
-1
0
8
-2
-3
0
0
-1
0
0
0
12
Current State
1?
© J. Christopher Beck 2008
2?
5?
3?
6?
4?
7?
8?
13
Swap 1 & 7: Cost 3
7?
© J. Christopher Beck 2008
2?
5?
3?
6?
4?
1?
8?
14
New Cost Difference Table
1
2
3
4
5
6
7
8
1
0
2
0
0
© J. Christopher Beck 2008
3
0
0
0
4
0
2
0
0
5
2
0
0
0
0
6
0
1
1
1
1
0
7
3
1
1
1
2
0
0
8
0
1
-1
1
0
0
1
0
15
Current State
7?
© J. Christopher Beck 2008
2?
5?
3?
6?
4?
1?
8?
16
Swap 3 & 8: Cost 2
7?
© J. Christopher Beck 2008
2?
5?
8?
6?
4?
1?
3?
17
Swap 6 & 7: Cost 1
6?
© J. Christopher Beck 2008
2?
5?
8?
7?
4?
1?
3?
18
Moves




Initial State:
Swap 1 & 7:
Swap 3 & 8:
Swap 6 & 7:
© J. Christopher Beck 2008
Cost
Cost
Cost
Cost
6
3
2
1
19
Cost Difference Table
1
2
3
4
5
6
7
8
1
0
2
1
0
© J. Christopher Beck 2008
3
1
1
0
4
1
2
1
0
5
2
2
1
2
0
6
2
1
4
1
2
0
7
1
3
1
3
1
1
0
8
1
1
2
1
2
1
1
0
20
Now what?


There are no improving
moves to make!
So far, we have been “hillclimbing”
cost
© J. Christopher Beck 2008
moves
21
Tabu Search Idea

Local search but:


Keep a small list of the moves that are
“tabu”: you can’t (un)do them
List has a limited length and the oldest
entries “fall off” when the list is full
© J. Christopher Beck 2008
22
Tabu Search



Start with some (maybe random) initial
state
Look at the moves in the
“neighborhood” and take the best one
Remember the last k moves (“tabu list”)
so you don’t undo them
© J. Christopher Beck 2008
23
Tabu Search & 1-Machine


Example C.5.4, min wjTj
Tabu List Size = 2
Jobs 1
2
3
4
pj
10
10
13
4
dj
4
2
1
12
wj
14
12
1
12
© J. Christopher Beck 2008
Jj, pj, dj, wj
J1, 10, 4, 14
24
TS Step 1: Find Initial Solution

Arbitrarily choose (2, 1, 4, 3)
J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
10
20
J3, 13, 1, 1
24
37
 w T 8 12 16 14 12 12  36 1  500
j j
Jj, pj, dj, wj
© J. Christopher Beck 2008
25
TS Step 2: Evaluate
Neighborhood & Select Move

Neighborhood:
swap

J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
Adjacent pairwise
interchange J4, 4, 12, 12
J1, 10, 4, 14J2, 10, 2, 12
J3, 13, 1, 1
Choose (1,4)
J3, 13, 1, 1
wjTj = 480
J3, 13, 1, 1
wjTj = 436
J4, 4, 12, 12
J2, 10, 2, 12
J1, 10, 4, 14
J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
© J. Christopher Beck 2008
J3, 13, 1, 1
wjTj = 652
26
TS Step 3: Add Move
to Tabu List
wjTj = 436
J4, 4, 12, 12
J2, 10, 2, 12
J1, 10, 4, 14
J3, 13, 1, 1
Tabu: ((1, 4))
Best so far:
(2, 4, 1, 3): 436
© J. Christopher Beck 2008
27
TS Step 2: Evaluate
Neighborhood & Select Move
wjTj = 436
J4, 4, 12, 12
J2, 10, 2, 12
J1, 10, 4, 14
J3, 13, 1, 1
Tabu: ((1, 4))
Choose (4,2)
J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
J3, 13, 1, 1
wjTj = 460
J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
J3, 13, 1, 1
wjTj = 500
J4, 4, 12, 12
J2, 10, 2, 12
© J. Christopher Beck 2008
J3, 13, 1, 1
J1, 10, 4, 14
wjTj = 608
28
TS Step 3: Add Move to Tabu
List
J4, 4, 12, 12
J2, 10, 2, 12 J1, 10, 4, 14
wjTj = 460
J3, 13, 1, 1
Tabu: ((2,4) (1, 4))
Best so far:
(2, 4, 1, 3): 436
© J. Christopher Beck 2008
29
TS Step 2: Evaluate
Neighborhood & Select Move
J4, 4, 12, 12
wjTj = 460
J2, 10, 2, 12 J1, 10, 4, 14
J3, 13, 1, 1
Tabu: ((2,4) (1, 4))
Choose (1,2)
J4, 4, 12, 12
J1, 10, 4, 14
J3, 13, 1, 1
wjTj = 436
J1, 10, 4, 14 J2, 10, 2, 12
J3, 13, 1, 1
wjTj = 440
J2, 10, 2, 12
J4, 4, 12, 12
J4, 4, 12, 12
J2, 10, 2, 12
© J. Christopher Beck 2008
J3, 13, 1, 1
J1, 10, 4, 14
wjTj = 632
30
TS Step 3: Add Move to Tabu
List
J4, 4, 12, 12
J1, 10, 4, 14 J2, 10, 2, 12
wjTj = 440
J3, 13, 1, 1
Tabu: ((1,2), (2,4))
Best so far:
(2, 4, 1, 3): 436
© J. Christopher Beck 2008
31
TS Step 2: Evaluate
Neighborhood & Select Move
J4, 4, 12, 12
wjTj = 440
J1, 10, 4, 14 J2, 10, 2, 12
J3, 13, 1, 1
Tabu: ((1,2), (2,4))
Choose (1,4)
J4, 4, 12, 12
J2, 10, 2, 12
J3, 13, 1, 1
wjTj = 408
J2, 10, 2, 12 J1, 10, 4, 14
J3, 13, 1, 1
wjTj = 460
J1, 10, 4, 14
J4, 4, 12, 12
J4, 4, 12, 12
J1, 10, 4, 14
© J. Christopher Beck 2008
J3, 13, 1, 1
J2, 10, 2, 12
wjTj = 586
32
TS Step 3: Add Move to Tabu
List
J4, 4, 12, 12
J1, 10, 4, 14
J2, 10, 2, 12
J3, 13, 1, 1
wjTj = 408
Tabu: ((1,4), (1,2))
Best so far:
(1,4,2,3): 408

And so on until a bound on the number
of iterations

(actually 408 is optimal, but TS has no way
of knowing)
© J. Christopher Beck 2008
33
Tabu Search Framework


Find initial solution (something quick)
Until N moves are done




Evaluate neighborhood
Choose best non-tabu neighbor
Update tabu list
Return best solution found
© J. Christopher Beck 2008
34
Tabu Search Framework

To completely define a TS algorithm,
you must define



How the initial solution is found
Format and length of tabu list
How to generate a neighborhood from a
given state
© J. Christopher Beck 2008
35
TS & JSP
J0
J1
J2
J0
J0
J1
J2
J1
J2
J1
© J. Christopher Beck 2008
J2
J0
36
TS & JSP



How might you find a first
solution?
What could your tabu list
format be?
Can you define a
neighborhood?
© J. Christopher Beck 2008
37
The N1 Neighborhood for JSP
J0
J0
J1
J2
J1
J2
J1
© J. Christopher Beck 2008
J2
J0
38
The N1 Neighborhood for JSP
J0
J0
J1
J2
J1
J2
J1


J2
J0
Pick a critical path
Neighborhood: all swaps on the chosen
CP
© J. Christopher Beck 2008
39
Tabu Example JSP

Run Tabu on JSP from
previous lectures
Jobs
Processing times
0
J0R0[15]  J0R1[50]  J0R2[60]
1
J1R1[50]  J1R0[50]  J1R2[15]
2
J2R0[30]  J2R1[15]  J2R2[20]
© J. Christopher Beck 2008
40
Download