一、鸡群优化算法CSO求解cec2013
1.cec2013函数简介
CEC 2013 Special Session on Real-Parameter Optimization中共有28个测试函数维度可选择为10/30/50/100。
每个测试函数的详细信息如下表所示:
cec2013参考文献:
[1] Liang J J , Qu B Y , Suganthan P N , et al. Problem Definitions and Evaluation Criteria for the CEC 2013 Special Session on Real-Parameter Optimization. 2013.
鸡群优化算法CSO参考文献:
[1] MENG X , LIU Y , GAO X Z , et al. A new bio-inspired algorithm: chicken swarm optimization[J]. Lecture Notes in Computer Science ,2014 ,8794(1):86-94.
2.部分代码
from CEC2013.cec2013 import *
from CSO import CSO
import matplotlib.pyplot as plt
import numpy as np
#主程序
function_name =1 #测试函数1-28
SearchAgents_no = 50#种群大小
Max_iter = 100#迭代次数
dim=10#维度 10/30/50/100
lb=-100*np.ones(dim)#下限
ub=100*np.ones(dim)#上限
cec_functions = cec2013(dim,function_name)
fobj=cec_functions.func#目标函数
BestX,BestF,curve = CSO(SearchAgents_no, Max_iter,lb,ub,dim,fobj)#问题求解
#画收敛曲线图
if BestF>0:
plt.semilogy(curve,color='r',linewidth=3,label='CSO')
else:
plt.plot(curve,color='r',linewidth=3,label='CSO')
plt.xlabel("Iteration")
plt.ylabel("Fitness")
plt.xlim(0,Max_iter)
plt.title("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))