Finding 2 independent input variables that provides mimimum of a function
6 ビュー (過去 30 日間)
古いコメントを表示
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'?
0 件のコメント
回答 (3 件)
Walter Roberson
2011 年 6 月 16 日
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.
0 件のコメント
Leno
2011 年 6 月 16 日
4 件のコメント
Walter Roberson
2011 年 6 月 17 日
If GlobalSearch is coming up undefined, you probably do not have the optional Global Optimization Toolbox.
Matt Tearle
2011 年 6 月 16 日
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 件のコメント
Matt Tearle
2011 年 6 月 17 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!