多目的進化計算ライブラリのplatypusについて目的関数の範囲指定のやりかたが分からない.
設計変数に関しては,Real(0,1)のように範囲指定することができ,拘束条件関数の定義を行うことができる.
しかし,目的関数f1を2.5<==f1<==3.0
という指定のやり方が分からない.
ご存じの方がいらっしゃればお教えいただきたいです.
実際に問題なくプログラムが動いているのは確認済みです.
実際のコードは以下の通りです.
from platypus import NSGAII, Problem, Real
def belegundu(vars):
x1 = vars[0]
x2 = vars[1]
x3 = vars[2]
x4 = vars[3]
x5 = vars[4]
x6 = vars[5]
x7 = vars[6]
x8 = vars[7]
x9 = vars[8]
x10 = vars[9]
x11 = vars[10]
x12 = vars[11]
x13 = vars[12]
x14 = vars[13]
x15 = vars[14]
x16 = vars[15]
x17 = vars[16]
x18 = vars[17]
x19 = vars[18]
x20 = vars[19]
x21 = vars[20]
x22 = vars[21]
x23 = vars[22]
x24 = vars[23]
x25 = vars[24]
x26 = vars[25]
x27 = vars[26]
x28 = vars[27]
x29 = vars[28]
x30 = vars[29]
return [0.64000573*x1+0.14397378*x2+0.54079948*x3+0.22333884*x4-1.04133668*x5-1.02149524*x6
-0.80324154*x7-0.96197168*x8+2.17547164*x9+2.1159477*x10+2.11594784*x11+2.1556302*x12
-0.81051432*x13-0.98908598*x14-0.65178426*x15-0.85019723*x16+1.42402255*x17+1.54307024*x18
+1.54307019*x19+1.4438638*x20+0.60094854*x21+0.60094859*x22+0.58110701*x23+0.56126604*x24
+1.37255057*x25+1.54120144*x26-2.64281005*x27-2.77177842*x28+1.07142851*x29+0.84325402*x30
-1.714979555
,-0.01221614*x1-1.15591655*x2+3.97238539*x3-0.0635985*x4-0.01579076*x5+0.47912646*x6
-0.35423701*x7-0.38614298*x8-2.33929053*x9-4.22182428*x10-4.99001553*x11+3.75250581*x12
+2.12183612*x13+0.82466014*x14+1.67771848*x15+2.19306848*x16-1.60337024*x17+0.05854879*x18
-1.25631746*x19-1.67983829*x20-1.58976272*x21+0.11155756*x22-1.55505578*x23-2.12679008*x24
-2.12289794*x25-0.86725301*x26+4.58191061*x27+2.03660415*x28+0.91999822*x29-0.76666518*x30
-0.77416676
],[x1+x2+x3+x4-1,
x5+x6+x7+x8-1,
x9+x10+x11+x12-1,
x13+x14+x15+x16-1,
x17+x18+x19+x20-1,
x21+x22+x23+x24-1,
x25+x26-1,
x27+x28-1,
x29+x30-1
]
problem = Problem(30, 2, 9)
problem.types[:] = [Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1),
Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1),
Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1),
Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1),
Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1), Real(0, 1)
]
problem.constraints[:] = "==0"
problem.function = belegundu
algorithm = NSGAII(problem)
algorithm.run(10000)
import pandas as pd
df = pd.DataFrame(columns = ("x1","x2","x3","x4","x5","x6",
"x7","x8","x9","x10","x11","x12",
"x13","x14","x15","x16","x17","x18",
"x19","x20","x21","x22","x23","x24",
"x25","x26","x27","x28","x29","x30",
"c1","c2","c3","c4","c5","c6","c7","c8","c9","f1","f2"))
for i in range(len(algorithm.result)):
df.loc[i] = algorithm.result[i].variables[:]+ \
algorithm.result[i].constraints[:] + \
algorithm.result[i].objectives[:]
df.to_csv("platypus_exp6.csv")
import seaborn as sns
sns.pairplot(df)