樽海鞘算法如何应用于单目标问题求解,并附有Matlab代码实例?

2026-05-26 17:062阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计508个文字,预计阅读时间需要3分钟。

樽海鞘算法如何应用于单目标问题求解,并附有Matlab代码实例?

1. 简介

2.部分代码

%Salp Swarm Algorithm (SSA) 源代码版本 1.0%您可以直接在单独的文件中定义您的成本,并将其句柄加载到 f 中

1 简介

樽海鞘算法如何应用于单目标问题求解,并附有Matlab代码实例?

2 部分代码

%_________________________________________________________________________________
% Salp Swarm Algorithm (SSA) source codes version 1.0
%
% You can simply define your cost in a seperate file and load its handle to fobj
% The initial parameters that you need are:
%__________________________________________
% 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_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
clear all
clc
SearchAgents_no=30; % Number of search agents
Function_name='F1'; % Name of the test function that can be from F1 to F23 (
Max_iteration=1000; % Maximum numbef of iterations
% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
[Best_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[500 500 660 290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
%Draw objective space
subplot(1,2,2);
semilogy(SSA_cg_curve,'Color','r')
title('Objective space')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid on
box on
legend('SSA')
display(['The best solution obtained by SSA is \m ', num2str(Best_pos)]);
display(['The best optimal value of the objective funciton found by SSA is \n ', num2str(Best_score)]);

3 仿真结果


4 参考文献

[1]康俊涛, 邹立, 曹鸿猷,等. 基于樽海鞘群算法的桁架结构优化设计[J]. 空间结构, 2020, 26(3):9.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。


本文共计508个文字,预计阅读时间需要3分钟。

樽海鞘算法如何应用于单目标问题求解,并附有Matlab代码实例?

1. 简介

2.部分代码

%Salp Swarm Algorithm (SSA) 源代码版本 1.0%您可以直接在单独的文件中定义您的成本,并将其句柄加载到 f 中

1 简介

樽海鞘算法如何应用于单目标问题求解,并附有Matlab代码实例?

2 部分代码

%_________________________________________________________________________________
% Salp Swarm Algorithm (SSA) source codes version 1.0
%
% You can simply define your cost in a seperate file and load its handle to fobj
% The initial parameters that you need are:
%__________________________________________
% 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_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj)
%__________________________________________
clear all
clc
SearchAgents_no=30; % Number of search agents
Function_name='F1'; % Name of the test function that can be from F1 to F23 (
Max_iteration=1000; % Maximum numbef of iterations
% Load details of the selected benchmark function
[lb,ub,dim,fobj]=Get_Functions_details(Function_name);
[Best_score,Best_pos,SSA_cg_curve]=SSA(SearchAgents_no,Max_iteration,lb,ub,dim,fobj);
figure('Position',[500 500 660 290])
%Draw search space
subplot(1,2,1);
func_plot(Function_name);
title('Parameter space')
xlabel('x_1');
ylabel('x_2');
zlabel([Function_name,'( x_1 , x_2 )'])
%Draw objective space
subplot(1,2,2);
semilogy(SSA_cg_curve,'Color','r')
title('Objective space')
xlabel('Iteration');
ylabel('Best score obtained so far');
axis tight
grid on
box on
legend('SSA')
display(['The best solution obtained by SSA is \m ', num2str(Best_pos)]);
display(['The best optimal value of the objective funciton found by SSA is \n ', num2str(Best_score)]);

3 仿真结果


4 参考文献

[1]康俊涛, 邹立, 曹鸿猷,等. 基于樽海鞘群算法的桁架结构优化设计[J]. 空间结构, 2020, 26(3):9.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。