



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This course object is to design and analysis of modern algorithms, different variants, accuracy, efficiency, comparing efficiencies, advance designing techniques. In this course algorithm will be analyse using real world examples. This lecture includes: Knapsack, Problem, Dynamic, Programming, Generalization, Cyclic, Assembly, Line, Scheduling, Multiprocessor
Typology: Slides
1 / 35
This page cannot be seen from the preview
Don't miss anything!




























The assembly line problem is well known in the area ofmultiprocessor scheduling.
-^
In this problem, we are given a set of tasks to beexecuted by a system with n identical processors.
-^
Each task, Ti, requires a fixed, known time pi to execute.
-^
Tasks are indivisible, so that at most one processor maybe executing a given task at any time
-^
They are un-interruptible, i.e., once assigned a task, maynot leave it until task is complete.
-^
The precedence ordering restrictions between tasks may
0-1 Knapsack Problem
-^
Problem Analysisā Divide and Conquerā Dynamic Solution
-^
Algorithm using Dynamic Programming
-^
Time Complexity
-^
Generalization, Variations and Applications
-^
Conclusion
The knapsack problem arises whenever there isresource allocation with no financial constraints Problem Statementā¢^
A thief robbing a store and can carry a maximalweight of W into his knapsack. There are n itemsand ith item weight is w
and worth is vi^
dollars.i^
What items should thief take, not exceeding thebag capacity, to maximize value? Assumption
the items may not be broken into smaller pieces,so thief may decide either to take an item or toleave it, but may not take a fraction of an item.
Problem Statement
-^
You are in Japan on an official visit and want tomake shopping from a store (Best Denki)
-^
A list of required items is available at the store
-^
You are given a bag (knapsack), of fixed capacity,and only you can fill this bag with the selecteditems from the list.
-^
Every item has a value (cost) and weight,
-^
Problem Constructionā¢^
You have prepared a list of n objects for whichyou are interested to buy, The items arenumbered as i
, i 1
,.. ., i 2
n
Capacity of bag is W
-^
Each item i has value v
, and weigh wi
i
We want to select a set of items among i
, i 1
i^ which do not exceed (in total weight) capacity Wn^ of the bag
-^
Total value of selected items must be maximum
-^
How should we select the items?
Given a list: i
, i 1
,.. ., i 2
, values: vn
, v 1
,.. ., v 2
andn
weights: w
, w 1
,.. ., w 2
respectivelyn
-^
Of course W
ļ³^
0, and we wish to find a set S of items
such that S
ļ {i^1
, i^2
,.. ., i
} thatn
maximizessubject to
Si
ļ£ Si
i^
W w
Approachā¢^
Partition the knapsack problem into sub-problems
-^
Find the solutions of the sub-problems
-^
Combine these solutions to solve original problem Commentsā¢^
In this case the sub-problems are not independent
-^
And the sub-problems share sub-sub-problems
-^
Algorithm repeatedly solves common sub-sub-problems and takes more effort than required
-^
Because this is an optimization problem andhence dynamic approach is another solution if weare able to construct problem dynamically
Step1 (Structure):ā¢^
Characterize the structure of an optimal solution
-^
Next decompose the problem into sub-problems
-^
Relate structure of the optimal solution of originalproblem and solutions of sub-problems Step 2 (Principal of Optimality)ā¢^
Define value of an optimal solution recursively
-^
Then express solution of the main problem interms of optimal solutions of sub-problems.
Step1 (Structure):ā¢^
Decompose problem into smaller problems
-^
Construct an array V[0..n, 0..W]
-^
V[i, w] = maximum value of items selected from{1, 2,.. ., i}, that can fit into a bag with capacity w,where 1
i^ ļø
n, 1
w
V[n, W] = contains maximum value of the itemsselected from {1,2,ā¦,n} that can fit into the bagwith capacity W storage
-^
Hence V[n, W] is the required solution for ourknapsack problem
Step 2 (Principal of Optimality)ā¢^
Recursively define value of an optimal solution interms of solutions to sub-problemsBase Case: Since
-^
V[0, w] = 0, 0
w
W, no items are available
V[0, w] = -
ļ„, w < 0, invalid
V[i, 0] = 0, 0
i^ ļø
n, no capacity available
Recursion:V[i, w] = max(V[i-1, w], v
])i
for 1
i^ ļø
n, 0
w
Select Item i (possible if w
ļøi^
w)
In this way, we gain value v
but use capacity wi^
i
Items left = {1,2,... , i-1}, storage limit = w - w
,i
Max. value, from items {1,2, ā¦,i-1} = V[i-1,w ā w
]i
Total value if we select item i = v
]i
Finally, the solution will be optimal if we take themaximum of
V[i-1,w] andvi+ V[i-1,w ā w^
]i
Hence V[i, w] = max(V[i-1,w], v
]i
-^
V[1, 1] = 0,
-^
V[1, 2] = 0
-^
V[1, 3] = 0,
-^
V[1, 4] = 0
-^
V[i, j] = max(V[i-1, j], v
]);i
-^
V[1, 5] = max(V[0, 5], v
]); 1
= max(V[0, 5], 10 + V[0, 5 - 5])= max(V[0, 5], 10 + V[0, 0])= max(0, 10 + 0) = max(0, 10) = 10
i^
1
2
3
4
v^ i^
10
40
30
50
w^ i^
5
4
6
3
Capacity = 10