SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
しゅごぷら
集合知プログラ
ミング勉強会
2014/4/12 (Sat)!
第5章 最適化
この本、誤植が多いらしい
❖ 古い刷を持っている人は注意

(初版第6刷はだいたい治って
ました)!
❖ 正誤表:https://
sites.google.com/site/
prgclctintelligence/errata
アジェンダ
❖ 最適化とは?!
❖ ヒルクライム!
❖ 擬似アニーリング!
❖ 遺伝アルゴリズム!
❖ 嗜好の最適化
最適化 (optimization) とは?
❖ 多くは最小化 (minimization)!
❖ 「えっ、でも最大化したいんだけど」 => 正負逆転させ
て最小化問題に持ち込む!
❖ 「最適化とは、コスト関数(目的関数)を定義し、それ
が最小になるような変数を決定することである」
最適化を使う場面
❖ どのような関数で表現されるかが不明である!
❖ 変数が多すぎる!
❖ 虱潰しするには計算コストが膨大すぎる!
❖ 解析的に最小値が求められない

❖ 最適化が必要ない例:
y = x2
+ 2x + 2
5.1 グループ旅行
❖ 6人が各々飛行機でニューヨー
クへ集まる!
❖ どのフライトを使うか?!
❖ コストの例 => 飛行時間・待ち
時間・運賃….etc.
LGA
BOS
DAL
MIA
CAK
ORD
MIA
5.2 解の表現
❖ 数字のリスト(ベクトル)!
❖ [1, 4, 3, 2, 7, 3, 6, 3, 2, 4, 5, 3] (12次元)!
❖ [ Saymourの行きの便, Saymourの帰りの便, Frannyの行
きの便, …., Lesの帰りの便]
5.3 コスト関数
❖ “悪さ”の尺度。小さいほどよい。!
❖ コスト関数の設計が一番むずかしい。!
❖ 最適化 (optimization) ≈ 最小化 (minimization)
コスト = 行きの飛行機代×6人 + 帰りの飛行機代×6人 !
   + 全員集まるまでの待ち時間×6人!
   + 帰りの飛行機に乗るまでの待ち時間!
   + レンタカーの追加料金
5.4 ランダムサーチ(無作為探索)
❖ 無作為探索!
❖ 一部を無作為に抽出し、その中で一番よいものを選ぶ!
❖ 最適化・・・?
x
コスト
5.5 ヒルクライム
❖ 山登り法、勾配法、最急降下法などいろんな別名!
❖ 周りを見て、コスト関数が下がる方向に進む!
❖ 現在地の勾配 (gradient) を計算し、その反対側へ降りて
いく、を繰り返す!
x(k+1)
= x(k)
↵ rf(x(k)
)
ヒルクライムは山を登れない
❖ 最終解は「局所最小」であって「大域最小」ではない。!
❖ 凸関数 (convex function) なら最小値を得られる。
x
コスト
無作為再出発ヒルクライム
!
!
!
!
❖ ヒルクライムの改善!
❖ ヒルクライムを、ランダムな初期値からなんども行う
x
コスト
5.6 擬似アニーリング
❖ 「良い方向への動きを常に取り入れつつも、初期には悪
い解も一部取り入れる」=> 山を登れる
x
コスト
高コストに進む確率
一定確率でコストが

大きくなる方に進む
Tは毎回小さくする
pi = exp(
|f(xi+1) f(xi)|
T
)
5.7 遺伝アルゴリズム
❖ genetic algorithm!
❖ まず個体群を生成し、コスト関数の値でランク付け!
❖ エリート主義 (elitism)!
❖ 突然変異 (mutation)!
❖ 交 or 交配 (crossover)
5.7 遺伝アルゴリズム
個体群:第一世代
5.7 遺伝アルゴリズム
個体群:第一世代
5.7 遺伝アルゴリズム
個体群:第一世代 個体群:第二世代
交差!
&!
突然変異
5.7 遺伝アルゴリズム
個体群:第一世代 個体群:第二世代
交差!
&!
突然変異
5.7 遺伝アルゴリズム
個体群:第一世代 個体群:第二世代
交差!
&!
突然変異
交差!
&!
突然変異
個体群:第三世代
遺伝アルゴリズム
!
❖ 交差の方法・・・一点交差、多点交差、一様交差!
❖ 突然変異の確率・・・0.1%∼1.0%ぐらい!
!
❖ wikipediaみるとのってるよ
5.8 実際のフライトを検索
❖ 省略・・・
いろいろ面白い
❖ 遺伝アルゴリズムでマリオ!
❖ http://www.nicovideo.jp/watch/sm18721450!
❖ https://www.youtube.com/watch?v=yZJ1V-zv_gU!
!
❖ 遺伝的アルゴリズムを楽しく理解できるサイトをまとめてみ
た!
❖ http://d.hatena.ne.jp/download_takeshi/
20100723/1279837904
5.9 嗜好の最適化
❖ 「割り当て」の最適化!
❖ 人材の最適配置
希望1 希望2 希望3 …
企業A 学生a 学生b
企業B 学生a 学生c!
企業C 学生
企業D
企業E
企業F
企業G
…
❖ 学生10人を寮に割り振る(10^4通り)!
!
!
!
❖ 完全解がコスト0になるようにコスト関数を設計すると
GOOD
5.9 嗜好の最適化
学生が第一希望に割り当てられた:コスト0!
学生が第二希望に割り当てられた:コスト1!
希望にないところに割り当てられた:コスト3!
A寮(2) B寮(2) C寮(2) D寮(2) E寮(2)
5.9 嗜好の最適化
❖ この問題は制約付き(各寮に二人)!
❖ 学生でループを回し、学寮のスロットに一人ずつ割り当
てていくことで有効解が得られる!
!
❖ ここだとランダム最適化と遺伝的アルゴリズムを適用
5.10 ネットワークの可視化
❖ 変数:座標(x,y) x 人数 個!
❖ コスト関数:リンクの交差の数!
❖ 描画にはPython Imaging Libraryが便利。
本日のまとめ・・・
❖ 最適化を使うのに大切なこと!
!
❖ 問題に対してコスト関数が定義されていること!
❖ 類似の解が類似の結果をもたらす傾向になること
Pythonによるデータ分析入門
❖ 2013年12月発売!
❖ Amazonだとそこそこ評判良い
以下補足
最適化問題の種類
❖ 線形計画問題!
❖ 整数計画問題2次計画問題!
❖ 凸計画問題!
❖ 半正定値計画問題非線形計画問題!
❖ 組み合わせ最適化
学問分野で言うと、線形プログラミング? オペレーションズ・リサーチ?
計算理論の問題のクラス
❖ P:多項式時間(Polynomial time)で解ける問題の集合!
❖ NP:非決定性多項式時間(Non-deterministic Polynomial
time)で解ける問題の集合!
❖ P≠NP予想!
❖ NP困難、NP完全!
❖ 計算機工学(Computer engineering)の分野になってくる
スパース最適化
❖ スパース = 疎!
❖ 圧縮センシング (Compressed Sensing)

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

集合知プログラミング勉強会 第五章 最適化