Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: a very time consumming code
Replies: 5   Last Post: Sep 28, 2013 4:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
draasoft

Posts: 12
Registered: 3/28/12
a very time consumming code
Posted: Sep 27, 2013 11:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi all, I am posting this portion of code if you could help me in making any improvements for its execution time.

I tried verctorising the code and using Matlab compiler but no important improvement.

codes being called millions of times (one execution needs hours with a I5 3.5GH and 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
*****************

The above 'binCross' function is said to be the most complex by theprofiler.

Thank you in advance



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.