function [conver_result,Final_result,all_result]=horseherd_process(datapass,pop_size,no_of_iter) traindata=datapass{1}; traindata_matrix=cell2mat(traindata); len_data=max(max(traindata_matrix)); max_val1=1; min_val1=0; dim=len_data; max_range=[repmat(max_val1,[1 dim])]; min_range=[repmat(min_val1,[1 dim])]; len=length(max_range); int_pos_data=init_pop_data(pop_size,len,max_range,min_range); data_pass_to{1}=[]; for indr=1:pop_size dataele=(int_pos_data(indr,:)); dataele=limit_chk_process(dataele,... max_val1,min_val1,data_pass_to); elechoose=dataele; obj_result=objective_process(datapass,elechoose); int_pos_data(indr,:)=dataele; fitness(indr)=obj_result{1}; finalall{indr}=obj_result; end [maxval,maxloc]=max(fitness); bestdata=int_pos_data(maxloc(1),:); bestfit=maxval; xg=bestdata; gbestdata=int_pos_data(maxloc(1),:); gbestfit=maxval; xhi=gbestdata; [rr,cc]=size(int_pos_data); initvel=ones(rr,cc)*0.01; iter_inc=1;% Loop counter % Main loop data_pass_to{1}=0; percentagehorse=[10 20 30 40]/100; agedata=randsrc(1,pop_size,[1 2 3 4;percentagehorse]); wg=0.95;wh=0.9;wsoc=0.9;wim=0.8;wdefmec=0.9;wro=0.9; giter=1;hmiter=1;sociter=1;imiter=1;roiter=1;defmeciter=1; while iter_inc<=no_of_iter low=0.95;upp=1.05; giter=wg*giter; hmiter=hmiter*wh; sociter=sociter*wsoc; imiter=imiter*wim; defmeciter=defmeciter*wdefmec; roiter=roiter*wro; newpos=randsrc(1,5,1:pop_size); newpos2=randsrc(1,5,1:pop_size); for kpop=1:pop_size pit=int_pos_data(kpop,:); r=rand; gram=giter*(low+r*upp)*pit; hm=hmiter*(bestdata-pit); socm=sociter*(mean(int_pos_data)-pit); imm=imiter*(mean(int_pos_data(newpos,:))-pit); defmec=defmeciter*(mean(int_pos_data(newpos2,:))-pit); ro=roiter*(pit); velmalpha=gram+defmec; velmbeta=gram+hm+socm+defmec; velmgamma=gram+hm+socm+defmec+imm+ro; velmdel=gram+imm+ro; if(agedata(kpop)==1) initvel(kpop,:)=velmalpha; end if(agedata(kpop)==2) initvel(kpop,:)=velmbeta; end if(agedata(kpop)==3) initvel(kpop,:)=velmgamma; end if(agedata(kpop)==4) initvel(kpop,:)=velmdel; end end int_pos_data=int_pos_data+initvel; for indr=1:pop_size dataele=(int_pos_data(indr,:)); dataele=limit_chk_process(dataele,... max_val1,min_val1,data_pass_to); elechoose=dataele; if(iter_inc==no_of_iter && indr==pop_size) datapass{21}=1; else datapass{21}=0; end obj_result=objective_process(datapass,elechoose); int_pos_data11(indr,:)=dataele; fitnessl1(indr)=obj_result{1}; finalall{indr}=obj_result; end [maxval,maxloc]=max(fitnessl1); bestdata=int_pos_data11(maxloc(1),:); bestdatafinal=finalall{maxloc(1)}; [best_conver_data(iter_inc),best_location(iter_inc)]=max(fitnessl1); final_data{iter_inc}=bestdata; final_alldata{iter_inc}=bestdatafinal; if iter_inc>=2 && best_conver_data(iter_inc)