python:基于竞争学习的鳟海鞘算法(CLSSA)求解23个测试函数

作品简介

一、基于竞争学习的鳟海鞘算法

基于竞争学习的鳟海鞘算法(Competitive Learning-Based Salp Swarm Algorithm,CLSSA)由Mohammed Qaraad等人于2023年提出。

参考文献:

Qaraad M, Aljadania A, Elhosseini M. Large-Scale Competitive Learning-Based Salp Swarm for Global Optimization and Solving Constrained Mechanical and Engineering Design Problems. Mathematics. 2023; 11(6):1362. https://doi.org/10.3390/math11061362

二、CLSSA求解23个测试函数

23个测试函数简介

测试集:23组基本测试函数简介及图像(提供python代码)_IT猿手的博客-CSDN博客

部分代码

from FunInfo import Get_Functions_details
from CLSSA import CLSSA
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['Microsoft YaHei']
#主程序
function_name =5 #测试函数1-23
SearchAgents_no = 50#种群大小
Max_iter = 100#迭代次数
lb,ub,dim,fobj=Get_Functions_details(function_name)#获取问题信息
BestX,BestF,curve = CLSSA(SearchAgents_no, Max_iter,lb,ub,dim,fobj)#问题求解

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


部分结果






三、参考代码

文件夹内包含CLSSA求解23个函数完整python代码,点击main.py即可运行。


创作时间: