Knapsack Problem - Introduction to Operations Research - Lecture Slides, Slides of Operational Research

These are the important key points of lecture slides of Introduction to Operations Research are:Knapsack Problem, Interpretation, Volume of Knapsack, Number of Items, Integrality Constraint, Nonnegativity Constraints, Many Variations, Knapsack Problems, Maximum Weight, Recovery of Optimal Solution

Typology: Slides

2012/2013

Uploaded on 01/09/2013

aarif
aarif ๐Ÿ‡ฎ๐Ÿ‡ณ

4.3

(43)

56 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Knapsack Problem
โ€ขThere are many other versions
max
xn
n
N
n
Z w x=
=
โˆ‘
1
v x V x
n
n
N
n n
=
โˆ‘โ‰ค โˆˆ
1
0 1 2, { , , ,...}
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Knapsack Problem - Introduction to Operations Research - Lecture Slides and more Slides Operational Research in PDF only on Docsity!

Knapsack Problem

  • There are many other versions

max

x n n N n

Z = w x

= โˆ‘ 1

v x V x

n n N n n = โˆ‘

1

Interpretation

  • n = 1,2,..., N - Item-type
  • V = Volume of knapsack
  • v n

= Volume of an item of type n

  • w n

= Weight of an item of type n

  • x n

= Number of items of type n put in the

knapsack

DP Strategy

  • Let,

f(s):= maximum weight of knapsack

with available volume of s units,

s=0,1,2,...,V.

  • We are interested in f(V).
  • Clearly, f(0)=
  • Clearly, f(s) =0 for all s smaller than

the smallest item (volume-wise).

  • Clearly, if f(s)>0, then f(s) = f(s-v

n

) + w

n

for some item-type n.

  • Obvious question:

What is the best n?

  • Answer:

The n that maximizes f(s-v

n

) + w

n

(NILN)

V
s
n

f(s) =?

(NILN)

V
s
n
s-v

n

f(s) = f(s-v

n

) + w

n

V
s
n

f(s) =?

Notation

  • As we solve the functional equation

for s=0,1,2,...,V - in this order (why?)

we store the optimal decisions. ie.

N ( s ) := n * : f ( s ) = w

n *

+ f ( s โˆ’ v

n *

  • Since there is no item-type with v n

we introduce a dummy variable n=4,

with w

4

=0 and v

4

n 1 2 3

w

n

v

n

9.2.2 Example

Procedure

  • f(0)= f (^) { w f v (^) } { w f v (^) } w f v f n v n n n n n n ( ) max ( ) max ( ) ( ) ( ) { } 1 1 1 1 0 0 0 1 4 = + โˆ’ = + โˆ’ = 4 + โˆ’ 4 = + = โ‰ค โˆˆ
N(1)={4}

f (^) { w f v (^) } { w f v (^) } w f v f n v n n n n n n ( ) max ( ) max ( ) ( ) ( ) { } 2 2 2 2 0 1 0 2 4 = + โˆ’ = + โˆ’ = 4 + โˆ’ 4 = + = โ‰ค โˆˆ

N(2)={4}

n 1 2 3 4

wn

vn

{ } { } f w f v w f v w f v w f v n v n n n n n n ( ) max ( ) max ( ) max { ( ), ( )} max { , } { , } 3 3 3 3 3 5 0 0 0 5 3 2 4 2 2 4 4 = + โˆ’ = + โˆ’ = + โˆ’ + โˆ’ = + + = โ‰ค โˆˆ

N(3)={2}

f (5) = max n vn โ‰ค 5 w n

  • f (5 โˆ’ v n { )} =^ max n โˆˆ{2,3, 4} w n
  • f (5 โˆ’ v n { )} = max { w 2
  • f (5 โˆ’ v 2 ), w 3
  • f (5 โˆ’ v 3 ), w 4
  • f (5 โˆ’ v 4

= max {5 + f (2),6 + f (1),0 + f (4)} = max{5 + 0,6 + 0, 0 + 6} = 6

N(5)={3,4}

Recovery of Optimal Solution

  • Using the table we select the optimal items

from N(s) and then go to N(s-v

n

  • x (0)

=(0,0,0,0), s=V=

  • x (1)

=(0,0,1,0) (N(13)={2,3}), next s = s-v

3

  • x (2)

=(0,1,1,0) (N(9)={2}, next s = s-v

2

  • x (3)

=(0,2,1,0) (N(6)={2}, next s = s-v

2

  • x (4)

=(0,3,1,0) (N(3)={2}, next s = s-v

2

  • x=(0,3,1,0)*