Finding 2 independent input variables that provides mimimum of a function

6 ビュー (過去 30 日間)
Leno
Leno 2011 年 6 月 16 日
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'?

回答 (3 件)

Walter Roberson
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.

Leno
Leno 2011 年 6 月 16 日
Thank you for your answer. I agree that I would have a better chance of finding a "good" minima by using matlab function such as fminsearch. However, I couldn't find a way to set boundaries (min and max) for the two input variables using fminsearch function. Thus, I considered using fmincon function. Are there any good matlab function to use to simultaneously optimize the two variables with fixed min and max?
  4 件のコメント
Walter Roberson
Walter Roberson 2011 年 6 月 17 日
If GlobalSearch is coming up undefined, you probably do not have the optional Global Optimization Toolbox.
Leno
Leno 2011 年 6 月 20 日
Does it return the message "No Active Constraints" since there is no equality or inequality relationship in the following syntax?
fmincon(@blackbox,2Variables,[],[],[],[],[1000,5000],[2000,10000],[],optimset('TolX',1e-3,'LargeScale','off')

サインインしてコメントする。


Matt Tearle
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
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.
Leno
Leno 2011 年 6 月 17 日
I already visualized the function values for the example that I was optimizing. The function looks like a partially rolled up paper.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by