1 / 17

アルゴリズムとデータ構造 補足資料 10-3 「ナップザック問題」

アルゴリズムとデータ構造 補足資料 10-3 「ナップザック問題」. 横浜国立大学 理工 学部 数物・電子情報系学科 富井尚志. バックトラックアルゴリズム. とりあえずやってみる ダメ なら戻って別の道を探る あの とき別の道を選んでいたら 、、、 試行錯誤( trial and error ) 結局全部のケースをやってみる(完全解) その中で最適な解を選ぶ (最適解を覚えておく). ナップザック問題 ( Knapsack problem ). n 個の品物を旅行カバンの中に入れて旅行する.持って歩ける重量には制限がある

lev
Download Presentation

アルゴリズムとデータ構造 補足資料 10-3 「ナップザック問題」

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. アルゴリズムとデータ構造補足資料10-3「ナップザック問題」アルゴリズムとデータ構造補足資料10-3「ナップザック問題」 横浜国立大学 理工学部 数物・電子情報系学科 富井尚志

  2. バックトラックアルゴリズム • とりあえずやってみる • ダメなら戻って別の道を探る • あのとき別の道を選んでいたら、、、 • 試行錯誤(trial and error) • 結局全部のケースをやってみる(完全解) • その中で最適な解を選ぶ (最適解を覚えておく)

  3. ナップザック問題(Knapsack problem) • n個の品物を旅行カバンの中に入れて旅行する.持って歩ける重量には制限がある • 個々の品物には,重さ と 価値(重要度) の情報が与えられている. • n個の品物からいくつか選択して,制限重量以下で価値の総和が最大になるようにする.

  4. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値0点

  5. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値10点 500g; あと一つ載せたらOUT

  6. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値90点 500g; あと一つ載せたらOUT

  7. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値90点 1,300g; OUT

  8. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値190点 320g; 1,300g; OUT

  9. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値190点 320g; 1,300g; OUT 720g;OUT

  10. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値190点 320g; 1,300g; OUT 720g;OUT 520g;OUT

  11. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値290点 320g; 330g; 1,300g; OUT 720g;OUT 520g;OUT

  12. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値390点 320g; 330g; 340g; 1,300g; OUT 720g;OUT 520g;OUT

  13. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値390点 320g; 330g; 340g; 1,300g; OUT 720g;OUT 520g;OUT 640g;OUT

  14. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値390点 解候補 現在の最大総価値390点 320g; 330g; 340g; 1,300g; OUT 720g;OUT 520g;OUT 640g;OUT

  15. ナップザック問題(Knapsack problem) 重量制限が500gのとき 現在の最大総価値390点 1,300g; OUT

  16. ナップザック問題(Knapsack problem) 1 1 1 1 1 1 1 1 1 1 ~ 0 0 0 0 0 0 0 0 0 0 最悪時: 上記の全とおりの組み合わせについて、総重量と総価値を計算して、       一番良いものを選ぶ。 O(2n)

  17. バックトラックアルゴリズム • とりあえずやってみる • ダメなら戻って別の道を探る • あのとき別の道を選んでいたら、、、 • 試行錯誤(trial and error) • 結局全部のケースをやってみる(完全解) • その中で最適な解を選ぶ (最適解を覚えておく)

More Related