Dynamic ProgrammingManhattan Tourist ProblemLecture 17.ppt

Dynamic ProgrammingManhattan Tourist ProblemLecture 17.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Dynamic ProgrammingManhattan Tourist ProblemLecture 17.ppt

Dynamic Programming: Manhattan Tourist Problem Lecture 17 Manhattan Tourist Problem (MTP) Manhattan Tourist Problem (MTP) Manhattan Tourist Problem (MTP) Manhattan Tourist Problem: Formulation MTP: An Example MTP: Greedy Algorithm Is Not Optimal MTP: Simple Recursive Program MTP: Simple Recursive Program MTP: Recurrence Manhattan Is Not A Perfect Grid Manhattan Is Not A Perfect Grid (cont’d) Traveling in the Grid DAG: Directed Acyclic Graph Topological Ordering Topological ordering Longest Path in DAG Problem Longest Path in DAG: Dynamic Programming Traversing the Manhattan Grid * Imagine seeking a path (from source to sink) to travel (only eastward and southward) with the most number of attractions (*) in the Manhattan grid Sink * * * * * * * * * * * Source * Imagine seeking a path (from source to sink) to travel (only eastward and southward) with the most number of attractions (*) in the Manhattan grid Sink * * * * * * * * * * * Source * Goal: Find the longest path in a weighted grid. Input: A weighted grid G with two distinct vertices, one labeled “source” and the other labeled “sink” Output: A longest path in G from “source” to “sink” 3 2 4 0 7 3 3 3 0 1 3 2 4 4 5 6 4 6 5 5 8 2 2 5 0 1 2 3 0 1 2 3 j coordinate i coordinate 13 source sink 4 3 2 4 0 1 0 2 4 3 3 1 1 2 2 2 4 19 9 5 15 23 0 20 3 4 1 2 5 2 1 5 2 3 4 0 0 0 5 3 0 3 5 0 10 3 5 5 1 2 promising start, but leads to bad choices! source sink 18 22 MT(n,m) if n=0 or m=0 return MT(n,m) x ? MT(n-1,m)+ length of the edge from (n- 1,m) to (n,m) y ? MT(n,m-1)+ length of the edge from (n,m-1) to (n,m) return max{x,y} MT(n,m) x ? MT(n-1,m)+ length of the edge from (n- 1,m) to (n,m) y ? MT(n,m-1)+ length of the edge from (n,m-1) to (n,m) return min{x,y} What’s wrong with this approach? 1 5 0 1 0 1 i source 1 5 S1,0 = 5 S0,1 = 1 Calculate optimal path score for each vertex in the graph Each vertex’s score i

文档评论(0)

shengyp + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档