CEC2017(Python):差分进化算法DE求解CEC2017

2024-01-02 06:23:54

一、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.

二、差分进化算法DE求解CEC2017

(1)部分Python代码

from DE import DE
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 = DE(SearchAgents_no, Max_iter,lb,ub,dim,fobj)#问题求解


#画收敛曲线图
if BestF>0:
? ? plt.semilogy(curve,color='r',linewidth=2,label='DE')
else:
? ? plt.plot(curve,color='r',linewidth=2,label='DE')
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代码

文章来源:https://blog.csdn.net/weixin_46204734/article/details/135324834
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。