How can i minimize the computation time?

조회 수: 1 (최근 30일)
Zainor
Zainor 2013년 5월 31일
Hye All
I need to solve scheduling optimization problem. I wanna check every combination that exist and evaluate the fitness of each combination. My problem is that it may take a very long time to solve it. How can I reduce computation time?
solHari=zeros(3,8); % pre-allocate for speed
% 'temp1' until 'temp8' is cell that contains
% rows matrices(three rows, 1 column) with a very big size
bestSol=solHari;
bestFitness=-100000;
for a=1:length(temp1)
solHari(:,1)=temp1{a};
for b=1:length(temp2)
solHari(:,2)=temp2{b};
for c=1:length(temp3)
solHari(:,3)=temp3{c};
for d=1:length(temp4)
solHari(:,4)=temp4{d};
for e=1:length(temp5)
solHari(:,5)=temp5{e};
for f=1:length(temp6)
solHari(:,6)=temp6{f};
for g=1:length(temp7)
solHari(:,7)=temp7{g};
for h=1:length(temp8)
solHari(:,8)=temp8{h};
fit=fitnessFunction(solHari);
if fit>bestFitness
bestFitness=fit;
bestSol=solHari;
end;
end
end
end
end
end
end
end
end
  댓글 수: 1
Roger Stafford
Roger Stafford 2013년 5월 31일
You have said that the 'temp' cells have a "very big size" but you haven't said how big. Let us suppose that each one has, say, a hundred entries in it. In that case the number of times you would call on 'fitnessFunction' would necessarily be 100^8 which is 10^16, that is, ten thousand million million times. That would indeed take a "very long time" to compute no matter how efficient the code is. It is to be hoped your sizes are not that large.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 5월 31일
If at all possible, do not call fitnessFunction so many times. Arrange so that fitnessFunction can operate on multiple values simultaneously.
At each point you assign to solHari(:,k) with varying k, and you never change solHari(I,J) otherwise. Therefore all rows of solHari are going to be exactly the same. Is there a point to that?
It is possibly the case that you could precompute some of the values that go into the fitnessFunction calculation, so that they do not end up getting computed each time. We would need to look at the fitnessFunction code to work on that.
Depending on how fitnessFunction is constructed, it might be the case that given some of the leading values in solHari, you can prove that changing the values in the remaining portions will never produce the best fitness. If that can be done then potentially a lot of time could be saved.

카테고리

Help CenterFile Exchange에서 Surrogate Optimization에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by