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
Re: a very time consumming code
Posted: Sep 28, 2013 4:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi again,

Here is tha main function causing such ahuge time consumption, I found that the main issue is in the number of calls of sub functions, where 'cec13_func' is just and evaluation function.

Any clues please?

*******************************
function []=main()
clc
clear all

tic
np=50;
d=30;

iter=10000*d/np;
cr=0.9;
f=0.5;

nexe=51;

for func=16:28
minim=-100;
maxim=+100;

switch func
case 1
optim=-1400;
case 2
optim=-1300;
case 3
optim=-1200;
case 4
optim=-1100;
case 5
optim=-1000 ;
case 6
optim=-900;
case 7
optim=-800;
case 8
optim=-700;
case 9
optim=-600;
case 10
optim=-500;
case 11
optim=-400;
case 12
optim=-300;
case 13
optim=-200;
case 14
optim=-100;
case 15
optim=100;
case 16
optim=200;
case 17
optim=300;
case 18
optim=400;
case 19
optim=500;
case 20
optim=600;
case 21
optim=700;
case 22
optim=800;
case 23
optim=900;
case 24
optim=1000;
case 25
optim=1100;
case 26
optim=1200;
case 27
optim=1300;
case 28
optim=1400;
otherwise;
end

Lb=ones(1,d)*minim;
Ub=ones(1,d)*maxim;

vectBests=zeros(1,iter);

for nbr=1:nexe
pop=initPop(np,d,minim,maxim);

best=pop(1,:);
bestFit=cec13_func(best',func);

fits=cec13_func(pop',func);

for it=1:iter;

if bestFit-optim<=1e-8;
vectBests(it)=optim;
break;
end

for i=1:np

xi=pop(i,:);

j=randi(np);
while j==i
j=randi(np);
end

k=randi(np);
while k==i || k==j
k=randi(np);
end

l=randi(np);
while l==i || l==j || l==k
l=randi(np);
end

xj=pop(j,:);
xk=pop(k,:);
xl=pop(l,:);

vi=mutate(xj,xk,xl,f);
ui=binCross(xi,vi,cr);
ui=simplebounds(ui,Lb,Ub);

fu=cec13_func(ui',func);
if fu<fits(i)
% xi=ui;
pop(i,:)=ui;
fits(i)=fu;
end

end

[bestFit,ind]=min(fits);
best=pop(ind,:);
vectBests(it)=bestFit;

end

sols(nbr)=vectBests(it)-optim;

sols(nbr)
[func nbr]



end

moy=mean(sols)
dev=std(sols)

end
toc
end

*************************



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.