Matlab's MultiStart runs fine, but GlobalSearch bugs out

4 ビュー (過去 30 日間)
Anthony
Anthony 2013 年 7 月 3 日
I'm trying to run a global optimization in Matlab using the global optimization toolbox. I am using the fmincon local optimizer as an input. I am able to successfully run the fmincon local optimizer, as well as the MultiStart global optimizer with this problem. However, when I try to set it up as a GlobalSearch, I get an error message.
Below is the code I am trying to use for the GlobalSearch:
%the functions is f(w) rather than f(x)
%constraints:
A = [1,0,0; 0,1,0; 0,0,1];
b = [.80, .80, .80];
Aeq = [1 1 1];
beq = 1;
lb = .10 * [1 1 1];
ub = .8 * [1 1 1];
w = [weight1, weight2, weight3];
wstart = randn(3,1);
options = optimset('Algorithm','interior-point');
% function handle for the objective function (note that variables
% aa through hh are additional parameters that the solver does not modify):
h = @(w)Difference_in_Returns(w(1),w(2),w(3), aa, bb, cc, dd, ee, ff, gg, hh);
% problem structure:
problem = createOptimProblem('fmincon','x0',wstart,'objective',h,'Aineq',A,...'
'bineq',b,'Aeq',Aeq,'beq',beq,'options',options,'lb',lb,'ub',ub);
gs = GlobalSearch;
run(gs,problem)
When I try to run this, Matlab bugs out and prints:
Error using -
Matrix dimensions must agree.
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>i_calcConstrViolation (line 593)
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>i_calcPenalty (line 627)
Error in C:\Program Files\MATLAB\R2012a\toolbox\globaloptim\globaloptim\private\
globalsearchnlp.p>globalsearchnlp (line 343)
Error in GlobalSearch/run (line 330)
[x,fval,exitflag,output] = ...
Error in Optimization_Setup (line 62)
run(gs,problem)
I believe the problem is outlined by the lines:
Error using -
Matrix dimensions must agree.
Error in GlobalSearch/run (line 330)
[x,fval,exitflag,output] = ...
Any tips are highly appreciated. Please let me know if you have any questions.

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 7 月 3 日
Can you confirm that the objective function: h does not return Inf or NaN during its evaluations for all w?
Also in MultiStart how many runs are you specifying?
>> [x,f] = run(ms,problem,k)
Does it fail if you make k large?
  2 件のコメント
Anthony
Anthony 2013 年 7 月 3 日
編集済み: Anthony 2013 年 7 月 3 日
Thank you for your response.
Is there a way to verify whether an Inf or NaN for the objective function is the source of the problem (in other words: could I find out what value for w GlobalSearch is trying to use right before the error)? I would be very surprised if the function returned either of those values though...
I run MultiStart with 500 randomly generated start points. This takes about 4 minutes to run. How large should I be trying?
Shashank Prasanna
Shashank Prasanna 2013 年 7 月 3 日
You must know if the objective function has a possibility of returning an inf or a nan. If not you can always check of the output using isinf and isnan functions.
In order to obtain intermediate values you can use outputfcn:
The only reason I mentioned that you use a large enough start points is to verify if MultiStart would fail if it stepped on that special case that is making globalsearch fail.
One last point:
You have redundant constraints:
A = [1,0,0; 0,1,0; 0,0,1];
b = [.80, .80, .80];
is basically: x_i < 0.8 for i = 1,2,3
lb = .10 * [1 1 1];
ub = .8 * [1 1 1];
is basically: 0.1 < x_i < 0.8 for i = 1,2,3
Just use the bound constraints. Don't use both.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGlobal or Multiple Starting Point Search についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by