Speeding up exhaustive search
Show older comments
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 Comments
Cedric
on 5 Feb 2013
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
on 5 Feb 2013
Are X1, X2, etc constrained to be integers? It is not clear.
dimitris
on 5 Feb 2013
Accepted Answer
More Answers (1)
Doug Hull
on 5 Feb 2013
0 votes
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.
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!