メインスクリプト例
ベイズ最適化の場合
import nimo
#目的関数の数を指定します.
n_objectives = 2
#一度のサイクルで探索アルゴリズムが提案する条件数を指定します.
n_proposals = 2
#サイクル数を指定します.
n_cycles = 3
#実験条件をリスト化したファイルを指定
candidates_file = "./candidates.csv"
#探索アルゴリズムが提案する条件を記載するファイルを指定
proposals_file = "./proposals.csv"
#履歴を格納するリストを作成
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives)
for K in range(n_cycles):
print("Start cycle", K+1)
#最初のサイクルは実験データがないため,ランダム探索を実施
#初めから実験データがいくつかある場合は,最初からPHYSBOを実行可能であり,分岐の必要は無し
if K==0:
method = "RE"
else:
method = "PHYSBO"
#探索アルゴリズムの実行
nimo.selection(method = method,
input_file = candidates_file,
output_file = proposals_file,
num_objectives = n_objectives,
num_proposals = n_proposals)
#ロボット実験用インプットファイルの作成およびロボット実験の実行
nimo.preparation_input(machine = "STAN",
input_file = proposals_file,
input_folder = "./EXPInput")
#ロボット実験結果の解析と実験条件ファイルの更新
nimo.analysis_output(machine = "STAN",
input_file = proposals_file,
output_file = candidates_file,
num_objectives = n_objectives,
output_folder = "./EXPOutput")
#履歴を格納するリストを更新
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives,
itt = K,
history_file = res_history)
#各サイクルの目的関数のデータ分布を出力
nimo.visualization.plot_distribution.plot(input_file = candidates_file,
num_objectives = n_objectives)
#目的関数のサイクル依存性をプロット
nimo.visualization.plot_history.cycle(input_file = res_history,
num_cycles = n_cycles)
#目的関数の最大値のサイクル依存性をプロット
nimo.visualization.plot_history.best(input_file = res_history,
num_cycles = n_cycles)
無目的探索の場合
import nimo
#目的関数の数を指定します.
n_objectives = 2
#一度のサイクルで探索アルゴリズムが提案する条件数を指定します.
n_proposals = 2
#サイクル数を指定します.
n_cycles = 3
#実験条件をリスト化したファイルを指定
candidates_file = "./candidates.csv"
#探索アルゴリズムが提案する条件を記載するファイルを指定
proposals_file = "./proposals.csv"
#履歴を格納するリストを作成
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives)
for K in range(n_cycles):
print("Start cycle", K+1)
#最初のサイクルは実験データがないため,ランダム探索を実施
#初めから実験データがいくつかある場合は,最初からBLOXを実行可能であり,分岐の必要は無し
if K==0:
method = "RE"
else:
method = "BLOX"
#探索アルゴリズムの実行
nimo.selection(method = method,
input_file = candidates_file,
output_file = proposals_file,
num_objectives = n_objectives,
num_proposals = n_proposals)
#ロボット実験用インプットファイルの作成およびロボット実験の実行
nimo.preparation_input(machine = "STAN",
input_file = proposals_file,
input_folder = "./EXPInput")
#ロボット実験結果の解析と実験条件ファイルの更新
nimo.analysis_output(machine = "STAN",
input_file = proposals_file,
output_file = candidates_file,
num_objectives = n_objectives,
output_folder = "./EXPOutput")
#履歴を格納するリストを更新
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives,
itt = K,
history_file = res_history)
#各サイクルの目的関数のデータ分布を出力
nimo.visualization.plot_distribution.plot(input_file = candidates_file,
num_objectives = n_objectives)
#目的関数のサイクル依存性をプロット
nimo.visualization.plot_history.cycle(input_file = res_history,
num_cycles = n_cycles)
#目的関数の最大値のサイクル依存性をプロット
nimo.visualization.plot_history.best(input_file = res_history,
num_cycles = n_cycles)
相図作成の場合
import nimo
#目的関数の数を指定します.
n_objectives = 2
#一度のサイクルで探索アルゴリズムが提案する条件数を指定します.
n_proposals = 2
#サイクル数を指定します.
n_cycles = 3
#実験条件をリスト化したファイルを指定
candidates_file = "./candidates.csv"
#探索アルゴリズムが提案する条件を記載するファイルを指定
proposals_file = "./proposals.csv"
#履歴を格納するリストを作成
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives)
for K in range(n_cycles):
print("Start cycle", K+1)
#最初のサイクルは実験データがないため,ランダム探索を実施
#初めから実験データがいくつかある場合は,最初からPDCを実行可能であり,分岐の必要は無し
if K==0:
method = "RE"
else:
method = "PDC"
#探索アルゴリズムの実行
nimo.selection(method = method,
input_file = candidates_file,
output_file = proposals_file,
num_objectives = n_objectives,
num_proposals = n_proposals)
#ロボット実験用インプットファイルの作成およびロボット実験の実行
nimo.preparation_input(machine = "STAN",
input_file = proposals_file,
input_folder = "./EXPInput")
#ロボット実験結果の解析と実験条件ファイルの更新
nimo.analysis_output(machine = "STAN",
input_file = proposals_file,
output_file = candidates_file,
num_objectives = n_objectives,
output_folder = "./EXPOutput")
#履歴を格納するリストを更新
res_history = nimo.history(input_file = candidates_file,
num_objectives = n_objectives,
itt = K,
history_file = res_history)
#各サイクルの相図を出力
nimo.visualization.plot_phase_diagram.plot(input_file = candidates_file)
自作モジュールを利用する場合
import nimo
#目的関数の数を指定します.
n_objectives = 2
#一度のサイクルで探索アルゴリズムが提案する条件数を指定します.
n_proposals = 2
#サイクル数を指定します.
n_cycles = 3
#実験条件をリスト化したファイルを指定
candidates_file = "./candidates.csv"
#探索アルゴリズムが提案する条件を記載するファイルを指定
proposals_file = "./proposals.csv"
#履歴を格納するリストを作成
res_history = nimo.history(input_file = candidates_file, num_objectives = n_objectives)
for K in range(n_cycles):
print("Start cycle", K+1)
#探索アルゴリズムの実行
import ai_tool_original
ai_tool_original.ORIGINAL(input_file = candidates_file,
output_file = proposals_file,
num_objectives = n_objectives,
num_proposals = n_proposals).select()
#ロボット実験用インプットファイルの作成およびロボット実験の実行
import preparation_input_original
preparation_input_original.ORIGINAL(input_file = proposals_file,
input_folder = "./EXPInput").perform()
#ロボット実験結果の解析と実験条件ファイルの更新
import analysis_output_original
analysis_output_original.ORIGINAL(input_file = proposals_file,
output_file = candidates_file,
num_objectives = n_objectives,
output_folder = "./EXPOutput").perform()
#履歴を格納するリストを更新
res_history = nimo.history(input_file = candidates_file, num_objectives = n_objectives, itt = K, history_file = res_history)
#各サイクルの目的関数のデータ分布を出力
nimo.visualization.plot_distribution.plot(input_file = candidates_file, num_objectives = n_objectives)
#目的関数のサイクル依存性をプロット
nimo.visualization.plot_history.cycle(input_file = res_history, num_cycles = n_cycles)
#目的関数の最大値のサイクル依存性をプロット
nimo.visualization.plot_history.best(input_file = res_history, num_cycles = n_cycles)