我使用NLopt库和python绑定。在
opt = nlopt.opt(nlopt_algorithm, N)
opt.set_max_objective(func_to_maximize)
opt.set_lower_bounds(lower_bounds)
opt.set_upper_bounds(upper_bounds)
opt.set_maxeval(100)
xopt = opt.optimize(x0)
当我使用nlopt_algorithm = nlopt.LN_SBPLX
时,效果很好。但是,如果我使用nlopt_algorithm = nlopt.GN_DIRECT_L
,它将失败,并出现错误:
ValueError: nlopt invalid argument
有人知道为什么吗?我错过了一些争论吗?在
问题是因为并不是所有变量都定义了绑定约束。对于全局优化,NLopt要求所有参数都有一个上界和一个下界。在
相关问题 更多 >
编程相关推荐