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

1.  Strategies for NP-Complete Problems

    --  Identify computationally tractable special cases.

        - knapsack capacity W = polynomial in number of items n

    --  Heuristics

        - Pretty good greedy heuristic

        - Excellent dynamic programming heuristic

    --  Exponential time but better than brute-force search

        - O(nW)-time dynamic programming vs. O(2^n) brute-force search.

 

2.  Knapsack Revisited

    --  Input: n items. Each has a positive value vi and a size wi . Also, knapsack capacity is W.

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

 

3.  A Greedy Heuristic

    --  Motivation: Ideal items have big value, small size.

    --  Step 1: Sort and reindex item so that v1/w1 >= v2/w2 >= ... >=vn/wn

    --  Step 2: Pack items in this order until one doesn't fit, then halt. (can continue to pack the follow-up items that can fit)

 

4.  A Refined Greedy Heuristic

    --  Fact: Greedy solution can be arbitrarily bad relative to an optimal solution.(i.e. v1 = 2, w1 = 1, v2 = 1000, w2 = 1000, W = 1000)

    --  Fix: Step 3: Return either the Step 2 solution, or the maximum valuable item, whichever is better.

    --  Theorem: Value of the 3-step greedy solution is always at least 50% value of an optimal solution.       --  Runnig time: O(n log n)

 

5.  Greedy Fractional Algorithm

    --  We were allowed to fill fully the knapsack using a suitable “fraction" (like 70%) of item (k+1)

    --  Greedy fractional solution at least as good as every non-fractional feasible solution.

        --  Let S = an arbitrary feasible solution

        --  Suppose l units of knapsack filled by S with items not packed by the greedy fractional solution

        --  Must be at least l units of knapsack filled by greedy fractional solution not packed by S

        --  By greedy criterion, items in Greedy Fractional solution have larger bang-per-buck vi/wi than those in S [i.e., more valuable use of space]

        --  Total value of greedy fractional solution at least that of S

 

6.  Analysis of Greedy Heuristic

    --  Suppose our greedy algorithm picks the 1st k items (sorted by vi/wi ).

    --  Value of 3-step greedy algorithm >= total value of 1st k items

        Value of 3-step greedy algorithm >= value of (k + 1)th item

        2 (value of 3-step greedy) >= total value of 1st (k + 1) items = total value of greedy fractional solution >= optimal knapsack solution

    --  Analysis is Tight (i.e. W = 1000 , v1 = 502, v2 = v3 = 500, w1 = 501, w2 = w3 = 500)

    

7.  A Refined Analysis

    --  Suppose: Every item i has size wi <= 10% * knapsack capacity W.

    --  Consequence: If greedy algorithm fails to pack all items, then the knapsack is >= 90% full.

    --  Value of 2-step greedy algorithm >= 90% * value of greedy fractional solution >= 90% * value of an optimal solution.

    --  In general, if maxi wi <= m%W, then 2-step greedy value is >= (1 - m%)*optimal

 

8.  Arbitrarily Good Approximation

    --  Goal: For a user-specified parameter e > 0 (e.g., e = 0.01), guarantee a (1 - e)-approximation.

    --  Catch: Running time will increase as e decreases. (i.e., algorithm exports a running time vs. accuracy trade-off).

    --  High-level idea: Exactly solve a slightly incorrect, but easier, knapsack instance.

    --  If vi's are integers, can solve knapsack via dynamic programming in O(n^2vmax) time, where vmax = maxi{vi}. 

    --  Plan: Throw out lower-order bits of the vi's!

 

9.  A Dynamic Programming Heuristic

    --  Step 1: Round each vi down to the nearest multiple of m [larger m ==> throw out more info ==> less accuracy ==> m depends on e]

        Divide the results by m to get vi' (integers). (i.e., vi' = floor(vi/m) )

    --  Step 2: Use dynamic programming to solve the knapsack instance with values v1', ... , vn', sizes w1, ..., wn, capacity W.

        Running time = O(n^2 max{vi'})

 

10.  Two Dynamic Programming Algorithms

    --  Dynamic programming algorithm #1: 

        --  Assume sizes wi and capacity W are integers

        --  Running time = O(nW)

    --  Dynamic programming algorithm #2:

        --  Assume values vi are integers

        --  Running time = O(n^2vmax), where vmax = max{vi}

 

11.  The Subproblems and Recurrence

    --  Subprolems: For i = 0, 1, ... , n and x = 0, 1, ... , n*vmax define

        S(i,x) = minimum total size needed to achieve value >= x while using only the first i items. (Or +Infinity if impossible)

    --  Recurrence: (i >= 1)

        S(i,x) = min { S(i-1,x) [Case 1, item i not used in optimal solution] , wi + S(i-1,x-vi) [Case 2, item i used in optimal solution, interpreted as 0 if vi > x]

 

12.  The Algorithm

    --  Let A = 2-D array [indexed by i = 0, 1, ... , n and x = 0, 1, ... , n*vmax]

    --  Base case: A[0,x] = 0 if x = 0 , +Infinity otherwise

    --  For i = 1, 2, ... , n

            For x = 0, 1, ... , n*vmax 

                A[i,x] = min{A[i-1,x] , wi+ A[i-1,x-vi]}

    --  Return the largest x such that A[n,x] <= W

    --  Running time: O(n^2vmax)

 

13.  Accuracy Analysis

    --  Since we rounded down to the nearest multiple of m,  m*vi' in [vi-m , vi] for each item i.

    --  If S* = optimal solution to the original problem (with the original vi), and S = our heuristic's solution, then

              Sum(i in S){vi'} >= Sum(i in S*){vi'} [Since S is optimal for the vi'] 

    --  Sum(i in S){vi} >= m * Sum(i in S) {vi'} >= m * Sum(i in S*){vi'} >= Sum{i in S*} {vi -m} >= Sum(i in S*} - nm

    --  Constraint: Sum(i in S){vi} >= (1-e)*Sum(i in S*){vi}

    --  To achieve above constraint: Choose m small enough that mn <= e * Sum(i in S*){vi}

        Sum(i in S*){vi} is unknown to algorithm, but definitely >= vmax

        Sufficient: Set m so that mn <= e*vmax, i.e., heuristic uses m = e*vmax/n

    --  Running time is O(n^2vmax') , vmax' <= vmax/m = vmax / (e*vmax/n) , so running time is O(n^3/e)

分享到:
评论

相关推荐

    背包问题之贪婪算法求解C语言源代码).rar_greedy_greedy knapsack_knapsack greedy_背包

    贪婪算法是一种在每一步选择中都采取在当前状态下最好或最优(即最有利)的选择,从而希望导致结果是全局最好或最优的算法。在背包问题中,贪婪算法的应用旨在尽可能地填充背包,同时使得装入物品的总价值最大。...

    abcd.rar_greedy knapsack_knapsack c_背包问题 贪婪_贪婪_贪婪算法

    贪婪算法是一种在每一步选择中都采取在当前状态下最好或最优(即最有利)的选择,从而希望导致结果是全局最好或最优的算法。在解决背包问题时,贪婪算法的应用非常典型。背包问题是一个经典的组合优化问题,其目标是...

    A GREEDY HEURISTIC FOR THE SET-COVERING PROBLEM

    集合覆盖问题可以被定义为:给定一个二进制矩阵\( A \)(大小为\( m \times n \)),其中每一行代表一个集合,每一列代表一个元素。此外,还有一个正权重向量\( c^T \)(长度为\( n \)),以及一个全为1的列向量\( e...

    4-7d多处最优服务次序问题.zip_greedy knapsack_passage2zn_算法设计与分析;贪心_背包问题

    在IT领域,优化问题的解决方法常常涉及到各种算法,其中包括贪心算法。本文将深入探讨“4-7d多处最优服务次序问题”、"4-1会场活动安排"以及"特殊0-1背包问题",这些都与贪婪策略和背包问题紧密相关。...

    python 实现 Knapsack 背包问题 课程设计

    python 实现 Knapsack 背包... Greedy Knapsack Knapsack Recursive Approach Knapsack Tests Test Greedy Knapsack Test Knapsack 包括实现 贪婪的背包 背包 递归方法背包 测试 测试贪婪背包 测试背包

    Greedy Layer-Wise Training

    et al recently introduced a greedy layer wise unsupervised learning algorithm for Deep Belief Networks DBN a generative model with many layers of hidden causal variables In the context of the above ...

    GREEDY FUNCTION APPROXIMATION: A GRADIENT BOOSTING MACHINE

    ### GREEDY FUNCTION APPROXIMATION: A GRADIENT BOOSTING MACHINE #### 1. 引言与背景 本文探讨了一种新的函数逼近方法——贪心函数逼近法(Greedy Function Approximation, GFA),该方法特别关注梯度提升机...

    论文研究-A Fast Greedy Algorithm for Outlier Mining.pdf

    A Fast Greedy Algorithm for Outlier Mining,何增友,,The task of outlier detection is to find small groups of data objects that are exceptional when compared with rest large amount of data....

    A Greedy, Graph-Based Algorithm

    在IT领域,尤其是在生物信息学中,"A Greedy, Graph-Based Algorithm for the Alignment of Multiple Homologous Gene Lists"是一个重要的研究主题。该算法利用贪婪策略和图论的方法来解决多序列比对的问题,特别是...

    利用A*, greedy, Dijkstra, RRT算法,针对迷宫障碍物栅格地图,采用8连接方法,找一 条从起始点到目标点的无

    在路径规划领域,A*、贪婪(Greedy)、Dijkstra和RRT( Rapidly-exploring Random Trees)算法是四种常见的寻路策略,用于解决如何在有障碍的环境中找到从起点到终点的有效路径。这些算法各有特点,适用于不同的场景...

    A fully automated greedy square jigsaw puzzle solver

    ### 完全自动贪婪式方形拼图求解器的关键知识点 #### 一、研究背景与问题定义 在方形拼图问题中,目标是通过一系列非重叠且无序的方形拼图块重构出完整的图像。该问题不仅是休闲娱乐中的常见挑战,同时也具有重要...

    greedy_c源程序

    根据提供的文件信息,本文将对“greedy_c源程序”中的关键知识点进行详细的解析与说明。此程序主要涉及了贪心算法(Greedy Algorithm)在C++中的实现,并结合具体的代码示例进行了演示。 ### 一、贪心算法概述 ...

    Greedy算法经典问题的解答

    ### Greedy算法经典问题解析 #### 一、Greedy算法概览 Greedy算法是一种简单直观的算法设计策略,它在每一步选择中都采取当前看起来最优的选择,以期望达到全局最优解。这种策略并不总是能得到全局最优解,但在很...

    Greedy Snake.zip

    本项目“Greedy Snake.zip”是一个基于Windows 32位汇编语言编写的贪吃蛇游戏,展示了汇编语言在实现游戏逻辑方面的强大能力。下面我们将深入探讨该项目涉及的知识点。 一、汇编语言基础 汇编语言是计算机程序设计...

    计算模型与算法技术:9-Greedy Technique.ppt

    * traveling salesman problem和knapsack problem:Greedy Technique可以提供快速的近似解决方案。 Greedy Technique是一种重要的算法设计技术,能够快速提供解决方案,但需要根据具体问题选择合适的技术。

    Greedy-Snake_贪吃蛇

    贪吃蛇小游戏,闲的无聊可以下来玩玩,哈哈。由于java编写,所以需要 jre 环境噢,电脑装了java的都有此环境。纯手打,java开发,学习开发全流程见 ...

    GreedySnake.zip

    本项目"GreedySnake.zip"提供了这样一个简单的Java实现,旨在帮助初学者熟悉Java开发的基本技术和流程。以下是该项目涉及的主要知识点: 1. **Java基础知识**:在Java中编写贪吃蛇游戏,需要对基本语法、类与对象、...

    [C++]Greedy Snake

    8. **资源管理**:项目中的`index.jpg`、`a.png`、`b.png`可能是用于游戏背景、图标或者食物图像的资源文件,EasyX库提供了加载和显示位图的功能,使得开发者可以将这些图片集成到游戏中。 9. **Readme.txt**:此...

    Greedy function approximation - A gradient boosting machine (1).pdf

    从给定文件内容中,我们可以梳理出一些关键的知识点,具体如下: 1. 梯度提升决策树(Gradient Boosting Decision Tree, GBDT): 该部分内容在文档中被提及,它指的是一种集成学习算法,属于机器学习和数据挖掘领域...

Global site tag (gtag.js) - Google Analytics