How can i minimize the computation time?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Roger Stafford
am 31 Mai 2013
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.
Antworten (1)
Walter Roberson
am 31 Mai 2013
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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!