Finding 2 independent input variables that provides mimimum of a function
Show older comments
I am trying to minimize the return value from the function called "blackbox" using the Matlab optimization function "fmincon". To make it simple, the "blackbox" function takes two scalar variables and returns one scalar output, and there is no equality or inequality relationship with these two variables. However, there are fixed maximum and minimum values for the two variables. 2Variables is 1 X 2 matrix containing two scalar values. The syntax that I used is as below:
fmincon(@blackbox,2Variables,[],[],[],[],[1000,5000],[2000,10000],[],optimset('TolX',1e-3,'LargeScale','off')
The challenge is that the function doesn't seem to optimize the '2Variables'. However, I am getting the message such as:
Optimization terminated successfully: Search direction less than 2*options.TolX and maximum constraint violation is less than options.TolCon.
Do you know how to modify either function syntax or option settings to obtain any reasonably optimized values for '2Variables'?
Answers (3)
Walter Roberson
on 16 Jun 2011
0 votes
Remember, fmincon is a local minimizer. You should expect that blackbox functions might have arbitrary numbers of arbitrary deep local minima. A global optimizer from the Global Optimization Toolbox has a better chance of finding a "good" minima -- though of course with any black-box function you can never know if you have reached the global minimum.
Leno
on 16 Jun 2011
0 votes
4 Comments
Walter Roberson
on 16 Jun 2011
fminsearch is not a global minimizer. For a global minimizer, see for example http://www.mathworks.com/help/toolbox/gads/globalsearch.run.html
None of the functions provided with base MATLAB are global minimizers. Plausibly, though, there is a global minimizer in the MATLAB File Exchange.
Leno
on 17 Jun 2011
Walter Roberson
on 17 Jun 2011
If GlobalSearch is coming up undefined, you probably do not have the optional Global Optimization Toolbox.
Leno
on 20 Jun 2011
Matt Tearle
on 16 Jun 2011
Given that blackbox is a function of two variables, why not do some visualization to see what it looks like?
x = linspace(xmin,xmax);
y = linspace(ymin,ymax);
[X,Y] = meshgrid(x,y);
[m,n] = size(X);
Z = zeros(m,n)
for k = 1:n
for j = 1:m;
Z(j,k) = blackbox(X(j,k),Y(j,k));
end
end
contour(X,Y,Z)
3 Comments
Walter Roberson
on 16 Jun 2011
Define any fixed mesh size, and I can come up with a blackbox function that has an arbitrarily deep minimum completely hidden within one of the mesh squares. It might be difficult to discover if the grid spacing gets down to eps() of the grid coordinates, but any arbitrarily thin downward spike can be clearly added to the blackbox function at any point. If the function was not black box you might have a choice of detecting this.
Matt Tearle
on 17 Jun 2011
True, but in that case a numerical optimization routine will mostly likely miss it as well. So the problem is the nature of the blackbox function. I don't see why it's not a good idea to get a feel for the landscape. It might give Leno an idea of what the distribution of local minima looks like.
Leno
on 17 Jun 2011
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!