I have written this function to find indices based on certain criteria. It should work, the problem is that it will take 2-3 days to run on my pc. Is there any way to get it down below an hour (or faster at all) ? This really doesn't need to be very fast. But 2 days is unacceptably slow.
I don't expect an in depth analysis on the function (Though it would be nice). Just some general improvements.
All it essentially is is 3 for-loops used to populate 8 large 3d arrays using another 256x8 matrix Logic. Then a few logic tests to find the desired index.
%These are sample values from the g.u.i. and other functions -
%ignore up til the loops unless you need it to understand something in the loops.
PriceMat=[58867 55620 16682 97384 11660 18175 25896 16300];
CapMat=[1400 1200 450 3600 150 1330 2000 250];
RepMat=[58 53 31 127 15 164 242 27];
DesiredRep=293.04;
DesiredCap=2600;
prevmin=99999999;
P=perms(0:7);
D=zeros(256,8,40320);
Cap=zeros(size(D,3),8);
Rep=zeros(size(D,3),8);
Price=zeros(size(D,3),8);
SufRep=zeros(1,size(D,3));
SufCap=zeros(1,size(D,3));
CapTot=zeros(1,size(D,3));
RepTot=zeros(1,size(D,3));
PriceTot=zeros(1,size(D,3));
for i=1:40320
for x=1:8
for j=1:256
D(j,x,i)=P(i,x)*Logic(j,x);
Cap(i,x)=D(j,x,i)*CapMat(x);
Price(i,x)=D(j,x,i)*PriceMat(x);
Rep(i,x)=D(j,x,i)*RepMat(x);
CapTot=sum(Cap,2);
RepTot=sum(Rep,2);
PriceTot=sum(Price,2);
if CapTot(i)>=DesiredCap
SufCap(i)=true;
else
SufCap(i)=false;
end
if RepTot(i)>=DesiredRep
SufRep(i)=true;
else
SufRep(i)=false;
end
if SufRep(i)==true && SufCap(i)==true
if PriceTot(i)<=prevmin
prevmin=i;
end
end
end
end
end
return prevmin
Logic(j,x)?D(j,x)?Dis 3D...