function f=benchmark_func(x,func_num)
global initial_flag
persistent fhd f_bias
if initial_flag==0
if func_num==1 fhd=str2func('sphere_shift_func'); %[-100,100]
elseif func_num==2 fhd=str2func('schwefel_func'); %[-100, 100]
elseif func_num==3 fhd=str2func('rosenbrock_shift_func'); %[-100,100]
elseif func_num==4 fhd=str2func('rastrigin_shift_func'); %[-5,5]
elseif func_num==5 fhd=str2func('griewank_shift_func'); %[-600,600]
elseif func_num==6 fhd=str2func('ackley_shift_func'); %[-32,32]
elseif func_num==7 fhd=str2func('fastfractal_doubledip'); %[0,1]
end
%f_bias = [-450 -450 390 -330 -180 -140 0];
load fbias_data;
end
f=feval(fhd,x)+f_bias(func_num);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%Unimodal%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1.Shifted Sphere Function
function fit=sphere_shift_func(x)
global initial_flag
persistent o
[ps,D]=size(x);
if initial_flag==0
load sphere_shift_func_data
if length(o)>=D
o=o(1:D);
else
o=-100+200*rand(1,D);
end
initial_flag=1;
end
x=x-repmat(o,ps,1);
fit=sum(x.^2,2);
% 2. Shifted Schwefel's Problem 2.21
function fit = schwefel_func(x)
global initial_flag
persistent o
[ps, D] = size(x);
if (initial_flag == 0)
load schwefel_shift_func_data
if length(o) >= D
o=o(1:D);
else
o=-100+200*rand(1,D);
end
initial_flag = 1;
end
x=x-repmat(o,ps,1);
fit = max(abs(x), [], 2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%Multimodal%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 3.Shifted Rosenbrock's Function
function f=rosenbrock_shift_func(x)
global initial_flag
persistent o
[ps,D]=size(x);
if initial_flag==0
load rosenbrock_shift_func_data
if length(o)>=D
o=o(1:D);
else
o=-90+180*rand(1,D);
end
initial_flag=1;
end
x=x-repmat(o,ps,1)+1;
f=sum(100.*(x(:,1:D-1).^2-x(:,2:D)).^2+(x(:,1:D-1)-1).^2,2);
% 4.Shifted Rastrign's Function
function f=rastrigin_shift_func(x)
global initial_flag
persistent o
[ps,D]=size(x);
if initial_flag==0
load rastrigin_shift_func_data
if length(o)>=D
o=o(1:D);
else
o=-5+10*rand(1,D);
end
initial_flag=1;
end
x=x-repmat(o,ps,1);
f=sum(x.^2-10.*cos(2.*pi.*x)+10,2);
% 5.Shifted Griewank's Function
function f=griewank_shift_func(x)
global initial_flag
persistent o
[ps,D]=size(x);
if initial_flag==0
load griewank_shift_func_data
if length(o)>=D
o=o(1:D);
else
o=-600+1200*rand(1,D);
end
o=o(1:D);
initial_flag=1;
end
x=x-repmat(o,ps,1);
f=1;
for i=1:D
f=f.*cos(x(:,i)./sqrt(i));
end
f=sum(x.^2,2)./4000-f+1;
% 6.Shifted Ackley's Function
function f=ackley_shift_func(x)
global initial_flag
persistent o
[ps,D]=size(x);
if initial_flag==0
load ackley_shift_func_data
if length(o)>=D
o=o(1:D);
else
o=-30+60*rand(1,D);
end
initial_flag=1;
end
x=x-repmat(o,ps,1);
f=sum(x.^2,2);
f=20-20.*exp(-0.2.*sqrt(f./D))-exp(sum(cos(2.*pi.*x),2)./D)+exp(1);
% 7. FastFractal "DoubleDip"
function f=fastfractal_doubledip(x)
global initial_flag
persistent o ff
[ps,D]=size(x);
if initial_flag==0
load fastfractal_doubledip_data
ff = FastFractal('DoubleDip', 3, 1, o, D);
initial_flag=1;
end
f=ff.evaluate(x);
%%%%% end of file %%%%%
MLCC.rar_MLCC matlab_mlcc_协同演化算法_合作演化_自适应分组
版权申诉
5星 · 超过95%的资源 37 浏览量
2022-07-15
03:41:52
上传
评论 2
收藏 99KB RAR 举报
御道御小黑
- 粉丝: 61
- 资源: 1万+
最新资源
- nginx配置文件,注意其中需要对应宿主机的路径
- 自用数据集自用数据集自用数据集
- HTML5小游戏【堆雪人-优秀H5小游戏合集】游戏源码分享下载 - epicsnowman.zip
- SNMP Client 是SNMP测试工具
- Android Camera内存统计脚本
- AD9220高速数据芯片硬件参考设计原理图+STM32F103单片机驱动程序代码+芯片技术手册资料.zip
- 常用爆破用户名字典top500
- meta-llama-3-8b-instruct 的 model-00003-of-00004.safetensors 的2/3
- bootstrap-select.js bootstrap-select.css
- EasyPoi Excel和 Word简易工具类
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论4