www.pudn.com > DE(rand1).rar > compute_rand1.m, change:2011-12-17,size:883b


function [gbest,gbsolution]=compute_rand1(Popsize,Dim,Pc,F,s,poprange,Max_iter,compute,gbest,gbsolution) 
% initial the population 
pop=initialpop(Popsize,Dim,poprange); 
 
obj=benchmark_function(pop,s); 
 
[sobj,spos]=sort(obj); 
 
gbest(1,compute)=sobj(1); 
 
pos=spos(1); 
 
gbsolution(compute,:)=pop(pos,:); 
 
 
 
 
% iterations 
for iter=2:Max_iter 
     
    M_pop=mutation_rand1(pop,F); 
     
    CR_pop=crossover(pop,M_pop,Pc); 
     
    CR_pop=adjust_solution(CR_pop,poprange); 
     
    [New_pop,obj]=select(pop,obj,CR_pop,s); 
     
    [sobj,spos]=sort(obj); 
     
    if (sobj(1)<gbest(iter-1,compute)) 
         
        gbest(iter,compute)=sobj(1); 
         
        pos=spos(1); 
         
        gbsolution(compute,:)=New_pop(pos,:);   
         
    else 
        gbest(iter,compute)=gbest(iter-1,compute); 
         
    end 
     
    pop=New_pop; 
end