`
leonzhx
  • 浏览: 798286 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
阅读更多

1.  Problem Denition

    --  Input: n items. Each has a:

        a) Value vi (nonnegative)

        b) Size wi (nonnegative and integral)

        Capacity W (a nonnegative integer)

    --  Output: A subset S of {1, 2, ... , n} that maximizes sum(i in S) {vi} subject to Sum(i in S) {wi} <= W.

 

2.  A Dynamic Programming Algorithm

    --  Formulate recurrence [optimal solution as function of solutions to "smaller subproblems"] based on a structure of an optimal solution.

    --  Let S = a max-value solution to an instance of knapsack.

    --  Case 1: Supose item n not in S. ==> S must be optimal with the first n-1 items (same capacity W) because If S* were better than S with respect to 1st n - 1 items, then this equally true w.r.t. all n items [contradiction]

    --  Case 2: Suppose item n in S. Then S - {n} is an optimal solution with respect to the 1st n - 1 items and capacity W - wn. Because If S* has higher value than S -{n} and its total size <= W - wn,

then S* U {n} has size <= W and value more than S [contradiction]

 

3.  The Subproblems

    --  Let V(i , x) = value of the best solution that:

       (1) uses only the first i items

       (2) has total size <= x

    --  For i in {1, 2, ... , n} and only x,

        V(i , x) = max {V(i-1 , x) (case 1, item i excluded), vi + V(i-1 , x-wi) (case 2, item i included) }

    --  Edge case: If wi > x, must have V(i , x) = V(i-1 , x)

    --  Identify the subproblems:

        a) All possible prefixes of items {1, 2, ... , i} , i in { 0, 1, 2, ..., n}

        b) All possible (integral) residual capacities x in {0, 1, 2, ... , W}

    --  Use recurrence to systematically solve all problems:

        a) Let A = 2-D array

        b) Initialize A[0 , x] = 0 for x = 0, 1, ... , W

        c) For i = 1, 2, ... , n

                For x = 0, 1, ... , W

                    A[i , x] := max { A[i - 1 , x] , A[i - 1; x - wi ] + vi } (Ignore second case if wi > x)

        d) Return A[n,W]

    --  Running Time: O(nW)

 

4.  Example :



 

  • 大小: 44.6 KB
分享到:
评论

相关推荐

    FPTAS for the Knapsack Problem

    背包问题近似算法PTAS和FPTAS. The Knapsack Problem and Fully Polynomial Time Approximation Schemes (FPTAS). 作者: Katherine Lai, Prof. M. X. Goemans

    An improved genetic algorithm for the multi constrained 0–1 knapsack problem

    在本文中,作者提出了一种改进的混合遗传算法(Hybrid Genetic Algorithm, HGA)来解决多约束0-1背包问题(Multiconstrained 0-1 Knapsack Problem, MKP)。MKP是一个著名的NP完全组合优化问题,其定义如下: 目标...

    华南理工大学计算机全英班算法设计实验

    4)And compare the results between the knapsack problem and the 0/1 knapsack problem. 5)Write down the report in which there should be the execution results of the program. Experiment 3 The Prim...

    Best-First-Tree 0-1 Knapsack

    best-first-search branch and bound algorithm for the knapsack problem

    np难问题近似算法(绝版好书)

    knapsack problem 9.3.2 The minimum makespan and the technique of dual approximations 9.3.3 Geometric packing and covering--the shifting technique 9.4 Best: unless NP = P 9.4.1 The k-center problem ...

    0-1 pack_rememberscj_C++_

    0-1 Detailed explanation of the knapsack problem algorithm and all the codes can provide an effective reference

    算法上机!!

    Solve the problem both as fractional knapsack and 0/1 knapsack. A simple scheduling problem. We are given jobs j1, j2… jn, all with known running times t1, t2… tn, respectively. We have a single ...

    01背包问题-huiying_hw4.rar

    1.Implement a GA optimization procedure for 0/1 knapsack problem: - For the given list of 10, 15, 20, 740items, load the knapsack with weight capacity 200 and volume of 500. Each itemcan be present ...

    The-Knapsack-Problem-Dynamic-programming:动态规划是一种求解优化问题的方法

    背包问题动态规划背包问题是组合优化中的一个问题: 给定一组物品,每个物品都有一个质量和一个价值,确定每个物品要包含在一个集合中的数量,以便总重量小于或等于给定的限制,并且总价值尽可能大。...

    AN IMPROVED NICHE GENETIC ALGORITHM

    A simulated annealing based niche genetic algorithm (SANGA) has been presented to strength the optimization ability of niche genetic algorithm (NGA). The improved idea is to define ...problem.

    The Algorithm Design Manual (2rd Edition)

    13.10 Knapsack Problem 13.11 Discrete Fourier Transform 14 Combinatorial Problems 14.1 Sorting 14.2 Searching 14.3 Median and Selection 14.4 Generating Permutations 14.5 Generating Subsets ...

    A novel approach for radio resource management in multi-dimensional heterogeneous 5G networks

    A GRA-BKP (Grey Relational Analysis-Bounded Knapsack Problem) scheme was proposed for the radio resource management of the 5G networks. It consists of two steps, access selection and admission control...

    Programming Interview Problems and Algorithms in Ruby

    Tree Serialization, Finding the Top k Elements of Data Streams, MapReduce, Partial Sorting, the Skyline Problem, DFS, BFS and Topological Sorting of Dags, the Alternative Alphabet and the Phone Words...

    dyer1984.pdf

    “An algorithm for solving the linear program associated with the multiple-choice knapsack problem described”说明文档中描述了一种用于求解与多重选择背包问题相关联的线性规划问题的算法。线性规划是数学...

    算法设计技巧与分析课件(英文版):ch8 The greedy approach.ppt

    6. 贪心算法的例子:贪心算法的一个典型例子是分数背包问题(Fractional Knapsack Problem)。该问题的目标是找到最大价值的物品组合,满足背包容量的限制。贪心算法可以高效地解决该问题。 7. 贪心算法的分析:...

    Efficient CPU-GPU cooperative computing for solving the subset-sum problem

    本文的焦点是“Efficient CPU-GPU cooperative computing for solving the subset-sum problem”,它针对的是如何更有效地利用CPU和GPU资源来解决子集和问题,这是一个在计算机科学中具有挑战性的计算问题。...

    Business.Analytics.for.Decision.Making.14822217

    Chapter 6: The Traveling Salesman Problem Chapter 7: Vehicle Routing Problems Chapter 8: Resource-Constrained Scheduling Chapter 9: Location Analysis Chapter 10: Two-Sided Matching Part III: ...

Global site tag (gtag.js) - Google Analytics