本文主要是介绍CEC2017(Python):麻雀搜索算法SSA求解CEC2017(提供Python代码),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、CEC2017简介
参考文献:
[1]Awad, N. H., Ali, M. Z., Liang, J. J., Qu, B. Y., & Suganthan, P. N. (2016). “Problem definitions and evaluation criteria for the CEC2017 special session and competition on single objective real-parameter numerical optimization,” Technical Report. Nanyang Technological University, Singapore.
二、麻雀搜索算法SSA求解CEC2017
(1)部分Python代码
from SSA import SSA import matplotlib.pyplot as plt import numpy as np import cec2017.functions as functions #主程序 function_name =4 #测试函数 1-29 SearchAgents_no = 50#种群大小 Max_iter = 100#最大迭代次数 dim=30;#维度只能是 10/30/50/100 lb = -100*np.ones(dim)#下界 ub = 100*np.ones(dim)#上界 fobj= functions.all_functions[function_name-1] BestX,BestF,curve = SSA(SearchAgents_no, Max_iter,lb,ub,dim,fobj)#问题求解#画收敛曲线图 if BestF>0:plt.semilogy(curve,color='r',linewidth=2,label='SSA') else:plt.plot(curve,color='r',linewidth=2,label='SSA') plt.xlabel("Iteration") plt.ylabel("Fitness") plt.xlim(0,Max_iter) plt.title("CEC2017-F"+str(function_name)) plt.legend() plt.savefig(str(function_name)+'.png') plt.show() print('\nThe best solution is:\n'+str(BestX)) print('\nThe best optimal value of the objective funciton is:\n'+str(BestF))
(2)部分结果
三、完整Python代码
这篇关于CEC2017(Python):麻雀搜索算法SSA求解CEC2017(提供Python代码)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!