Speeding up exhaustive search
古いコメントを表示
I need to find the global minimum of a function using exhaustive search. I have 10 function variables x1,x2,x3,...,x10 ∈ [0,10]. In order to produce all possible combinations of those function variables, i have written a code with 10 for loops and check their value.
Although this works, i would like to speed it up because it takes too much time to finish. Parfor can not help me here because the loops are not independent.
I would like some suggestions on how to speed up this code. Part of my code:
x=zeros(1,10);
for x1=1:10
x(1)=x(1)+step; %step=1 so at each iteration x(1)=1,2,3,...,10
for x2=1:10
if x(2)==10
x(2)=0;
end
x(2)=x(2)+step;
end
repeat for each variable
%evaluate f(x1,x2,x3,...,x10)
end
4 件のコメント
Cedric
2013 年 2 月 5 日
Could you post, at least partially, your code?
For that you should look at what the Optimization toolbox has to propose, because your are not exhaustive here (note that even the best methods won't be exhaustive); what happens if your global minimum lies in between two steps which are both characterized by a value of f greater than other values of f elsewhere?
The Optim. toolbox will provide you with tools using variable steps, that will be better suited for what you are trying to achieve.
Doug Hull
2013 年 2 月 5 日
Are X1, X2, etc constrained to be integers? It is not clear.
dimitris
2013 年 2 月 5 日
採用された回答
その他の回答 (1 件)
Doug Hull
2013 年 2 月 5 日
0 投票
This is going to be so dependent on your problem.
Is it smooth? Can you start with a 3x3x3x... grid, then search in the most likely areas?
Have you run the profiler? This will tell you where the code is running the slowest.
You will have to show us the algorithm for any realistic help on this. Just modify the question (rather than comment) with the new information.
カテゴリ
ヘルプ センター および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!