ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Greedy Algorithm

2022-08-10 16:30:25  阅读:153  来源: 互联网

标签:set Algorithm problems solution greedy Greedy optimal


Greedy Algorithm

A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage.
In many problems, a greedy strategy does not produce an optimal solution, but a greedy heuristic can yield locally optimal solutions that approximate a globally optimal solution in a reasonable amount of time.

For example, a greedy strategy for the travelling salesman problem (which is of high computational complexity) is the following heuristic: "At each step of the journey, visit the nearest unvisited city." This heuristic does not intend to find the best solution, but it terminates in a reasonable number of steps; finding an optimal solution to such a complex problem typically requires unreasonably many steps. In mathematical optimization, greedy algorithms optimally solve combinatorial problems having the properties of matroids and give constant-factor approximations to optimization problems with the submodular structure.

Specifics

Greedy algorithms produce good solutions on some mathematical problems, but not on others. Most problems for which they work will have two properties:

Greedy choice property

A locally optimal solutions would never reconsiders its choices. This is the main difference from dynamic programming, which is exhaustive and is guaranteed to find the solution. On every stage, dynamic programming makes decision based on all the decisions made in the previous stage and may reconsider the previous stage's algorithmic path to the solution.

Optimal substructure

"A problem exhibits optimal substructure if an optimal solution to the problem contains optimal solutions to the sub-problems." Please see dynamic program in Math.

Greedy may produce the unique worst possible result in cases of failure.

Theory

Greedy heuristics are known to produce sub-optimal results on many problems.

Matroids

A matroid is a mathmatical structure that generalizes the notion of linear independence from vector spaces to arbitrary(任意) sets. If an optimization problem has the structure of a matroid, then the appropriate greedy algorithm will solve it optimally.

Submodular functions

A function \(f\) defined on subsets of a set \(\Omega\) is called submodular if for every \(S,T \subseteq \Omega\) we have that \(f(S)+f(T) \ge f(S\cup T)+f(S \cap T)\).

In mathematics, a submodular set function (also known as a submodular function) is a set function whose value, informally, has the property that the difference in the incremental value of the function that a single element makes when added to and input set decreases as the size of the input set increases.

Submodular functions have a natural diminishing returns property which makes them suitable for many applications, including approximation algorithms, game theory(as functions modeling user preferences) and electrical networks. Recently, submodular functions have also found immense utility in serveral real world problems in machine learning and artifical intelligence, including automatic summarization, multi-document summarization, feature selection, active learning, sensor placement, image collection summarization and many other domains.

Example

Suppose one wants to find a set \(S\) which maximizes \(f\). The greedy algorithm, which builds up a set \(S\) by incrementally adding the element which increases \(f\) the most at each step, produces as output a set that is at least \((1-1/e)\max_{X\subseteq \Omega}f(X)\). That is, greedy performs within a constant factor of \((1-1/e)\approx 0.63\) as good as the optimal solution.

Similar guarantees are provable when additional constraints, such as cardinality constraints, are imposed on the output, though often slight variations on the greedy algorithm are required.

标签:set,Algorithm,problems,solution,greedy,Greedy,optimal
来源: https://www.cnblogs.com/qianxinn/p/16572914.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有