Lecture 6 Knapsack Problem Quadratic Assignment Problem
-
Upload
randolph-malone -
Category
Documents
-
view
242 -
download
1
description
Transcript of Lecture 6 Knapsack Problem Quadratic Assignment Problem
1
Lecture 6 Lecture 6 Knapsack ProblemKnapsack Problem
Quadratic Assignment ProblemQuadratic Assignment Problem
2
OutlineOutline
knapsack problemknapsack problem quadratic assignment problemquadratic assignment problem
3
Knapsack ProblemKnapsack Problem
4
Knapsack ProblemKnapsack Problem
very useful sub-problems very useful sub-problems booksbooks
Knapsack Problems by Hans Kellerer, Ulrich Knapsack Problems by Hans Kellerer, Ulrich Pferschy, and David Pisinger (2004) Pferschy, and David Pisinger (2004)
Knapsack Problems: Algorithms and Knapsack Problems: Algorithms and Computer Implementations by Silvano Computer Implementations by Silvano Martello and Paolo Toth (1990)Martello and Paolo Toth (1990)
5
Problem StatementProblem Statement nn types of products types of products
weight of type weight of type ii: : aaii
value of type value of type ii: : ppii
capacity of truck: capacity of truck: bb kg kg question: selection of products to maximize the total value in question: selection of products to maximize the total value in
a trucka truck special tpye: 0-1 knapsack problem: special tpye: 0-1 knapsack problem: ii {0, 1} {0, 1}
1 1 2 2
1 1 2 2
max ... ,. . ... ,
non-negative integers.
n n
n n
i
p p ps t a a a b
i = number of type-i products put in the truck
6
Common Knapsack ProblemsCommon Knapsack Problems
project selection problemsproject selection problems capital budgeting allocation problems capital budgeting allocation problems inventory stocking problemsinventory stocking problems ……
7
Multi-Dimensional Multi-Dimensional Knapsack ProblemKnapsack Problem
nn types of products types of products weight of type weight of type ii: : aaii
volume of type volume of type ii: : vvii
value of type value of type ii: : ppii
capacity of truckcapacity of truck bb kg kg c c mm33
question: selection of products to maximize the total value question: selection of products to maximize the total value in a truckin a truck
i = number of type-i products put in the truck
1 1 2 2
1 1 2 2
1 1 2 2
max ... ,. . ... ,
... ,non-negative integers.
n n
n n
n n
i
p p ps t a a a b
v v v c
8
Cutting-Stock ProblemCutting-Stock Problem
knapsack problem: a sub-problem in solving knapsack problem: a sub-problem in solving cutting-stock problem by column generation cutting-stock problem by column generation
7-meter steel pipes of a given diameter7-meter steel pipes of a given diameter orderorder
150 pieces of 1.5-meter segments150 pieces of 1.5-meter segments 250 pieces of 2-meter segments250 pieces of 2-meter segments 200 pieces of 4-meter segments200 pieces of 4-meter segments
objective: minimize the amount of trim offobjective: minimize the amount of trim off
9
Formulation of Formulation of the Cutting-Stock Problemthe Cutting-Stock Problem
decisions: how to cut the pipesdecisions: how to cut the pipes three types of segmentsthree types of segments
type-1 segment: 1.5 mtype-1 segment: 1.5 m type-2 segment: 2 mtype-2 segment: 2 m type-3 segment: 4 m type-3 segment: 4 m
aaijij = the number of = the number of jj type segments produced by the type segments produced by the iith th cut patterncut pattern
the the iith cut pattern: (th cut pattern: (aaii11, , aaii22, , aaii33))TT with trim loss with trim loss ttii e.g., ae.g., a11 = ( = (aa1111, , aa1212, , aa1313))TT = (0, 0, 1) and = (0, 0, 1) and tt11 = 3 = 3
10
Formulation of Formulation of the Cutting-Stock Problemthe Cutting-Stock Problem
totally 15 cutting patterns totally 15 cutting patterns
Cut Patterns
x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15
1.5-meter segment
0 1 0 2 0 2 1 0 2 1 0 4 3 2 1
2-meter segment 0 0 1 0 3 2 2 2 1 1 1 0 0 0 0
4-meter segment 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0
trim loss (meter) 3 1.5 1 0 1 0 1.5 3 2 3.5 5 1 2.5 4 5.5
11
Formulation of Formulation of the Cutting-Stock Problemthe Cutting-Stock Problem
xi = the # of steel pipes cut in the ith pattern
151
151 1
151 2
151 3
min ,
. . 150,
250,
200,non-negative integers
i i i
i i i
i i i
i i i
i
t x
s t a x
a x
a xx
12
Solution of Solution of the Cutting-Stock Problemthe Cutting-Stock Problem
for Simplex Method, the reduced cost of the for Simplex Method, the reduced cost of the iith th variable (i.e., the variable (i.e., the iith cutting pattern) can be th cutting pattern) can be shown to relate to a Knapsack Problemshown to relate to a Knapsack Problem
max max 11aa11 + + 22aa22 + + 33aa33, ,
ss..tt.. 1.51.5aa11 + 2 + 2aa22 + 4 + 4aa33 7, 7,
where where jj = value of the = value of the jjth dual variable of th dual variable of the current basic feasible solutionthe current basic feasible solution
13
Solution of Solution of the Cutting-Stock Problemthe Cutting-Stock Problem
Formulate a LP Formulate a LP
Solve the LP to get a BFSSolve the LP to get a BFS
Get dual variables Get dual variables jj of the BFSof the BFS
Solve a knapsack problem to get a Solve a knapsack problem to get a new, valuable cutting patternnew, valuable cutting pattern
any new any new cutting cutting
pattern?pattern?
Stop. Current BFS is Stop. Current BFS is optimumoptimum
NoNo
Add a cutting pattern (i.e., Add a cutting pattern (i.e., new column) to the LPnew column) to the LP
YesYes
Resolve the LP to get Resolve the LP to get a new BFSa new BFS
14
Solution of Solution of the Knapsack Problem the Knapsack Problem
dynamic program: more appropriatedynamic program: more appropriate branch and bound: not as appropriatebranch and bound: not as appropriate
15
Quadratic Assignment ProblemQuadratic Assignment Problem
16
Door Assignment in a Door Assignment in a Distribution CenterDistribution Center
a DC with two-inbound and two-outbound doorsa DC with two-inbound and two-outbound doors cross-docking operations to handle goods of two suppliers and two cross-docking operations to handle goods of two suppliers and two
retailersretailers objective: to minimize the total goods-distanceobjective: to minimize the total goods-distance
Retailer 1 Retailer 2Supplier 1 77 00Supplier 2 44 66
Door a Door bDoor A 22 33Door B 33 22
Distances Among the DoorsDistances Among the Doors
Amount of Goods from Amount of Goods from Suppliers to RetailersSuppliers to Retailers
Door A
Door B
Door a
Door b
InboundDoors
OutboundDoors
17
Door Assignment in a Door Assignment in a Distribution CenterDistribution Center
goods-distance for supplier goods-distance for supplier 1 1 Door Door AA, supplier 2 , supplier 2 Door Door BB, retailer 1 , retailer 1 Door Door aa, retailer 2 , retailer 2 Door Door bb
Door A
Door B
Door a
Door b
InboundDoors
OutboundDoors
Door a Door b
Door A 22 33
Door B 33 22
Distances Among the DoorsDistances Among the Doors
Retailer 1 Retailer 2
Supplier 1 77 00
Supplier 2 44 66
Amount of Goods from Amount of Goods from Suppliers to RetailersSuppliers to Retailers3
32
2A
B
a
b
46
7A
B
a
b
total goods-distance total goods-distance = (2)(7) + (3)(4) + (2)= (2)(7) + (3)(4) + (2)(6)(6)formulate an optimization formulate an optimization
to find the door assignment to find the door assignment that minimizes the total that minimizes the total
goods-distancegoods-distance
18
Formulation of Formulation of the Door Assignment Problemthe Door Assignment Problem
1, if supplier is assigned to inbound door , 1,2; , ;
0, . .,iji j
x i j A Bo w
1, if retailer is assigned to outbound door , 1,2; , ;
0, . .,iji j
y i j a bo w
Door a Door b
Door A 22 33
Door B 33 22
Distances Among the DoorsDistances Among the Doors
Retailer 1 Retailer 2
Supplier 1 77 00
Supplier 2 44 66
Amount of Goods from Amount of Goods from Suppliers to RetailersSuppliers to Retailers
yy11aa yy11bb yy22aa yy22bb
xx11AA 1414 2121 00 00
xx11BB 2121 1414 00 00
xx22AA 88 1212 1212 1818
xx22BB 1212 88 1818 1212
Cost Coefficients Cost Coefficients ccijklijkl, for , for xxijij = = yyklkl = 1 = 1
19
Formulation of Formulation of the Door Assignment Problemthe Door Assignment Problem
yy11aa yy11bb yy22aa yy22bb
xx11AA 1414 2121 00 00
xx11BB 2121 1414 00 00
xx22AA 88 1212 1212 1818
xx22BB 1212 88 1818 1212
1 1 2 2 1 2 1 2
1 1 2 2 1 2 2 2
. .1, 1, 1, 1,1, 1, 1, 1,
{0,1}, 1,2; , ; {0,1}, 1,2; , .
A B A B A A B B
a b a b a a a b
ij ij
s tx x x x x x x xy y y y y y y yx i j A B y i j a b
1 1 1 1 1 1 1 1
2 1 2 1 2 1 2 1
2 2 2 2 2 2 2 2
14 21 21 14min 8 12 12 8
12 18 18 12 ,
A a A b B a B b
A a A b B a B b
A a A b B a B b
x y x y x y x yx y x y x y x yx y x y x y x y
20
Quadratic Assignment ProblemQuadratic Assignment Problem
four sets four sets SS11, , TT11, , SS22, , TT22, , SS11 and and TT1 1 of of mm items, items, SSnn and and TTnn of of nn items items
two groups of assignments two groups of assignments the pairing of items in the pairing of items in SS11 and and TT1 1
the pairing of items in the pairing of items in SS22 and and TT2 2
cost of assigning item cost of assigning item ii SS11, , jj TT11, , kk SS22, , ll TT22 = = ccijklijkl
21
Quadratic Assignment ProblemQuadratic Assignment Problem
1 1 1 1
1
1
1
1
min ,
. .
1, ;
1, ;
1, ;
1, ;, {0,1}, 1 , ;1 , .
m m n ni j k l ijkl ij kl
mi ij
mj ij
nk klnl kl
ij kl
c x y
s t
x j
x i
y l
y kx y i j m k l n
22
Another Another Quadratic Assignment ProblemQuadratic Assignment Problem
two sets two sets SS and and TT, each of , each of nn items items
the pairing of items in the pairing of items in SS and and TT as in an as in an assignment problemassignment problem
cost of pairing cost of pairing ii SS with with jj TT and and kk SS with with ll TT: : ccijklijkl
23
Another Another Quadratic Assignment ProblemQuadratic Assignment Problem
1, if is assigned to ,0, . .ij
i S j To w
1 1, 1,..., ;nj ij i n
1 1, 1,..., ;ni ij j n
{0,1}, 1 , .ij i j n
, , , 1
min ,nijkl ij kli j k l
k ic
. .s t
24
ExampleExample
three factories three factories aa, , bb, , cc three cities three cities AA, , BB, , C C
AA BB CC
AA 1414 88
BB 1111
CC
Distance Between the CitiesDistance Between the Cities
aa bb cc
aa 1 01 0 1515
bb 1818
cc
Quantities Shipped Among the FactoriesQuantities Shipped Among the Factories
1, if factory is assigned to city ,0, . .
, , ; , ,
iji j
o wi a b c j A B C
25
ExampleExample
aAaA aBaB aCaC bAbA bBbB bCbC cAcA cBcB cCcC
aAaA 140140 8080 210210 120120
aBaB 140140 110110 210210 165165
aCaC 8080 110110 120120 165165
bAbA 252252 144144
bBbB 252252 198198
bCbC 144144 198198
cAcA
cBcB
cCcC
aa bb cc
aa 1 01 0 1515
bb 1818
cc
Quantities Shipped Quantities Shipped Among the FactoriesAmong the FactoriesAA BB CC
AA 1414 88
BB 1111
CC
Distance Between the CitiesDistance Between the Cities
26
ExampleExample1, if { , , } is assigned to { , },0, . .ij
i a b c j AB Co w
1, ;
1, ;
{0,1}, { , , }, { , , }.
i ij
j ij
ij
j
i
i a b c i A B C
, , , 1, ,
1min ,2
nijkl ij kl
i j k li k j l
c
. .s t
27
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
non-linear objective function with terms non-linear objective function with terms such as such as ijijklkl
to linearize the non-linear term to linearize the non-linear term ijijklkl
let let ijklijkl = = ij ij klkl
need to ensure that need to ensure that ijklijkl = 1 = 1 ij ij klkl = 1 = 1
28
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
ijklijkl = 1 = 1 ij ij klkl = 1 = 1 ijklijkl = 1 = 1 ij ij = 1 and = 1 and klkl = 1 = 1
two parts two parts ijklijkl = 1 = 1 ij ij = 1 and = 1 and klkl = 1 = 1
ij ij = 1 and = 1 and klkl = 1 = 1 ijklijkl = 1= 1
trickstricks ijkl ijkl ijij and and ijkl ijkl kl kl
ijij + + klkl 1 + 1 + ijklijkl
29
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
drawback of the methoddrawback of the method addition of one variable and three constraints addition of one variable and three constraints
for one cross-product for one cross-product nn((nn1)/2 cross products for 1)/2 cross products for nn ij ij ’s ’s
any method to add less variables or less any method to add less variables or less constraintsconstraints
30
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
three cross-products 2three cross-products 21122+3+311331144 of of
four variables four variables 11, , 22, , 33, , 44
the previous method: 3 new variables and 9 the previous method: 3 new variables and 9 new constraints new constraints
another method with 1 new variable and 3 another method with 1 new variable and 3 new constraintsnew constraints
31
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
let let ww = 2 = 21122+3+311331144 = = 11(2(222+3+33344))
hope to have: hope to have: 11 = 1 = 1 ww = 2 = 222+3+33344, and , and 11
= 0 = 0 ww = 0 = 0 possible values of possible values of ww {-1, 0, 1, 2, 3, 4, 5} {-1, 0, 1, 2, 3, 4, 5}
11 = 0 = 0 ww = 0: = 0: ww 5 511
how to model how to model 11 = 1 = 1 ww = 2 = 222+3+33344??
32
Linearization of Linearization of the Quadratic Assignment Problem the Quadratic Assignment Problem
to model to model 11 = 1 = 1 ww = 2 = 222+3+33344
ww = 2 = 222+3+33344
ww 2 222+3+33344 and and ww 2 222+3+33344
11 = 1 = 1 ww 2 222+3+33344 and and ww 2 222+3+33344
when when 11 = 1: two valid constraints = 1: two valid constraints
ww 2 222+3+33344 and and ww 2 222+3+33344
when when 11 = 0: two redundant constraints = 0: two redundant constraints
ww 2 222+3+33344+5+55511 and and ww 2 222+3+33344+5+51155