在现实世界中,有这样一类问题:它有n个输入,而它的解就由这n个输入的某个子集组成,不过这个子集必须满足某些事先给定的条件。把那些必须满足的条件称为约束条件;而把满足约束条件的子集称为该问题的可行解。
问题的简单描述:
In={n个输入};             显然,满足约束条件的子
Ina是In的子集;             集可能不止一个,一般来说
Ina满足约定的条件;           可行解不是唯一的。
Ina构成问题的解。

  贪心方法是一种改进了的分级处理方法,选择能产生问题最优解的最优量度标准是使用贪心法设计求解的核心问题。但是,要选出最优量度标准并不是一件容易的事,不过,一旦能选择出某个问题的最优量度标准,那么用贪心方法求解这个问题则特别有效。

  贪心方法可以用下面的抽象化控制来描述:

  void Greedy(a[],n) {
//A(1:n)包含n个输入
solution = Φ //将解向量solution初始化为空
for(j=;j=n;++j) {
x = Select(a[]);
if Feasible(solution,x) {solution=union(solution,x);}
};//for
return solution;
}// Greedy

  函数Select的功能是按某种最优量度标准从A(1:n)中选择一个输入,把它的值赋给x并从输入集合A中消去它。Feasible是一个布尔函数,它判定x是否可以包含在解向量中。union将x与解向量结合并修改目标函数。过程Greedy描述了用贪心策略设计算法的主要工作和基本控制路线。一旦给出一个特定的问题,就可将Select,Feasible和 Union具体化并付诸实现。

Greedy的更多相关文章

  1. USACO . Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  2. hdu4976 A simple greedy problem. (贪心+DP)

    http://acm.hdu.edu.cn/showproblem.php?pid=4976 2014 Multi-University Training Contest 10 1006 A simp ...

  3. ACM Greedy Mouse

    Greedy Mouse 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 A fat mouse prepared M pounds of cat food,read ...

  4. hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏

    huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...

  5. Greedy is Good

    作者:supernova 出处:http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=greedyAlg Joh ...

  6. 九度OJ 1453 Greedy Tino -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1453 题目描述: Tino wrote a long long story. BUT! in Chinese... ...

  7. 119 - Greedy Gift Givers

     Greedy Gift Givers  The Problem This problem involves determining, for a group of gift-giving frien ...

  8. ZOJ 3794 Greedy Driver

    两次SPFA 第一关找:从1没有出发点到另一个点的多少是留给油箱 把边反过来再找一遍:重每一个点到终点最少须要多少油 Greedy Driver Time Limit: 2 Seconds       ...

  9. Greedy Change

    Greedy Change time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. uva 10256 The Great Divide

    题意:给定两个点集,一个红点集,另一个蓝点集,询问,能否找到一条直线能,使得任取一个红点和蓝点都在直线异侧. 思路:划分成两个凸包,一个红包,一个蓝包.两个凸包不相交不重合. 1.任取一个凸包中的点不 ...

  2. Error starting static Resources java.lang.IllegalArgumentException: Document base D:\Program Files\apache-tomcat-xxx\webapps\xxx does not exist or is not a readable directory

    网上的答案大多数如下: 但并没有解决我的问题  经过我的观察: 在tomcat的server.xml有Lottery项目描述,但实际上,该项目已被我删除,不存在于webapps中了    该行Cont ...

  3. HDU-4704 Sum 大数幂取模

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4704 题意:求a^n%m的结果,其中n为大数. S(1)+S(2)+...+S(N)等于2^(n-1) ...

  4. Mongodb 和 普通数据库 各种属性 和语句 的对应

    SQL to MongoDB Mapping Chart In addition to the charts that follow, you might want to consider the F ...

  5. SQL2008-截取字段函数

    ltrim()  int转字符 Left('ABC',2)='AB' right('ABC',2)='BC' SUBSTRING('ABC',1,2)='AB'  和DELPHI中的COPY一样Sub ...

  6. define

    define('player',['videoplay'],function(videoplay){ var wrap_player = $('#live_SWF'), obj_player = '' ...

  7. Dijkstra in python

    下面是一段由python实现的Dijkstra算法,一些地方的处理实在非常棒,相比于C,代码的数量已经缩减到了60行,所以我想通过本文简单的介绍一下这段代码的细节之处,首先给出源程序: from sy ...

  8. Action开发、通配符、路径问题和struts中常量用法

    1.action开发 开发的几种方式 (1).继承自ActionSupport,(如果用struts的数据效验功,能必须必须使用此功能,因为ActionSupport实现了数据效验的接口) publi ...

  9. 对get_baserel_parampathinfo函数的学习

    /* * get_baserel_parampathinfo * Get the ParamPathInfo for a parameterized path for a base relation, ...

  10. ListOrderedMap

    要有序能够用List,要便于查找能够用Map,那既要有序又便于查找呢? 近期我就遇到了这样一个问题.Java没有给我们提供现成的类.我们全然能够自己开发个类继承List和Map(Java原来就有不能够 ...