github地址:https://github.com/guofei9987/scikit-opt
$pip install scikit-opt
定义目标函数
def demo_func(x):
x1, x2, x3 = x
return x1 ** 2 + (x2 - 0.05) ** 2 + x3 ** 2
优化求解
from sko.PSO import PSO
pso = PSO(func=demo_func, dim=3)
pso.run()
print('best_x is ',pso.gbest_x)
print('best_y is ',pso.gbest_y)
pso.plot_history()

github地址:https://github.com/guofei9987/scikit-opt 欢迎star
另外,这个库总共封装了遗传算法(GA)、粒子群算法(PSO)、蚁群算法(ACA)、模拟退火算法(SA)、免疫优化算法(IA)、人工鱼群算法(AFSA)。
文档在下面,大家探索吧。
中文文档 https://scikit-opt.github.io/scikit-opt/#/docs/zh
documents https://scikit-opt.github.io/scikit-opt/#/docs/en
$pip install scikit-opt
定义目标函数
def demo_func(x):
x1, x2, x3 = x
return x1 ** 2 + (x2 - 0.05) ** 2 + x3 ** 2
优化求解
from sko.PSO import PSO
pso = PSO(func=demo_func, dim=3)
pso.run()
print('best_x is ',pso.gbest_x)
print('best_y is ',pso.gbest_y)
pso.plot_history()

github地址:https://github.com/guofei9987/scikit-opt 欢迎star
另外,这个库总共封装了遗传算法(GA)、粒子群算法(PSO)、蚁群算法(ACA)、模拟退火算法(SA)、免疫优化算法(IA)、人工鱼群算法(AFSA)。
文档在下面,大家探索吧。
中文文档 https://scikit-opt.github.io/scikit-opt/#/docs/zh
documents https://scikit-opt.github.io/scikit-opt/#/docs/en