ch08 The Greedy Approach
Ch8动态规划

Operations Research
第八章 动态规划
Dynamic Programming
8.1 动态规划数学模型Mathematical Model of DP 8.2 资源分配问题 Resource Assignment Problem 8.3 生产与存储问题Production and inventory problem 8.4 背包问题 Knapsack Problem 8.5 其它动态规划模型 Other Model of DP
南京理工大学经济管理学院 包文彬 8.1 动态规划数学模型 baowenbin@ Mathematical Model of DP
第8章 动态规划 Dynamic Programming
2012年6月12日星期二
Page 7
5 . 状态具有无后效性 当某阶段状态确定后,此阶段以后过 程的发展不受此阶段以前各阶段状态的影响。如下图所示:
第8章 动态规划 Dynamic Programming
2012年6月12日星期二
Page 12
动态规划要求过程指标满足递推关系 ,即
V k ( s k , x k , x k 1 , , x n ) V k [ v ( s k , x k ), V k 1 ( s k 1 , x k 1 , , x n )]
(8.6)
动态规划数学模型由式(8.4)或(8.6)、边界条件及状态转移方程 构成。如连和形式的数学模型
f k ( s k ) Opt {v k ( s k , x k } f k 1 ( s k 1 )}, k 1, 2 , , n xk Dk ( sk ) f n (sn ) 0 s T (sk , xk ) k 1
第八章贪心算法

个特异顶点s称为源。单源最短路径问题,或者简称为
最短路径问题,是确定从s到V中每一个其他顶点的距离,
这里从顶点s到顶点x的距离定义为从s到x的最短路径的
长度。
● 假设V={1,2,…,n}并且s=1。这个问题可以用一种称 为Dijkstra算法的贪心技术来解决。初始时,将顶点
分为两个集合X={1}和Y={2,3,…,n}。X包含的顶点集 合:从源点到这些顶点的距离已经确定。
i1
i1
得证,分数背包问题最的优解值大于等于任可一行解的值,因此
贪心算法得到的是最解优。
钱币问题
一个买糖的孩子用1元钱买了不到1元钱的糖,售货
员找硬币时希望用最少个数的硬币。 售货员每增加一个硬币,使用的贪心规则是:
每次希望增加尽可能多的币值,又不能超出总数。例如 要找66c(分)。
● 假设硬币面值分别为:25c, 10c, 5c, 1c。
一次循环后仍满足要求.
即要证明如下结论成立:
对于拟阵 MS,L,A是L的一个元素,且A是该
拟阵的某个权值最大独立集T的子集,x满足
Ax, 且L 没有其他满足
的A y使y得L ,
即xw 是y 能 使w Ax 扩展的元素中的权值最大的。
令
,A 那么A 存 在一x个包含
A的 最优解。
X
能使A扩展
ch8 GA parallel

6
The genetic operators
Crossover and mutation can be parallelized using the same idea of partitioning the population and distribution the work among multiple processors. However, these operators are so simple that it is very likely that the time required to send individuals back and forth will offset any performance gains. The communication overhead is also a problem when selection is parallelized because most forms of selection need information about the entire population and thus require some communications.
14
Fine-grained parallel GA
1) Partition the initial population with N individuals to N processors; 2) for i=1 to N par-do 2.1) Each processor select one individual from itself and its neighbour 2.2) Crossover with one individual from its neighbour and remain one offspring 2.3) Mutation 2.4) Calculate the fitness 3) Go to 2)
Chapter_16_Greedy_Algorithm

Recursive Algorithm
Recursive-Activity-Selector (s, f, i, j) 1. m i+1 2. while m < j and sm < fi 3. do m m+1 4. if m < j 5. then return {am} Recursive-Activity-Selector(s, f, m, j) 6. else return
– Example: Sorting activities by finish time.
• Another, alternative goal that we don’t solve here: maximize time spent on rides
• Welcome to the activity selection problem
Activity-selection Problem • Input: Set S of n activities, a1, a2, …, an. • Output: Subset A of maximum number of compatible activities.
– This generates two subproblems. – Selecting from a1, …, ak-1, activities compatible with one another, and that finish before ak starts (compatible with ak). – Selecting from ak+1, …, an, activities compatible with one another, and that start after ak finishes. – The solutions to the two subproblems must be optimal.
贪婪重构算法StOMP及其改进

Keywords Compressed sensing Reconstruction algorithm Matching pursuit Particle swar m optimisation(PSO)
演算法课程AlgorithmsCourse8回溯分枝与限制Backtracking

3
▓ 求解Optimization Problems
若以暴力演算法來求算最佳化問題,對於有n個輸入項目
的最佳化問題 (X1, X2, …, Xn):
有些被歸類為 “部份集合(Subset)” 問題,則會有2n種可能的情況
如:部份集合之和 (Sum of Subset)問題、0/1背包問題…等
上述的兩個策略,皆透過 “邊界函數” (Bounding Function) 來刪 除一些不必要的子樹搜尋動作,以提昇搜尋效率。
6
解答空間 (Solution Space)
每個問題通常都可為其定義一個解答空間 (Solution Space): S = { (X1, X2, …, Xn) ; (X1, X2, …, Xn)為滿足問題的所有解}
此即為修剪 (Pruning)
當搜尋到 “可行” 的節點 (即:課本所指的有前途(promising)節點) 時,則可以再續繼往下搜尋該節點以下之分枝節點。 可以得到修剪過的狀態空間樹 (Pruned State Space Tree)。
9
一個修剪過的狀態空間樹:
起始狀態
不可行解 可行解
然而,並不是所有求最佳化的問題都合乎最佳化原則, 此時就只能用其它的方法求解了。
5
▓ Backtracking vs. Branch and Bound
對於具有限制的最佳化問題,除了可以採用
“貪婪法則” 或 “動態規劃” 來設計演算法則之外,若問題不具有 “最佳化原則”時,可考慮採用回溯(Backtracking)或分 枝與限制(Branch and Bound)之解題策略。
2008tem8
TEST FOR ENGLISH MAJORS(2008)—GRADE EIGHT—TIME LIMIT: 195MINPART II READING COMPREHENSION (30 MIN)In this section there are four reading passages followed by a total of 20 multiple-choice questions. Read the passages and then mark your answers on your coloured answer sheet。
TEXT AAt the age of 16, Lee Hyuk Joons life is a living hell. The South Korean 10th grader gets up at 6 in the morning to go to school, and studies most of the day until returning home at 6 p.m. After dinner, its time to hit the books again—at one of Seouls many so-called cram schools. Lee gets back home at 1 in the morning, sleeps less than five hours, then repeats the routine—five days a week. Its a grueling schedule, but Lee worries that it may not be good enough to get him into a top university. Some of his classmates study even harder.South Koreas education system has long been highly competitive. But for Lee and the other 700,000 high-school sophomores in the country, high-school studies have gotten even more intense. Thats because South Korea has conceived a new college-entrance system, which will be implemented in 2008. This years 10th graders will be the first group evaluated by the new admissions standard, which places more emphasis on grades in the three years of high school and less on nationwide SAT-style and other selection tests, which have traditionally determined which students go to the elite colleges.The change was made mostly to reduce what the government says is a growing education gap in the country: wealthy students go to the best colleges and get the best jobs, keeping the children of poorer families on the social margins. The aim is to reduce the importance of costly tutors and cram schools, partly to help students enjoy a more normal high-school life. But the new system has had the opposite effect. Before, students didnt worry too much about their grade-point averages; the big challenge was beating he standardized tests as high-school seniors. Now students are competing against one another over a three-year period, and every midterm and final test is crucial. Fretful parents are relying even more heavily on tutors and cram schools to help their children succeed.Parents and kids have sent thousands of angry online letters to the Education Ministry complaining that the new admissions standard is setting students against each other. "One can succeed only when others fail,” as one parent said.Education experts say that South Koreas public secondary-school system is foundering, while private education is thriving. According to critics, the countrys high schools are almost uniformly mediocre—the result of an egalitarian government education policy. With the number of elite schools strictly controlled by the government, even the brightest students typically have to settle for ordinary schools in their neighbourhoods, where the curriculum is centred on average students. To make up for the mediocrity, zealous parents send their kids to the expensive cram schools. Students in affluent southern Seoul neighbourhoods complain that the new system will hurt them the most.Nearly all Korean high schools will be weighted equally in the college-entrance process, and relatively weak students in provincial schools, who may not score well on standardized tests, often compile good grade-point averages.Some universities, particularly prestigious ones, openly complain that they cannot select the best students under the new system because it eliminates differences among high schools. Theyveasked for more discretion in picking students by giving more weight to such screening tools as essay writing or interviews.President Roh Moo Hyun doesnt like how some colleges are trying to circumvent the new system. He recently criticized "greedy" universities that focus more on finding the best students than faying to "nurture good students". But amid the crossfire between the government and universities, the countrys 10th graders are feeling the stress. On online protest sites, some are calling t hemselves a “cursed generation” and “mice in a lab experiment”. It all seems a touch melodramatic, but thats the South Korean school system.11. According to the passage, the new college-entrance system is designed toA. require students to sit for more college-entrance tests.B. reduce the weight of college-entrance tests.C. select students on their high school grades only.D. reduce the number of prospective college applicants.12. What seems to be the effect of introducing the new system?A. The system has given equal opportunities to students.B. The system has reduced the number of cram schools.C. The system has intensified competition among schools.D. The system has increased students study load.13. According to critics, the popularity of private education is mainly the result ofA. the governments egalitarian policy.B. insufficient number of schools:C. curriculums of average quality.D. low cost of private education.14. According to the passage, there seems to be disagreement over the adoption of the new system between the following groups EXCEPTA. between universities and the government.B. between school experts and the government.C. between parents and schools.D. between parents and the government.15. Which of the following adjectives best describes the authors treatment of the topic?A. Objective.B. Positive.C. Negative.D. Biased.TEXT BWilfred Emmanuel-Jones was a teenager before he saw his first cow in his first field. Born in Jamaica, the 47-year-old grew up in inner-city Birmingham before making a career as a television producer and launching his own marketing agency. But deep down he always nurtured every true Englishmans dream of a rustic life, a dream that his entrepreneurial wealth has allowed him to satisfy. These days hes the owner of a thriving 12-hectare farm in deepest Devon with cattle, sheep and pigs. His latest business venture: pushing his brand of Black Fanner gourmet sausages and barbecue sauces. “My background may be very urban,” says Emmanuel-Jones.“But it has given me a good idea of what other urbanites want.”And of how to sell it. Emmanuel-Jones joins a herd of wealthy fugitives from city life who are bringing a new commercial know-how to British farming. Britains burgeoning farmers markets -numbers have doubled to at least 500 in the last five years—swarm with specialty cheesemakers, beekeepers or organic smallholders who are redeploying the business skills they learned in the city. "Everyone in the rural community has tocome to terms with the fact that things have changed." Says Emmanuel-Jones. "You can produce the best food in the world, but if you dont know how to market it, you are wasting your time. We are helping the traditionalists to move on."The emergence of the new class of superpeasants reflects some old yearnings. If the British were the first nation to industrialize, they were also the first to head back to the land. "There is this romantic image of the countryside that is particularly English," says Alun Howkins of the University of Sussex, who reckons the population of rural England has been rising since 1911. Migration into rural areas is now running at about 100,000a year, and the hunger for a taste of the rural life has kept land prices buoyant even as agricultural incomes tumble. About 40 percent of all farmland is now sold to "lifestyle buyers" rather than the dwindling number of traditional farmers, according to the Royal Institution of Chartered Surveyors.Whats new about the latest returnees is their affluence and zeal for the business of producing quality foods, if only at a micro-level. A healthy economy and surging London house prices have helped to ease the escape of the would-be rustics. The media recognize and feed the fantasy. One of the big TV hits of recent years, the "RiverCottage" series, chronicled the attempts of a London chef to run his own Dorset farm. Naturally, the newcomers cant hope to match their City salaries, but many are happy to trade any loss of income for the extra job satisfaction. Who cares if theres no six-figure annual bonus when the land offers other incalculable compensations?Besides, the specialist producers can at least depend on a burgeoning market for their products. Todays eco-aware generation loves to seek out authentic ingredients. "People like me may be making a difference in a small way," Jan McCourt, a onetime investment banker now running his own 40-hectare spread in the English Midlands stocked with rare breeds.Optimists see signs of far-reaching change: Britain isnt catching up with mainland Europe; its leading the way. “Unlike most other countries, where artisanal food production is being eroded, here it is being recovered," says food writer Matthew Fort. “It may be the mark of the next stage of civilization that we rediscover the desirability of being a peasant.” And not an investment banker.16. Which of the following details of Wilfred Emmanuel-Jones is INCORRECT?A. He was born and brought up in Birmingham.B. He used to work in the television industry.C. He is wealthy, adventurous and aspiring.D. He is now selling his own quality foods.17. Most importantly, people like Wilfred have brought to traditional British farmingA. knowledge of farming.B. knowledge of brand names.C. knowledge of lifestyle.D. knowledge of marketing,18. Which of the following does NOT contribute to the emergence of a new class of farmers?A. Strong desire for country life.B. Longing for greater wealth,C. Influence of TV productions.D. Enthusiasm for quality food business.19. What is seen as their additional source of new income?A. Modern tendency to buy natural foods.B. Increase in the value of land property.C. Raising and selling rare live stock. VD. Publicity as a result of media coverage.20. The sentence in the last paragraph “...Britain isnt catching up with mainland Europe; its leading the way" implies thatA. Britain has taken a different path to boost economy.B. more authentic foods are being produced in Britain.C. the British are heading back to the countryside.D. the Europeans are showing great interest in country life.TEXT CIn Barcelona the Catalonians call them castells, but these arent stereotypical castles in Spain. These castles are made up of human beings, not stone. The people who perform this agile feat of acrobatics are called castellers, and to see their towers take shape is to observe a marvel of human cooperation.First the castellers form what looks like a gigantic rugby scrummage. They are the foundation blocks of the castle. Behind them, other people press together, forming outward-radiating ramparts of inward-pushing muscle: flying buttresses for the castle. Then sturdy but lighter castellers scramble over the backs of those at the bottom and stand, barefoot, on their shoulders—then still others, each time adding a higher "story".These human towers can rise higher than small apartment buildings: nine “stories”, 35 feet into the air. Then, just When it seems this tower of humanity cant defy gravity any longer, a little kid emerges from the crowd and climbs straight up to the top.Arms extended, the child grins while waving to the cheering crowd far below.Dressed in their traditional costumes, the castellers seem to epitomize an easier time, before Barcelona became a world metropolis arid the Mediterraneans most dynamic city. But when you observe-them tip close, in their street clothes, at practice, you see theres nothing easy about what the castellers do - and that they are not merely reenacting an ancient ritual.None of the castellers can-give a logical answer as to why they love doing this. But Victor Luna, 16, touches me on the shoulder and says in English: "We do it because its beautiful. We do it because we are Catalan."Barcelona’s mother tongue is Catalan, and to understand Barcelona, you must underst and two words of Catalan: seny and rauxa. Seny pretty much translates as common sense, or the ability to make money, arrange things, and get things done. Rauxa is reminiscent of our words “raucous” and “ruckus”.What makes the castellers revealing of the city is that they embody rauxa and seny. The idea of a human castle is rauxa—it defies common sense—but to watch one going up is to see seny in action. Success is based on everyone working together to achieve a shared goal.The success of Carlos Tusquets bank, Fibanc, shows seny at work in everyday life. The bank started as a family concern and now employs hundreds. Tusquets said it exemplifies how the economy in Barcelona is different.Entrepreneurial seny demonstrates why Barcelona and Catalonia—the ancient region of which Barcelona is the capital—are distinct from the rest of Spain yet essential to Spains emergence, after centuries of repression, as a prosperous, democratic Europeancountry. Catalonia, with Barcelona as its dynamo, has turned into an economic powerhouse. Making up 6 percent of Spain’s territory, with a sixth of its people, it accounts for nearly a quarter of Spains production—everything from textiles to computers—even though the rest of Spain has been enjoying its own economic miracle.Hand in hand with seny goes rauxa, and theres no better place to see rauxa in action than on the Ramblas, the venerable, tree-shaded boulevard that, in gentle stages, leads you from the centre of Barcelona down to the port. There are two narrow lanes each way for cars and motorbikes, but it’s the wide centre walkway that makes the Ramblas a front-row seat for Barcelonas longest running theatrical event. Plastic armchairs are set out on the sidewalk. Sit in one of them, and an attendant will come and charge you a small fee. Performance artists throng the Ramblas—stilt walkers, witches caked in charcoal dust, Elvis impersonators. But the real stars are the old women and happily playing children, millionaires on motorbikes, and pimps andwomen who, upon closer inspection, prove not to be.Aficionados (Fans) of Barcelona love to compare notes: “Last night there was a man standing on the balcony of his hotel room,” Mariana Bertagnolli, an Italian photographer, told me. "The balcony was on the second floor. He was naked, and he was talkinginto a cell phone."There you have it, Barcelonas essence. The man is naked (rauxa), but he is talking into a cell phone (seny).21. From the description in the passage, we learn thatA. all Catalonians can perform castells.B. castells require performers to stand on each other.C. people perform castells in different formations.D. in castells people have to push and pull each other.22. According to the passage, the4mplication of the performance is thatA. the Catalonians are insensible and noisy people.B. the Catalonians show more sense than is expected.C. the Catalonians display paradoxical characteristics.D. the Catalonians think highly of team work.23. The passage cites the following examples EXCEPT __________ to show seny at work.A. development of a bankB. dynamic role in economyC. contribution to national economyD. comparison with other regions24. In the last but two paragraph, t he Ramblas is described as “a front-row seat for Barcelona’s longest running theatrical event”. What does it mean?A. On the Ramblas people can see a greater variety of performances.B. The Ramblas provides many front seats for the performances.C. The Ramblas is preferred as an important venue for the events.D. Theatrical performers like to perform on the Ramblas.25. What is the main impression of the scenes on the Ramblas?A. It is bizarre and Outlandish.B. It is of average quality.C. It is conventional and quiet.D. It is of professional standard.TEXT DThe law firm Patrick worked for before he died filed for bankruptcy protection a year after his funeral. After his death, the firms letterhead properly included him: Patrick S. Lanigan, 1954-1992.He was listed up in the right-hand corner, just above the paralegals. Then the rumors got started and wouldnt stop. Before long, everyone believed he had taken the money and disappeared. After three months, no one on the Gulf Coast believed that he was dead. His name came off the letterheadas the debts piled up.The remaining partners in the law firm were still together, attached unwillingly at the hip by the bondage of mortgages and the bank notes, back when they were rolling and on the verge of serious wealth. They had been joint defendants in several unwinnable lawsuits; thus the bankruptcy. Since Patricks departure, they had tried every possible way to divorce one another, but nothing would work. Two were raging alcoholics who drank at the office behind locked doors, but nevertogether. The other two were in recovery, still teetering on the brink of sobriety.He took their money. Their millions. Money they had already spent long before it arrived, as only lawyers can do. Money for their richly renovated office building in downtown Biloxi. Money for new homes, yachts, condos in the Caribbean. The money was on the way, approved, the papers signed, orders entered; they could see it, almost touch it when their dead partner—Patrick—snatched it at the last possible second.He was dead. They buried him on February 11, 1992. They had consoled the widow and put his rotten name on their handsome letterhead. Yet six weeks later, he somehow stole their money.They had brawled over who was to blame. Charles Bogan, the firms senior partner and its iron hand, had insisted the money be wired from its source into a new account offshore, and this made sense after some discussion. It was ninety million bucks,a third of which the firm would keep, and it would be impossible to hide that kind of money in Biloxi, population fifty thousand. Someone at the bank would talk. Soon everyone would know. All four vowed secrecy, even as they made plans to display as much of their new wealth as possible. There had even been talk of a firm jet, a six-seater.So Bogan took his share of the blame. At forty-nine, he was the oldest of the four, and, at the moment, the most stable. He was also responsible for hiring Patrick nine years earlier, and for this he had received no small amount of grief.Doug Vitrano, the litigator, had made the fateful decision to recommend Patrick as the fifth partner. The other three had agreed, and when Patrick Lanigan was added to the firm name, he had access to virtually every file in the office. Bogan, Rapley, Vitrano, Havarac, and Lanigan, Attorneys and Counselors-at-Law. A large ad in the yellow pages claimed "Specialists in Offshore Injuries." Specialists or not, like most firms theywould take almost anything if the fees were lucrative. Lots of secretaries and paralegals. Big overhead, and the strongest political connections on the Coast.They were all in their mid- to late forties. Havarac had been raised by his father on a shrimp boat. His hands were still proudly calloused, and he dreamed of choking Patrick until his neck snapped. Rapley was severely depressed and seldom left his home, where he wrote briefs in a dark office in the attic.26. What happened to the four remaining lawyers after Patricks disappearance?A. They all wanted to divorce their wives.B. They were all heavily involved in debts.C. They were all recovering from drinking.D. They had bought new homes, yachts, etc.27. Which of the following statements contains a metaphor?A. His name came off the letterhead as the debts piled up.B. …they could see it, almost touch it when their dead partner...C. …, attached unwillingly at the hip by the bondage of mor tgages...D. …, and for this he had received no small amount of grief.28. According to the passage, what is the main cause of Patrick stealing the money?A. Patrick was made a partner of the firm.B. The partners agreed to have the money transferred.C. Patrick had access to all the files in the firm.D. Bogan decided to hire Patrick nine years earlier.29. The lawyers were described as being all the following EXCEPTA. greedy.B. extravagantC. quarrelsome.D. bad-tempered.30. Which of the following implies a contrast?A. …, and it would be impossible to hide that kind of money in Biloxi, population fifty thousand.B. They had been joint defendants in several unwinnable lawsuits; thus the bankruptcy.C. There had even been talk of a firm jet, a six-seater.D. His name came off the letterhead as the debts piled up.PART III GENERAL KNOWLEDGE (10 MIN)There are ten multiple-choice questions in this section. Choose the best answer to each question. Mark your answers on your coloured answer sheet31. The largest city in Canada isA. Vancouver.B. Montreal.C. TorontoD. Ottawa.32. According to the United States Constitution, the legislative power is invested inA. the Federal Government.B. the Supreme Court.C. the Cabinet.D. the Congress.33. Which of the following is the oldest sport in the United States?A. Baseball.B. Tennis.C. Basketball.D. American football.34. The head of the executive branch in New Zealand isA. the President.B. the Governor-General.C. the British monarch,D. the Prime Minister.35. The Canterbury Tales, a collection of stories told by a group of pilgrims on their way to Canterbury, is an important poetic work byA. William Langland.B. Geoffrey Chaucer.C. William Shakespeare.D. Alfred Tennyson.36. Who wrote The American?A. Herman Melville.B. Nathaniel Hawthorne.C. Henry James.D. Theodore Dreiser.37. All of the following are well-known female writers in 20th -century Britain EXCEPTA. George Eliot.B. Iris Jean Murdoch.C. Doris Lessing.D. Muriel Spark.38. Which of the following is NOT a design feature of human language?A. Arbitrariness.B. Displacement.C. Duality.D. Diachronicity.39. What type of sentence is “Mark likes fiction, but Tim is interested in poetry.”?A. A simple sentence.B. A coordinate sentence.C. A complex sentence.D. None of the above.40. The phenomenon that words having different meanings have the same form is calledA. hyponymy.B. synonymy.C. polysemy.D. homonymy.PART IV PROOFREADING & ERROR CORRECTION (15 MIN)Proofread the given passage on ANSWER SHEET TWO as instructed.PART V TRANSLATION (60 MIN)SECTION A CHINESE TO ENGLISHTranslate the underlined part of the following text into English. Write your translation on ANSWER SHEET THREE.都市寸土千金,地价炒得越来越高,今后将更高。
第六部分 分支限界法
单源最短路经
• 有向图G中,每一边都有一个非负边权。求 图G的从源顶点s到目标顶点t之间的最短路 径。
2
9
12
14>8 9>8
5>3
12>4
10>7
0
3
4
7
8>7
8
4
5
6>5
6
• 剪枝:结点间的控制关系。从s出发,经过两条不同路径 到达同一顶点,这两条路径相应于解空间树的2个不同的 结点A和B,如果结点A所相应的路长小于结点B所相应的路 长,则可以将结点B为根的子树剪去,称结点A控制了结点 B。 • 优先队列中结点的优先级:结点所对应的当前路长。
• 在使用分支限界法解具体问题时,可以采 用下面两种典型方式实现活结点表
– 队列式分支限界(先进先出) – 优先队列式分支限界
1 1
2
3
4
2
3
4
队列式: 活结点表L=(2,3,4)
优先队列式: 活结点表L=(2,3,4按限界函数值确定 优先级),即哪个分支能够花最小 代价 E.length c[E.i][j] dist[j]是否更新?
j
i
j
最大团问题
• 给定一个无向图G=(V,E)。如果U包含于V,且对任 意u,v属于U有(u,v)属于E,则称U是G的一个完全子 图。G的完全子图U是G的一个团当且仅当U不包含 在G的更大的完全子图中。G的最大团是指G中所 含顶点数最多的团。
• (当前扩展结点)顶点数上界=已确定的顶点数+未确定的顶点 数的上界
Ch8_EnsembleLearning
有超过半数的基分类器正确,则集成分类就正确: 对 δ > 0,k = (p − δ )n,Hoeffding
.
.
P (H (n) ≤ (p − δ )n) ≤ e−2δ
2
n
.
假设基分类器的错误率相互独立,则由 Hoeffding 为: P (H (x) ̸= f (x)) = P (H (x) ≤ ⌊
⌋,可得 ,令 (p − δ )T = ⌊ T 2
.
机器学习导论
.
– Introduction to Machine Learning
.
8
学习
(Chapter 8: Ensemble Learning)
华中科技大学电信学院
王邦
博士, 教授博导
wangbang@
学
学
1 / 39
08
. 1 . 2 . 3 . 4 . 5 . 6 Boosting Bagging 机
( ) ⌊T /2⌋ ( ) ∑ T T 1 ⌋) = (1 − ϵ)k ϵT −k ≤ exp − T (1 − 2ϵ)2 2 2 k k=0
上式显示出,随着集成中个体分类器数目 T 的增大,集成的错误率将指数级下降,最终趋向于零。
学
学
6 / 39
(4)
学习器 解决同一个问题训练出来的,不可能相互独立! 。在现实任务中,个体学习器是为
(a)
(b)
.
(c)
表 (a) 中,每个分类器都只有 66.6% 的精度,但集成学习却达到了 100%; 表 (b) 中,三个分类器没有差别,集成之后性能没有提高; 表 (c) 中,每个分类器的精度都只有 33.3%,集成学习的结果变得更糟。
学
07-greedy
Algorithms
Lecture 7: Greedy Algorithms [Fa’13]
This example gives us our first greedy algorithm. To minimize the total expected cost of accessing the files, we put the file that is cheapest to access first, and then recursively write everything else; no backtracking, no dynamic programming, just make the best local choice and blindly plow ahead. If we use an efficient sorting algorithm, the running time is clearly O(n log n), plus the time required to actually write the files. To prove the greedy algorithm is actually correct, we simply prove that the output of any other algorithm can be improved by some sort of swap.
n cost(k) n k L[i]
E[cost] =
=
.k=1 nFra bibliotekk=1 i=1 n
If we change the order of the files on the tape, we change the cost of accessing the files; some files become more expensive to read, but others become cheaper. Different file orders are likely to result in different expected costs. Specifically, let π(i) denote the index of the file stored at position i on the tape. Then the expected cost of the permutation π is
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Optimal substructure
A problem exhibits optimal substructure if an optimal solution to the problem contains within it optimal solutions to subproblems. In the 0-1 knapsack problem, when we consider an item for inclusion in the knapsack, we must compare the solution to the subproblem in which the item is included with the solution to the subproblem in which the item is excluded before we can make the choice. The problem formulated in this way gives rise to many overlapping subproblems--a hallmark of dynamic programming.
Chapter 8
The Greedy Approach
Introduction
Greedy algorithms are usually designed to solve optimization problems. They typically consist of an iterative procedure that tries to find a local optimal solution. A greedy algorithm makes a correct guess on the basis of little calculation without worrying about the future. It builds a solution step by step. Each step increases the size of the partial solution and is based on local optimization. The choice made is that which produces the largest immediate gain while maintaining feasibility. The algorithms are typically efficient. The hard part is proving that the algorithm does indeed solve the problem.
4
Algorithm 8.1 DIJKSTRA Input: A weighted directed graph G=(V,E), where V={1,...,n} Output: The distance from vertex 1 to every other vertex in G 1. X={1}; YV-{1}; [1]0 2. for y2 to n 3. if y is adjacent to 1 then [y]length[1,y] 4. else [y] 5. end if 6. end for 7. for j1 to n-1 8. Let yY be such that [y] is minimum 9. XX{y} {add vertex y to X} 10. YY-{y} {delete vertex y from Y} 11. for each edge (y,w) 12. if wY and [y]+length[y,w]<[w] then 13. [w][y]+length[y,w] 14. end for 15. end for
5
Representation: adjacency lists Lemma 8.1 (correctness): In Algorithm DIJKSTRA, when a vertex y is chosen in Step 8, if its label [y] is finite then [y]=[y] Theorem 8.1 (time complexity): Given a directed graph G with nonnegative weights on its edges and a source vertex s, Algorithm DIJKSTRA finds the length of the distance from s to every other vertex in (n^2) time.
2
Fractional knapsack
Given n items of sizes s1,...,sn, and values v1,...,vn and size C, the knapsack capacity, the objective is to find nonnegative real numbers x1,...,xn that
i 1
The shortest path problem
Let G=(V,E) be a directed graph in which each edge has a nonnegative length, and a distinguished vertex s called the source. Then determine the distance from s to every other vertex in V, where the distance from vertex s to vertex x is defined as the length of a shortest path from s to x.
7
Greedy-choice property
A globally optimal solution can be arrived at by making a locally optimal (greedy) choice. When we are considering which choice to make, we make the choice that looks best in the current problem and then solve the subproblem arising after the choice is made. The choice may depends on choices so far, but it cannot depend on any future choices or on the solutions to subproblems. It usually progresses in a top-down fashion, making one greedy choice after another, reducing each given problem instance to a smaller one. In dynamic programming, we make a choice at each step, but the choice usually depends on the solutions to subproblems. Consequently we solve dynamicprogramming problems in a bottom-up manner, progressing from smaller subproblems to large subproblems. But we must prove that a greedy choice at each step yields a globally optimal solution. 8
9
File compression
Suppose we are given a file, which is a string of characters. Compress the file as much as possible in such a way that the original file can be reconstructed. Let the set of characters in the file be C={c1,c2,...,cn}. Let also f(ci), 1in, be the frequency of character ci in the file. Since the frequency of some characters may be much larger than others, it is reasonable to use variable length encodings. When the encodings vary in length, we stipulate that the encoding of one character must not be the prefix of the encoding of another character; such codes are called prefix codes.
max xi v i
i 1 n n
s.t. x i si C
Greedy strategy: For each item compute yi=vi/si. Sort the items by decreasing ratio,and fill the knapsack with as much as possible from the first item, then the second, and so forth. Characteristics: The algorithm consists of a simple iterative procedure that selects that item which produces the largest 3 immediate gain while maintaining feasibility.