【优化算法】缎面弓箭鸟优化(SBO)【含Matlab源码 1432期】
【摘要】
一、获取代码方式
获取代码方式1: 通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
获取代码方式2: 完整代码已上传我的资源:【优化算法】缎面弓箭鸟优化(SBO)【含Matlab源...
一、获取代码方式
获取代码方式1:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
获取代码方式2:
完整代码已上传我的资源:【优化算法】缎面弓箭鸟优化(SBO)【含Matlab源码 1432期】
备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
function SBO
%% This function implements the basic School Based Optimization (SBO) algorithm for 10-bar truss optimization
% For more information about this method and other algorithms check the following papers:
%%
global D
% Specity SBO parameters
Itmax=300; % Maximum number of iterations
NClass=5; % Number of classes in the school
PopSize=15; % Population size of each class
% Optimization problem parameters
D=Data10; % For truss function evaluate the functio to get the initial parameters
LB=D.LB; % Lowerbound
UB=D.UB; % Upperbound
FN='ST10'; % Name of analyzer function
%% Randomely generate initial designs between LB and UB
Cycle=1;
for I=1:PopSize
for NC=1:NClass
Designs{NC}(I,:)=LB+rand(1,size(LB,2)).*(UB-LB); % Row vector
end
end
% Analysis the designs
for NC=1:NClass
[PObj{NC},Obj{NC}]=Analyser(Designs{NC},FN);
Best{NC}=[];
end
%% SBO loop
for Cycle=2:Itmax
for NC=1:NClass
% Identify best designs and keep them
[Best{NC},Designs{NC},PObj{NC},Obj{NC},WMeanPos{NC}]=Specifier(PObj{NC},Obj{NC},Designs{NC},Best{NC});
TeachersPObj(NC,1)=Best{NC}.GBest.PObj;
TeachersDes(NC,:)=Best{NC}.GBest.Design;
end
for NC=1:NClass
% Select a teacher
SelectedTeacher=TeacherSelector(Best,NC,TeachersPObj);
% Apply Teaching
[Designs{NC},PObj{NC},Obj{NC}]=Teaching(LB,UB,Designs{NC},PObj{NC},Obj{NC},TeachersDes(SelectedTeacher,:),WMeanPos{NC},FN);
[Best{NC},Designs{NC},PObj{NC},Obj{NC},WMeanPos{NC}]=Specifier(PObj{NC},Obj{NC},Designs{NC},Best{NC});
% Apply Learning
[Designs{NC},PObj{NC},Obj{NC}]=Learning(LB,UB,Designs{NC},Obj{NC},PObj{NC},FN);
[Best{NC},Designs{NC},PObj{NC},Obj{NC},WMeanPos{NC}]=Specifier(PObj{NC},Obj{NC},Designs{NC},Best{NC});
end
% Find best so far solution and Mean
CumPObj=[];
for NC=1:NClass
ClassBestPObj(NC,1)=Best{NC}.GBest.PObj;
ClassMean(NC,1)=mean(PObj{NC});
CumPObj=[CumPObj;PObj{NC}];
end
[~,b]=min(ClassBestPObj);
OveralBestPObj=Best{b}.GBest.PObj;
OveralBestObj=Best{b}.GBest.Obj;
OveralBestDes=Best{b}.GBest.Design;
% Plot time history of the best solution vs. iteration and print the
% results
hold on;plot(Cycle,Best{b}.GBest.PObj,'b*');xlabel('Iteration');ylabel('Best solution value');pause(0.0001)
fprintf('Cycle: %6d, Best (Penalized): %6.4f, Objective: %6.4f\n',Cycle,OveralBestPObj,OveralBestObj);
end
Solution.PObj=OveralBestPObj;% Objective value for best non-penalized solution
Solution.Design=OveralBestDes;% Design for best non-penalized solution
%% Save the results
save('SBO_Results.mat','Solution')
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 包子阳,余继周,杨杉.智能优化算法及其MATLAB实例(第2版)[M].电子工业出版社,2016.
[2]张岩,吴水根.MATLAB优化算法源代码[M].清华大学出版社,2017.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/120917776
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)