非常耗时的代码

时间:2013-09-29 18:26:49

标签: matlab parfor

如果您可以帮助我对其执行时间进行任何改进,我会发布这部分代码。

我尝试过编写代码并使用Matlab编译器,但没有重要改进。

代码被调用数百万次(一次执行需要数小时,I5 3.5GH,Ram = 4GH):


function [res] = binCross(a,b,cr) 

s=length(a);
mui = rand(1,s) < cr ; % all random numbers < CR are 1, 0 otherwise
mpo = mui < 0.5; 
res= a.*mpo + b.*mui; 
fx=randi(s);
res(fx)=b(fx); 

end


function [res] = mutate(a,b,c,f)

res=a+f*(b-c);


function s=simplebounds(s,Lb,Ub)

  % Apply the lower bound
  ns_tmp=s;
  I=ns_tmp<Lb;
  ns_tmp(I)=Lb(I);

  % Apply the upper bounds 
  J=ns_tmp>Ub;
  ns_tmp(J)=Ub(J);

  % Update this new move 

  s=ns_tmp;

end

上述binCross函数据说是该函数最复杂的。

提前谢谢

0 个答案:

没有答案
相关问题