一、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.
二、粒子群优化算法PSO求解CEC2017
(1)部分Python代码
from PSO import PSO
import matplotlib.pyplot as plt
import numpy as np
import cec2017.functions as functions
#主程序
function_name =7 #测试函数 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 = PSO(SearchAgents_no, Max_iter,lb,ub,dim,fobj)#问题求解#画收敛曲线图
if BestF>0:plt.semilogy(curve,color='g',linewidth=3,label='PSO')
else:plt.plot(curve,color='g',linewidth=3,label='PSO')
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))