麻雀优化算法SSA-灰狼优化算法GWO-粒子群优化算法PSO-鲸鱼优化算法WOA-遗传优化算法GA【单目标优化算法】在23个测试函数上对比(Matlab代码实现)

%__________________________________________

% fobj = @YourCostFunction 设定适应度函数

% dim = number of your variables 设定维度

% Max_iteration = maximum number of generations 设定最大迭代次数

% SearchAgents_no = number of search agents 种群数量

% lb=[lb1,lb2,...,lbn] where lbn is the lower bound of variable n 变量下边界

% ub=[ub1,ub2,...,ubn] where ubn is the upper bound of variable n 变量上边界

% If all the variables have equal lower bound you can just

% define lb and ub as two single number numbers

% To run SSA: [Best_pos,Best_score,curve]=SSA(pop,Max_iter,lb,ub,dim,fobj)

%__________________________________________

clear all

clc

rng('default');

SearchAgents_no=30; % Number of search agents 种群数量

Function_name='F6'; % Name of the test function that can be from F1 to F23 (Table 1,2,3 in the paper) 设定适应度函数

Max_iteration=500; % Maximum numbef of iterations 设定最大迭代次数

% Load details of the selected benchmark function

[lb,ub,dim,fobj]=Get_Functions_details(Function_name); %设定边界以及优化函数

%% 麻雀算法

[fMin , bestX,SSAcurve ] = SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %开始优化

%% 灰狼算法

[Alpha_score,Alpha_pos,GWOcurve]=GWO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %开始优化

%% 粒子群算法

[gBestScore,gBest,PSOcurve]=PSO(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %开始优化

%% 鲸鱼算法

[Leader_score,Leader_pos,WOAcurve]=WOA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %开始优化

%% 遗传算法

[Best_score,Best_pos,GAcurve]=GA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj); %开始优化

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智能算法及其模型预测

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值