鲍威尔搜索法 (POWELL)
- class pypop7.optimizers.ds.powell.POWELL(problem, options)[源代码]
鲍威尔搜索法 (POWELL)。
注意
这是对来自 SciPy 的鲍威尔算法的封装,带有函数评估次数上限的精度控制。
- 参数:
problem (dict) –
- 问题参数,包含以下通用设置 (键)
'fitness_function' - 需要被最小化的目标函数 (func),
'ndim_problem' - 维度数量 (int),
'upper_boundary' - 搜索范围的上边界 (array_like),
'lower_boundary' - 搜索范围的下边界 (array_like).
options (dict) –
- 优化器选项,包含以下通用设置 (键)
'max_function_evaluations' - 函数评估的最大次数 (int, 默认: np.inf),
'max_runtime' - 允许的最大运行时间 (float, 默认: np.inf),
'seed_rng' - 随机数生成器的种子,需要明确设置 (int);
- 以及以下特定设置 (键)
“x”- 初始(起始)点 (array_like),
如果未给出,它将从一个均匀分布中随机抽样,该分布的搜索范围由 problem[‘lower_boundary’] 和 problem[‘upper_boundary’] 界定。
示例
使用优化器最小化著名的测试函数 Rosenbrock
1>>> import numpy 2>>> from pypop7.benchmarks.base_functions import rosenbrock # function to be minimized 3>>> from pypop7.optimizers.ds.powell import POWELL 4>>> problem = {'fitness_function': rosenbrock, # define problem arguments 5... 'ndim_problem': 20, 6... 'lower_boundary': -5*numpy.ones((20,)), 7... 'upper_boundary': 5*numpy.ones((20,))} 8>>> options = {'max_function_evaluations': 5000, # set optimizer options 9... 'seed_rng': 2022, 10... 'x': 3*numpy.ones((20,)), 11... 'verbose_frequency': 500} 12>>> powell = POWELL(problem, options) # initialize the optimizer class 13>>> results = powell.optimize() # run the optimization process 14>>> # return the number of function evaluations and best-so-far fitness 15>>> print(f"POWELL: {results['n_function_evaluations']}, {results['best_so_far_y']}") 16POWELL: 50000, 0.0
关于其编码的正确性检查,请参阅这份基于代码的可重复性报告以获取更多详情。
- x
初始(起始)点。
- 类型:
array_like
参考文献
https://docs.scipy.org.cn/doc/scipy/reference/optimize.minimize-powell.html
Kochenderfer, M.J. and Wheeler, T.A., 2019. Algorithms for optimization. MIT Press. https://algorithmsbook.com/optimization/files/chapter-7.pdf (详情参见算法 7.3(第 102 页)。)
Powell, M.J., 1964. An efficient method for finding the minimum of a function of several variables without calculating derivatives. The Computer Journal, 7(2), pp.155-162. https://academic.oup.com/comjnl/article-abstract/7/2/155/335330