LoginSignup
1
1

More than 3 years have passed since last update.

ちょっと最適化問題が解けるplatypusを動かしてみた

Last updated at Posted at 2020-08-19

なんか暑くて疲れていたのでplatypusで最適化してみた

ベイズ推定の勉強にちょっと疲れてきたので、口安めに、なんか最適化してみたくなって、ちょっとやってみた。
Platypus - Multiobjective Optimization in Pythonにマニュアルがありました。

インストールは、どうもplatypusでなくて、pip install platypus-optで-optがいるようです。

それでインストールしたら、サンプルを動かしてみましょう。
サンプルは、
A Simple Example
の、DTLZ2 問題ってのを、 NSGA-IIで解く問題のようです。

一体、このDTLZ2問題ってのがなんなのか?情報があまりありません。
どうもDTLZ2問題とは、単峰性問題で、山あるいは谷がひとつしかない問題のようです。

では、もう一つの NSGA-IIはなんだろう。
GAということで、きっと遺伝的アルゴリズムに関係しているのはわかりますよね。どうも、このGAを複雑にしたもののようです。とりあえず、NSGA-Ⅱこれを読むとわかるようです。私にはまだ理解できていません。しっかり勉強しないと。。。

さて、ここまで来たら動かしてみましょう。
こんなサンプルのプログラムがマニュアルにのっています。

# -*- coding: utf-8 -*-
from platypus import NSGAII, DTLZ2
# define the problem definition
problem = DTLZ2()
# instantiate the optimization algorithm
algorithm = NSGAII(problem)
# optimize the problem using 10,000 function evaluations
algorithm.run(10000)
# plot the results using matplotlib
import matplotlib.pyplot as plt
plt.scatter([s.objectives[0] for s in algorithm.result],
            [s.objectives[1] for s in algorithm.result])
plt.xlim([0, 1.1])
plt.ylim([0, 1.1])
plt.xlabel("$f_1(x)$")
plt.ylabel("$f_2(x)$")
plt.show()

動かすと、こんなグラフが描かれます。
pareateFigure 2020-08-19 185923.png

これはパレート最適解の線図になります。

さて、ドキュメントにこんなことが書いてありました。
Note that we did not need to specify many settings when constructing NSGA-II. For any options not specified by the user, Platypus supplies the appropriate settings using best practices.
google翻訳・・NSGA-IIを構築する際に、多くの設定を指定する必要はないことに注意してください。ユーザーが指定していないオプションについては、Platypus はベスト プラクティスを使用して適切な設定を提供します。

これ、本当だろうか?確かに、スクリプトに、いろいろなパラメーターを書いていないし、これでいいなら、結構楽かもしれない。。。本当だろうか?

とりあえず今日はここまで。。。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1