收藏 分享(赏)

问题的难与易.pptx

上传人:weiwoduzun 文档编号:5662864 上传时间:2019-03-11 格式:PPTX 页数:17 大小:157.61KB
下载 相关 举报
问题的难与易.pptx_第1页
第1页 / 共17页
问题的难与易.pptx_第2页
第2页 / 共17页
问题的难与易.pptx_第3页
第3页 / 共17页
问题的难与易.pptx_第4页
第4页 / 共17页
问题的难与易.pptx_第5页
第5页 / 共17页
点击查看更多>>
资源描述

1、1,问题的难与易,容易的问题:在时间复杂度为多项式时间 (polynomial time)内可解的问题如:排序,找最大值 困难的问题:NP-complete,NP-hard如:分割问题(Partition Problem)旅行商问题(Traveling Salesperson Problem) 不可解问题:用算法(图灵机)无法解的问题如:停止问题(Halting Problem),2,我想不出好方法,我可能太笨了!,3,我想不出好方法, 因為不可能有這種好方法!,4,我想不出好方法, 因為這些名人專家也不會!,5,Our old list of problems,排序 查找 图的最短路径 图的

2、最小生成树 最近点对问题 等等,旅行商问题(Traveling salesman problem) 背包问题(Knapsack problem)(子集求和问题) 汉诺塔问题(Towers of Hanoi),复杂性都是指数级O(an),复杂性都是多项式,6,Classifying a problems complexity,Is there a polynomial-time algorithm that solves the problem? Possible answers: yes no because it can be proved that all algorithms take

3、exponential time because it can be proved that no algorithm exists at all to solve this problem dont know dont know, but if such algorithm were to be found, then it would provide a means of solving many other problems in polynomial time,7,问题分类,优化问题: 对问题构造一个目标函数,求目标函数的最大值或最小值。例子: 线性表中找最大元素或最小元素 图的最短路

4、径,最小生成树 判定问题: 对一个问题,回答是或者否( yes/no)很多问题即可以表述为判定问题,也可以表述为优化问题 Eg: Traveling salesman problem optimization: find hamiltonian cycle of minimum weight decision: find hamiltonian cycle of weight k,如果我们有一个求解判定问题的有效算法,那么很容易把它变成求解相应的优化问题的算法,8,Some more problems,划分问题: 给定 n 正整数,判定是否可以把它们划分成两个不相交的子集,且其和相等。Bin

5、packing: given n items whose sizes are positive rational numbers not larger than 1, put them into the smallest number of bins of size 1Graph coloring: For a given graph find its chromatic number, ie, the smallest number of colors that need to be assigned to the graphs vertices so that no two adjacen

6、t vertices are assigned the same colorCNF satisfiability: Given a boolean expression in conjunctive normal form (conjunction of disjunctions of literals), is there a truth assignment to the variables that makes the expression true?,9,The class P,P类问题:能够用确定性算法在多项式时间内求解的判定问题,这种问题也称为确定性多项式时间类型 O(p(n),

7、这儿 p(n) 是一个关于 n的多项式Why polynomial? 有效比较好的理论性质,因此构建出算法复杂性理论。,10,The class NP,NP类问题: 在非确定性机器上,能够在多项式时间内求解的判定问题称为NP类问题( nondeterministic polynomial time problem) (A determinstic computer is what we know)A nondeterministic computer is one that can “guess” the right answer or solution Thus NP can also be

8、 thought of as the class of problems whose solutions can be verified in polynomial time; or that can be solved in polynomial time on a machine that can pursue infinitely many paths of the computation in parallel Note that NP stands for “Nondeterministic Polynomial-time”,11,一则童话故事:证比求易问题,我国计算机科学家洪加威曾

9、经讲了一个被人称为“证比求易算法”的童话,用来帮助读者理解计算复杂性的有关概念具体内容如下 : 从前有一个酷爱数学的年轻国王向邻国一位聪明美丽的公主求婚,公主出了这样一道题:求出48 770 428 433 377 171的一个真因子,若国王能在一天之内求出答案,公主便接受他的求婚。国王回去后立即开始逐个数地进行计算,他从早到晚共算了三万多个数最终还是没有结果。国王向公主求情,公主将答案相告223 092 827是它的一个真因子。国王很快就验证了这个数确能除尽48 770 428 433 377 171,公主说我再给你一次机会如果还求不出,将来你只好做我的证婚人了,国王立即回国并向时任宰相的大

10、数学家求教。 大数学家在仔细地思考后认为这个数为17位,则最小的一个真因子不会超过9位,于是他给国王出了一个主意,按自然数的顺序给全国的老百姓每人编一个号发下去,等公主给出数目后立即将它们通报全国让每个老百姓用自己的编号去除这个数,除尽了立即上报赏金万两,最后国王用这个办法求婚成功 。,12,在“证比求易算法”中,对公主给出的数进行验证显然是在多项式时间内可以解决的问题。 因此这类问题属于NP类问题,13,例子: 合取子句满足问题(CNF),This problem is in NP. Nondeterministic algorithm: Guess truth assignment Che

11、ck assignment to see if it satisfies CNF formulaExample: (AB C ) (A B) ( B D F ) (F D)Truth assignments:A B C D E F 0 1 1 0 1 0 1 0 0 0 0 1 1 1 0 0 0 1 . (how many more?)Checking phase: (n),14,Where are we now?,Exhibited nondeterministic poly-time algorithm for CNF-satisfiability CNF-sat is in NPSim

12、ilar algorithms can be found for TPS, HC, Partition, etc proving that these problems are also in NPAll the problems in P can also be solved in this manner (but no guessing is necessary), so we have: P NP Big question: P = NP ?,15,NP-complete and NP-hard problems,A decision problem D is NP-complete i

13、ff D NP every problem in NP is polynomial-time reducible to DA decision problem D is NP-hard iff every problem in NP is polynomial-time reducible to D (简单地说:无法找到确定性的多项式时间算法的问题,就是 NPhard问题)Cooks theorem (1971): CNF-sat is NP-completeOther NP-complete problems obtained through polynomial-time reductio

14、ns of known NP-complete problems The class of NP-complete problems is denoted NPC,16,Reductions,Example: Polynomial-time reduction of directed HC(哈密吨回路) to undirected HC,y,v,u,x,y3,v3,What does this prove?HC is harder or easier for directed graphs?if HC is NPC for directed graphs, is it also NPC for

15、 undirected graphs?ORif HC is NPC for undirected graphs, is it also NPC for directed graphs?,x3,x2,x1,y1,y2,u1,u2,u3,v2,v1,17,How to tackle those difficult problems.,There are two principal approaches to tackling NP-hard problems or other “intractable” problems:Use a strategy that guarantees solving the problem exactly but doesnt guarantee to find a solution in polynomial time 穷举法,回溯法,分支界限Use an approximation algorithm that can find an approximate (sub-optimal) solution in polynomial time 启发式搜索(遗传算法,蚁群算法等) 针对具体问题研究的近似算法,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报