<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; 近似算法</title>
	<atom:link href="http://zhiqiang.org/blog/tag/%e8%bf%91%e4%bc%bc%e7%ae%97%e6%b3%95/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>数学、金融、计算机</description>
	<lastBuildDate>Wed, 23 May 2012 08:37:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>理论计算机初步：概率算法和近似算法</title>
		<link>http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html</link>
		<comments>http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html#comments</comments>
		<pubDate>Thu, 14 Sep 2006 01:32:32 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[计算机科学]]></category>
		<category><![CDATA[概率算法]]></category>
		<category><![CDATA[理论计算机初步]]></category>
		<category><![CDATA[近似算法]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/442.html</guid>
		<description><![CDATA[博客 » 计算机科学 » 概率算法，理论计算机初步，近似算法 » 系列：理论计算机初步 查看该系列所有文章 前面已经提到了显示中大多数难解问题问题最后都被证明是NP-完全问题。这意味着，除非NP=P，它们是不可能有多项式时间算法的（而且，在这篇文章提到即使NP=P，人们也可能找不到一个NP完全问题的“有效”算法）。 所以人们发展了各种工具来避开它们，最常用的两种...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/science/computer-science">计算机科学</a> » <a href="http://zhiqiang.org/blog/tag/%e6%a6%82%e7%8e%87%e7%ae%97%e6%b3%95" rel="tag">概率算法</a>，<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%9d%e6%ad%a5" rel="tag">理论计算机初步</a>，<a href="http://zhiqiang.org/blog/tag/%e8%bf%91%e4%bc%bc%e7%ae%97%e6%b3%95" rel="tag">近似算法</a> » </p><div class="series"><span>系列：<b>理论计算机初步</b></span><br/>
<a href="http://zhiqiang.org/blog/tag/%e7%90%86%e8%ae%ba%e8%ae%a1%e7%ae%97%e6%9c%ba%e5%88%9d%e6%ad%a5">查看该系列所有文章</a>
<div id='series'></div>
</div>  <p><a rel="理论计算机初步：P vs NP - 问题概述" href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-p-vs-np-an-overview-of-the-problem.html">前面</a>已经提到了显示中大多数难解问题问题最后都被证明是NP-完全问题。这意味着，除非NP=P，它们是不可能有多项式时间算法的（而且，在<a rel="理论计算机初步：P vs NP - 历史，现状和未来" href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-p-vs-np-past-present-and-future.html">这篇文章</a>提到即使NP=P，人们也可能找不到一个NP完全问题的“有效”算法）。</p>
<p>所以人们发展了各种工具来避开它们，最常用的两种方法是使用概率算法和近似算法，这两种方法也符合实际需要：在解决实际问题中，我们<font color="#ff0000">不需要结果绝对正确</font>，也<font color="#ff0000">不需要结果绝对精确</font>。</p>
<p>所谓<strong>概率算法</strong>，就是在算法的过程中引入随机数，使得算法在执行的过程中随机选择下一个计算步骤。它最后可能导致结果也是不确定的。一个结果不确定的概率算法叫做Monte Carlo算法，而总是得到准确解的概率算法叫做Sherwood算法（一个例子是引进随机因子的快速排序算法）。</p>
<p>为何引入随机数能够提升计算性能（事实上，理论计算机学家还没能证实随机因子本质上更有效率——指具有指数级别的效率提升），主要有下面两个原因：</p>
<p>首先，通常一个算法，它对于很多种情况是比较快的，但对于某些“特别差”的输入，它要找到一个解则特别困难。引入随机数之后，使得算法的时间复杂度平均化了，然后算得更快（评价一个随机算法的复杂性通常是考虑其平均复杂性）。</p>
<p>其次，对于Monte Carlo算法，它的输出是不精确的，这种牺牲使得算法能够在较短时间内完成。</p>
<p>需要指出的是，下面这个定理，使得一个不那么精确的Monte Carlo算法亦有实际的效用的：</p>
<blockquote><p>如果一个判定问题的某个Monte Carlo算法有2/3的正确几率(这个2/3可以替换成任何一个大于1/2的数，当然小于等于1/2的随机算法一点意义都没有，因为还不如抛硬币)，重复这个算法k次，取出现次数更多的结果作为问题的答案，则这个答案的正确率大于1-1/2(8/9)^k。</p></blockquote>
<p>上面的结果由于k出现在指数上，所以只需要将一个Monte Carle算法重复很少的次数，便能得到很高的准确率。</p>
<p>近似算法从字面的意思来看似乎和上面的Monte Carle算法差不多，其实它们的考虑对象是不一样的，而且通常所指的近似算法是确定型算法。近似算法多用在组合优化的问题，而不是判定性问题上。组合优化问题，指的是那些需要求最优解的问题，比如下面这个</p>
<blockquote><p><strong>旅行商问题</strong></p>
<p>有n个城市，一个推销员要从其中某一个城市出发，不重复地走遍所有的城市，再回到他出发的城市。问这个推销员的最短路程。</p></blockquote>
<p>对于这种问题，如果最短路径是1000，而且我们能很快找到一个1000.1的路径，在实际运用中，我们还需要浪费巨大的计算资源去找那个1000的路径吗？近似算法便基于此思想而来。</p>
<p><strong>近似算法</strong>指在解决优化问题中，最后得到的结果能保证在一定的误差之内的算法。</p>
<p>从近似算法的角度来说，同为NP完全问题，它们也有不同的可近似度。在多项式时间内，有些问题可以无穷小误差的逼近，但有些问题却连常数倍数之内的结果都没法得到。</p>
<div><h4>相关文章</h4><ul><li class='currentpost'><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html">理论计算机初步：概率算法和近似算法</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-preface.html">理论计算机初步：前言</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-p-vs-np-an-overview-of-the-problem.html">理论计算机初步：P vs NP - 问题概述</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-p-vs-np-past-present-and-future.html">理论计算机初步：P vs NP - 历史，现状和未来</a></li><li ><a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-xiao-yun-wang-from-the-hash-function-to-crack-md5.html">理论计算机初步：从hash函数到王小云的MD5破解</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2006. | <a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html#comments">7 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/science/computer-science/preliminary-computer-theory-approximation-algorithms-and-probability-algorithm.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

