How to obtain the objective function value and values of variables during each iteration of the algorithm using pymoo?

随声附和 提交于 2021-01-28 18:12:36

问题


I would like to get the values of objective and decision variables during each iteration of the algorithm. Is there any way of doing that? I tried to use history, but it doesn't contain the values. I'm trying to solve a single objective optimization problem using pymoo. This objective function is like a black box function, which is not in a nice closed form.

f = objective(x, fitted_model, lam)
g1 = x[:, 0] - 3.5
g2 = 1.14 - x[:, 0]
g3 = x[:, 1] - 103
g4 = 44.4 - x[:, 1]
g5 = x[:, 2] - 107
g6 = 58.6 - x[:, 2]
g7 = x[:, 3] - 223
g8 = 176.3 - x[:, 3]
g9 = x[:, 4] - 364.9
g10 = 325.9 - x[:, 4]
out["F"] = f
out["G"] = anp.column_stack([g1, g2, g3, g4, g5, g6, g7, g8, g9, g10])

Now I would like to get the values of f and x during each iteration.

res = minimize(MyProblem(), algorithm, seed=1, save_history=True, verbose=True)

Is there anyway of doing that?

来源:https://stackoverflow.com/questions/62496005/how-to-obtain-the-objective-function-value-and-values-of-variables-during-each-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!